You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.
Associations seem to be eager-loading when all that is required is a count. This can take awhile when the count of rows is even in the 10k+ area, if not more.
The problem may be with DataMapper::Collection#delegate_to_relationship which does not create a lazyarray or something like it. At that point, it fully builds the collection from the relationship before anything (e.g., count) is ever done to it. It would seem that the only time we would actually want to load something when we want to do something with it.
This is probably not news to anyone but me, however, SEL is used regardless of whether or not the association in a loop is ever used for anything. That’s obviously an affect of the association not being a lazyarray when called.
Here is a potential change to dm-core that fixes my original gist. It changes the spec and Collection to lazy load for #delegate_to_relationship. This ends up breaking the many_to_many spec in a way I have yet to understand, but I will post up anyway.
by Tony Pitale
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Associations seem to be eager-loading when all that is required is a count. This can take awhile when the count of rows is even in the 10k+ area, if not more.
http://gist.github.com/156762
Created by Tony Pitale - 2009-07-27 22:00:09 UTC
Original Lighthouse ticket: http://datamapper.lighthouseapp.com/projects/20609/tickets/992
The text was updated successfully, but these errors were encountered: