-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix: Efficient build menu for versioned and unversioned pages #7807
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
Conversation
pages | ||
.filter(pagecontent_set__language__in=languages) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This query gets looped through on line 275 and it's looking at the related set without a prefetch. I think we should add a one;
pages.prefetch_related(
'pagecontent_set'
).filter(pagecontent_set__language__in=languages)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! The pages
queryset gets turned into a list when get_visible_nodes
is called. Let me have a look at get_visible_nodes
to return a queryset instead of a list. A first glance, it gives the impression there is room for further performance improvement. Maybe we can save another query?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marksweb Now, I've looked into that. pages
is pushed as an iterable into prefetch_related
. So the prefetch is done manually there.
Keeping it as a queryset, is I hoped would improve the database accesses, therefore will not do so. Also, the permissions cache is filled, which - if get_visible_nodes
needed to return a qs - would not be possible and might lead to performance penalties later. Finally, the permission rules are quite complicated. Turning them into queries is not immediately obvious.
I would stay with the current structure.
Description
With djangocms-versioning activated, building menus can take extremely long times for large sites (#7805). While djangocms-versioning's own menu class is not efficient, the django CMS core menu class does not utilize the
admin_manager
and fails when run on versioned pages.This PR updates django CMS core's menus with three cornerstones in mind
admin_manager
and preview endpoints allowing to be extended by packages like djangocms-versioningTo use the core's menu system with djangocms-versioning you have to include to following setting in
settings.py
:In comparison, djangocms-versioning's menus are slower and do not respect the language fallbacks.
Related resources
Checklist
develop-4