Move towards optimization now…


If you are looking to do the query optimization of your rails apps, I can suggest using few tools that does it.

1. First I want to suggest BULLET- A rails plugin/gem to kill N+1 queries and unused eager loading.

Bullet helps in finding the space for eager loading. It has a beautiful way of telling where should you add the eager loading for certain association. Whenever you try to run the code in development browser, it pops up a js alert and tells you exaclty where and what includes you have to add in you finder queries. It also tells you to remove the extra unnecessary eager loading handled in you app.

To add more beauty to it flyerhzm added growl notification as well for the Mac based developers.

2. Second suggested tool will be Slim-Scrooge: SlimScrooge heavily optimises your database interactions

Slim-Scrooge works for optimizing the sql queries by monitoring the required columns for the model and changing inline the queries to fetch only selective columns. So with slim_scrooge working in background you don’t have to worry about giving the options to :select in you find. Instead slim_scrooge will itself analyze what are the columns needed to run your code for the first time and second call to the same action it itself puts the necessary column in select removing the asterisk(*).

I am still skeptical about using it. As it might make the developers lazy(just blindly putting * in queries) and increasing the processing time in slim_scrooge inline query modifier. Though I think it could be a good tool if used once in a while to analyze what are the missing selects in our code. Whatever be the case you might wanna give it a try, its kinda lucraitve.

3. Last but not the least I try to add is rack-bug: Debugging toolbar for Rack applications implemented as middleware.

Remember rails-footnotes? Well Rack-bug is kinda same but seems better and provide more. Better, because its rack based. Provides more with the toolbar giving following info:

  • Rails Info
  • Resource Usage
  • Rack Env
  • SQL
  • AR Objects
  • Memcached
  • Templates
  • Log
  • Memory Usage

I kind of loved it at first sight. So if you already have footnotes. Give it a try. If you dont, then again give it a try to optimize better. Watch the screencast by brynary for more info.

If you have tried any of those feel free to give your opinions. I will be happy to learn how everybody is approaching the technique of optimization.


About these ads

About Ritu

A Ruby on Rails developer from India View all posts by Ritu

3 responses to “Move towards optimization now…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: