I have a site with around 4000 pages which is using fine grained permissions on around 400 of those pages. For some users accessing the /admin/ page the page loads in a second or so. For others the page can take around 5 minutes to load.
Profiling and debugging into the code seems to show that the area of concern is the wagtail\core\models.py
explorable_pages()
function, in particular the
page_permissions = Page.objects.filter(group_permissions__in=self.permissions)
line. This seems to return, for my data at least, over 2000 results with each reults repeated 6 or 7 times (returning a result for each permission type?). There are only around 400 distinct results.
Adding a distinct()
improves matters
page_permissions = Page.objects.filter(group_permissions__in=self.permissions).distinct()
getting the number down to around 400. My page loads are now around 90 seconds - not ideal but better.
Is the above a real issue with wagtail or am I missing/not understanding something?
Is there something I can do to speed up the page loading? Are the site permissions being set in a way that would be expected for a typical wagtail site?
(Excuse my ignorance and I am probably using the wrong terminology - I am Java programmer new to Python/Django/Wagtail)