Thursday, January 7, 2010

Rails use :select for better performance

If you want to retrieve some fields information from database, then it is better to use select in the find method.
Example use below
@movies = Movie.find(:all, :select => 'title, description')
instead of
@movies = Movie.find(:all)

It will get only the title and description and store into instance variable (hash) @movies.

Here you application load time will definetly decreased.

No comments: