Thanks for the reply, I believe I understand now.

So the issue is that once it decides that *any* of the :include  
tables are referenced in :conditions it joins *all* of them - even  
though it's possible that some of the includes are not referenced.

Personally I've not been bitten by performance issues with the  
prequery but if your non-destructive-patch improves that situation  
I'd say it was a good idea.

Is your patch intelligent enough to cope with this?:

Album.find(:all, :limit => 10, :include => [{:songs  
=> :uploads}, :artists],
   :conditions => 'uploads.errored = 0')

where the prequery joins songs and uploads but not artists?

I bring it up because that strikes me as a reason why it just does  
all of the joins - bit of a pain to tease apart exactly which joins  
are absolutely required (not impossible - just a pain).

Regards,
Trevor

On 13-Sep-07, at 12:00 PM, Pratik wrote:

>
>> Album.find(:all, :limit => 10, :include => :songs, :conditions =>
>> 'songs.active = 1')
>> # join in prequery, conditions in prequery
>
> Check the prequery for :
>
> Album.find(:all, :limit => 10, :include => [:songs, :artists],
> :conditions => 'songs.active = 1')
> -- 
> Cheers!
> - Pratik
> http://m.onkey.org
>
> 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" 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-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to