Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Eager Load entire tree? #8

Open
mltsy opened this issue Mar 2, 2012 · 2 comments
Open

Eager Load entire tree? #8

mltsy opened this issue Mar 2, 2012 · 2 comments

Comments

@mltsy
Copy link

mltsy commented Mar 2, 2012

I've got a page where I need to display all elements in a table, and it just takes forever to load, partly because it issues a separate query to retrieve each node's children. I imagine it would go much faster to load all the rows at once, and then associate them based on their parent_ids. This, of course, isn't a good solution if you need to load only 10% of a large table, and there's no way to determine which rows need to be loaded without checking for parent_ids one query at a time.

To solve that it might be a good idea to setup something like "eager-loading sets" where you could tag each instance with a set name, so you could eager load a named set... or something.

But for starters, just eager loading the whole table would be awesome.

@flsafe
Copy link

flsafe commented Mar 5, 2012

I've also run into a scenario where this functionality would be the best solution.

@jasonseney
Copy link

Yes, right now to display the tree, I'm getting n+1 queries through the whole tree. I've tried using some preload hacks for datamapper but can't seem to get it working. Is there a work around to load all the elements with their "tree" attributes intact?

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

No branches or pull requests

3 participants