Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should use lazy proxy on m2o and x2m associations #109

Open
rvalyi opened this issue Apr 23, 2014 · 3 comments
Open

should use lazy proxy on m2o and x2m associations #109

rvalyi opened this issue Apr 23, 2014 · 3 comments

Comments

@rvalyi
Copy link
Member

rvalyi commented Apr 23, 2014

m2o
product1.categ_id should 1st load ProductCategory proxy with just the name (default to the rec_name read) and the id. And it should hit the server and request all other lazy fields only if other fields are asked.

x2m
for x2m, a CollectionProxy should mimic only a collections with the id attribute and should lazily hit OpenERP to retrieve all other fast fields of all the collection if any other field is asked.

@rvalyi
Copy link
Member Author

rvalyi commented Apr 28, 2014

done for m2o with the lazy property

@rvalyi
Copy link
Member Author

rvalyi commented Apr 28, 2014

for o2m associations, an idea could be that in relation.rb, in method_missing, when we have the method, of an Array (:each), with a Proc passed, then we could may be call to_a with a special option so that when it will do the find upon the specified ids scope, it just build the proxies with just their id and the lazy flag on without hitting OpenERP yet.

Then when the first accessor will be called upon the first item, we should be able to figure out that this lazy proxy belongs to some owner object with a collection association.
So we should reload all the proxies of the collection all together in a single call to OpenERP.

Additionally, this gives us the opportunity to inject the requested field along with the "fast_fields" to eager load them in the single request.

That would be interesting to know if we could collect all the accessors called upon the collection items within the block and request them altogether.
It's worth looking f other ORM are able to introspect somewhat the iteration block or able to collect all the requests fields.
For instance Datamapper says it fixes the N+1 problem in "Strategic Eager Loading"
http://datamapper.org/why.html
are they just eager loading a list of fields or are them doing something smarter?

@rvalyi
Copy link
Member Author

rvalyi commented Apr 28, 2014

actually, it's probably where CollectionProxy should start kicking'in when we create one for the x2m associations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant