-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Optimize sitemap #12064
base: main
Are you sure you want to change the base?
Optimize sitemap #12064
Conversation
This removes the need to do subsequent custom queries for a page
`Site.get_for_request` is already cached, but this ensures even no site is cached, and keeps the cache closer to the class.
This removes the need to load all pages as part of the sitemap index views.
This code is copied from how Django does it
Manage this branch in SquashTest this branch here: https://realorangeoneoptimize-sitemap-nule6.squash.io |
The cause of the slowdown seems to be related to the use of |
The issue is indeed from |
Fixes #1698
This PR encompasses a few small optimisations:
.specific(defer=True)
when getting pages. This means there's no need to fetch the specific page models at all, removing the extra queries which comes with it.lastmod
, rather than looping through all pages.The query drops in the tests is deceptive. These changes dropped them by 2 in the tests - the rest are from using a non-database cache.
With ~10000 pages (averaged over 10 requests using
gunicorn
andoha
):Before:
35 DB queries
After:
18 DB queries
I'm not sure why the updated version appears slower - although I think it's within the margin of error. It's running fewer queries, and
defer=True
should make the codepaths much simpler, too. The tests were run onbakerydemo
and I suspect with more than just a single model the improvements may be greater still.