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

Improve efficiency by pre-fetching entire page tree branches from the database #40

Closed
ababic opened this issue Sep 29, 2016 · 1 comment

Comments

@ababic
Copy link
Collaborator

ababic commented Sep 29, 2016

Currently, database queries are made at each level of navigation output, counting children for pages (where necessary), and fetching those children for display at the next level. I think it would be far more efficient to intelligently query for everything at once and build some kind of pythonic representation of the data that can be accessed directly by all levels of that menu, without having to access the database again.

This could be particularly effective when used in combination with PageQuerySet.specific()

Probably simplest to start with section_menu, as the query will be the easiest to build (it's entirely page driven, and always starts at the same level/depth). main_menu will be trickier because of figuring out how deep to go, but still very possible. With those two cracked, applying to children_menu and flat_menus should be a doddle.

@ababic ababic added this to the v1.5 milestone Sep 29, 2016
@ababic ababic changed the title Improve efficiency by fetching entire page tree branches from the database at once Improve efficiency by pre-fetching entire page tree branches from the database Sep 29, 2016
@ababic ababic modified the milestones: Some time in the future, v1.5 Sep 29, 2016
@ababic
Copy link
Collaborator Author

ababic commented Oct 7, 2016

I've experimented with this approach on section_menu, and the performance benefits weren't that obvious. A few less queries, but the speed of the queries overall didn't really improve... I guess because it's one huge/slow query as opposed to more little ones.

Overall, rendering time actually increased slightly... I guess because of the additional operations needed to translate the full page queryset into something that can be easily referenced by the various sub_menu calls within the same menu.

I'm going to shelve this for now. For all the added complication it adds to the codebase and design, I don't think the benefits are worth it.

@ababic ababic closed this as completed Oct 7, 2016
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