Jatin Kumar wrote in post #972585:
> On Wed, Jan 5, 2011 at 6:10 PM, Marnen Laibow-Koser
> <lists@ruby-forum.com>wrote:
>
>>
>> I didn't mean to use raw SQL *instead of* ActiveRecord. But sometimes
>> ActiveRecord's abstractions aren't terribly good
>
> (notably with bulk and
>> aggregate operations, as well as certain types of joins),
>
> Could you elaborate a little bit on these operations and joins, name a
> few
> and tell why ActiveRecord isn't good with them. I am pretty low on my
> learning curve in this domain, so your experience would really help.
Well, for aggregate operations, AR just doesn't provide much abstraction
at all. Yes, User.count and User.max :age are helpful, but more complex
aggregate operations (for example, on associated tables) have to be done
in SQL, or in the application layer. Many Rails developers would opt
for the latter, but IMHO that's inefficient and silly, since the DB can
do these operations for more efficiently.
Perhaps Arel has changed this. I gather that this is probably a goal,
but I don't know if it's been achieved.
Bulk updates are another area where AR is really inefficient, since
update_all is pretty anemic. ar-extensions can help here, though.
Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org
--
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