Hey guys,

I just noticed one of my find calls is creating n+1 queries to be
run.  The find looks like this:

     Class.find(:all,
        :include => [:user, :users],
        :conditions =>  {:id=> ids},
        :order => order )

This is on Rails 2.3.2.

First the class is queried, then the join table between class and
users, and then each user in the users collection is queried
individually. If I remove the :users from the include, then the users
aren't loaded (until I hit them in the view).

I thought the whole point of :include is to avoid the n + 1 scenario?

Cheers,

Tim.


--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to