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
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.
The text was updated successfully, but these errors were encountered:
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
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.
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 tochildren_menu
andflat_menus
should be a doddle.The text was updated successfully, but these errors were encountered: