On the Edge, Part 1 – New RailsLab Episode in our Scaling Rails series introduces three ActiveRecord plugins

On RailsLab we’ve just posted a new episode in the Scaling Rails series. In Episode 19, the first of a three-part series titled “On the Edge,” Gregg Pollack discusses three ActiveRecord plugins for database optimization. The first, Bullet, helps you reduce the number of ActiveRecord queries in your application by giving you alerts/notifications. Gregg takes us though specific examples of how a Bullet notification can lead you to take some relatively simple steps for database optimization.

Next, Gregg looks at Rails Indexes, a new tool that uses Rake tasks to, you guessed it, find missing Rails indexes. He shows us how to install the plugin and run the first Rake task, which finds all the models, looks at the relationship between them, and then looks at the database to see if there are any missing indexes. It then generates a migration. The second Rake task looks for the find method in the application and recommends indexes. Lastly, Gregg demonstrates Scrooge, a SQL query optimizer. By discovering columns in a table that aren’t being used in a particular view, Scrooge can identify places where your database queries are casting strings unnecessarily. After installing Scrooge, when you refresh the page the query only casts for only the columns needed in that view. Now you can optimize your SQL queries without having to change a single line of code.

Additional Resources

RailsLab on iTunes

Don’t forget to subscribe to the RailsLab podcast on iTunes where you’ll find the Scaling Rails series as well as our other RailsLab episodes. Download one, or the whole series and play them on your iPhone or computer.

marketing@newrelic.com'

View posts by .

Interested in writing for New Relic Blog? Send us a pitch!