On 9/7/07, Gabe da Silveira <[EMAIL PROTECTED]> wrote:
> I have a patch which I believe will be pretty controversial, but I think is
> a improvement overall.  I'd like some feedback from everyone using eager
> loading.  For me this patch is absolutely critical for development on my G4
> where MySQL performance is pretty poor.
>
> http://dev.rubyonrails.org/ticket/9497
>
> This patch is providing my development code with a 300x speed increase...
>
>
> I know it does remove some functionality, but I think the missing
> functionality was limited and occasionally error-prone anyway.  My opinion
> is that explicit :joins provide much more transparency and utility anyway,
> so I think this optimization is worth it in the long run (especially before
> Rails 2.0 hits).
>
> Please post your counter examples or what this breaks in your test suite
> (rather than the contrived tests in the official test suite).

The tests aren't particularly contrived in this case, I've written
similar stuff in the past.  However the large performance boost you're
seeing is probably worth investigating whether we can apply those
joins a little more selectively, or let users opt out of them.

My understanding is that the conditions / joins *have* to be applied
in order for limit / offset to work with an :order or :conditions when
using eager loading.  If you apply the limit / offset to the final
query, it's not limiting correctly, and if you leave the order or
conditions off that query your paginated result set will behave
erratically, with varying numbers per page, or repeated entities.

For an example:

@tickets_from_priority_customers = Ticket.find(:all,
:conditions=>["tickets.open = ? and customers.priority = ?", true,
true], :include=>[:customers])

Now if you start paginating that list,  your stuff will cause bugs?

-- 
Cheers

Koz

--~--~---------~--~----~------------~-------~--~----~
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