Opened 2 hours ago
#36964 new Cleanup/optimization
Documentation incorrectly states that persistent connections don't work with runserver
| Reported by: | Adam Sołtysik | Owned by: | |
|---|---|---|---|
| Component: | Documentation | Version: | 5.2 |
| 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
From https://docs.djangoproject.com/en/5.2/ref/databases/#caveats:
The development server creates a new thread for each request it handles, negating the effect of persistent connections. Don’t enable them during development.
Something here seems to be incorrect. I'm using 'CONN_MAX_AGE': None with the development server, and it works as expected. My requests are significantly faster than with the default setting. When analyzing with SELECT * FROM pg_stat_activity WHERE datname = '<dbname>', I can see a single connection created and persisting after the first request, and it disappears after autoreload.