The Wire · Showcase
Django site's N+1 query slashed from 45 to 1
By RepoJournal · Filed · About Django
A single pull request just cut the Django project's dashboard page from 45 SQL queries down to one, and it's headed to your browser.
The djangoproject.com dashboard had an N+1 problem: a loop over metrics fired 18 near-identical queries per page load, ballooning to 45 total SQL statements, and the fix collapses that into a single statement unioning each metric's latest datum [1]. The PR author flagged it as WIP, but it landed anyway as #1813 with co-author Baptiste Mispelon, so the optimization is live [2]. Meanwhile, Sarah Boyce added a GitHub Action to test djangoproject.com against Django main, catching incompatibilities before they ship [3][4]. On the core Django side, Jacob Walls cleaned up the 6.1 release notes, removing versionadded and versionchanged directives that were only meant for backports in recent security releases [5][6]. He also readded optional requirements onto daily builds for Python 3.15, mirroring the 3.14 setup [7]. With only 10 commits and 7 PRs across three repos today, this is a housekeeping-heavy wire, but the dashboard query fix is the release-ready win. The README typo fixes and the ruff isort switch are low-risk polish; skip them if time is tight [8][9]. Start with the dashboard query fix, since it directly impacts page latency for every visitor.
One email a day. Unsubscribe in one click.
Keep up with Django in about 3 minutes a day: what actually shipped — the commits, pull requests, releases, and security advisories that matter.
One email a day. Unsubscribe in one click. Read a past issue →
Action items
- → Deploy djangoproject.com PR #1813 to production to eliminate the N+1 queries django/djangoproject.com [immediate]
- → Monitor the new GitHub Action testing against Django main for breakage django/djangoproject.com [plan]
- → Review the version directive cleanup in Django main before next release django/django [monitor]
References
- [1] fix #1806: N+1 query issue on dashboard index page ↗ django/djangoproject.com
- [2] Fixed #1806: N+1 query issue on dashboard index page. (#1813) django/djangoproject.com
- [3] Added GitHub action to test against Django main. ↗ django/djangoproject.com
- [4] Added GitHub action to test against Django main. (#2713) django/djangoproject.com
- [5] Removed more versionadded/versionchanged directives for 6.1. django/django
- [6] Removed more versionadded/versionchanged directives for 6.1. ↗ django/django
- [7] Refs #36664 -- Readded optional requirements on daily builds for Python 3.15. ↗ django/django
- [8] Fix typos and omissions in README django/django-asv
- [9] Switch to ruff's isort ↗ django/djangoproject.com