django-cms / djangocms-versioning

General purpose versioning package for Django CMS 4 and above.
Other
34 stars 30 forks source link

feat: Prefetch page content version objects for faster page tree #418

Closed fsbraun closed 2 months ago

fsbraun commented 4 months ago

Description

To improve responsiveness of the page tree for large sites (in terms of pages), this PR adds a prefetch_related to the admin query sets and evaluates prefetched version objects where available.

This, for example, removes the N+1 issue when getting the state indicators. With a prefetched page content query set evaluating the state indicator does not require a db query.

Note: Currently, the django CMS core does not respect the admin get_queryset method which would contain the prefetch_related rule. This is fixed by https://github.com/django-cms/django-cms/pull/7956

Merging of https://github.com/django-cms/django-cms/pull/7956 is required to have a test for this PR.

Related resources

Checklist