Opened 18 months ago
Closed 18 months ago
#34713 closed Cleanup/optimization (needsinfo)
Add an option to disable lastmod in Sitemaps.
Reported by: | Christoph Krybus | Owned by: | nobody |
---|---|---|---|
Component: | contrib.sitemaps | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In django 4.1+ <lastmod> was added to sitemap index (https://code.djangoproject.com/ticket/25916)
One consequence of this is that django loads now the whole queryset into memory in order to determine the lastmod value for each sitemap entry in the sitemap index. In django versions < 4.1 this was not the case, the paginator just needed to know the number of elements to generate links to the sitemaps.
My sitemap has ~1.5M entries, it worked OK in django 4.0, in django 4.1 the VM comes to a standstill.
There seem to be no way to disable this new feature without also disabling lastmod on single entries. As a workaround I'm overriding the whole view right now.
For the vast majority of sites the worse performance should not be a problem, but maybe there could be a setting or at least an overridable parameter to disable it?
The index view https://github.com/django/django/blob/4.2.3/django/contrib/sitemaps/views.py#L65 has already a variable called all_indexes_lastmod maybe it could be initialized by a new index view argument? Something like enable_index_lastmod=True
.
Change History (2)
comment:1 by , 18 months ago
Version: | 4.1 → dev |
---|
comment:2 by , 18 months ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
Summary: | Sitemap index performance regression → Add an option to disable lastmod in Sitemaps. |
Type: | Uncategorized → Cleanup/optimization |
Thanks for the report. Isn't it enough to overwrite
get_latest_lastmod()
in your view? Creating a new feature flags is always controversial when subclassing is enough (as we already have many of them).