Skip to content

Slow modeladmin views because of PagePermissionHelper.get_valid_parent_pages #19

@haplo

Description

@haplo

Issue Summary

I have been profiling the Wagtail admin views because my users experience some very slow load times (10-30 seconds). I implemented some big optimizations already (see wagtail/wagtail#5311 and wagtail/wagtail#5314), and when I profiled the index view I found out that a lot of the time goes into PagePermissionHelper.get_valid_parent_pages because it builds a massive query with hundreds or thousands of OR operators.

See the profiling for WMAView.dispatch:
profiler_get_valid_parent_pages

I propose a solution in the next message.

Steps to Reproduce

  1. Create a group with add, edit, publish permissions over hundreds of pages of the same content type.
  2. Add an user to the group.
  3. Log in as the user and go to that content type index page.
  4. Page load time should be higher than ideal.

I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: no, I profiled over a local Wagtail 2.4 with a snapshot of production data.

Technical details

  • Python version: 3.7
  • Django version: 2.0.3
  • Wagtail version: 2.4
  • Browser version: Firefox 60.6.1esr (64-bit) on Fedora 29 (not relevant to this issue)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions