Rails Performance Tip: Query Optimization

 by Anand  on   11 Jul 2011

Rails applications will get significant performance boost if the sql queries sent to the database are optimized. Database cialis super active must not be hit with requests unless there is an absolute necessity.

Two Basic online writing sites steps for Optimization:

  1. Add database indexes on all foreign keys
  2. add_index :tasks, :project_id
  3. Use Eager loading to avoid n+1 query problems, in sensible places.
  4. Project.find(12).includes(:tasks, :notes)

    QueryReviewer gem:

This gem helps a lot in optimizing the SQL queries.

For every page request, it gives good statistics on the number of queries, number of slow queries, in-efficient queries etc.,
Check it out.

Tags: , , ,

Leave a comment