Ruby on Rails Thursday, April 29, 2010

David Zhu wrote:
> Is it possible to do a find all, and then return the # of items?

Better to use the built-in aggregate functions.

http://railsapi.com/doc/rails-v2.3.5/classes/ActiveRecord/Calculations/ClassMethods.html#M001357

This will perform the count in SQL and will be much more efficient than
building all those ActiveRecord objects.
--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment