I’m currently working on some high-load projects and wanted to bring up a topic that feels increasingly important — native support for database connection pooling in Django.
I realize this probably belongs in the Internals category, but I don’t yet have posting permissions there. I’m sharing it here to get feedback and start a discussion — happy to repost it in Internals when possible!
Why this matters
In Django, CONN_MAX_AGE helps with persistent connections, but it doesn’t provide true connection pooling like you’d get with SQLAlchemy in FastAPI or similar frameworks.
In contrast, SQLAlchemy gives you:
Configurable pool sizes
Queueing and timeout behavior
Recycle/reconnect logic
Pool health insights
This makes a huge performance difference for apps with high concurrency, short-lived processes (e.g. in serverless), or async workflows.
First of all please make my apology for such late respond.
Thank you for taking time to write here , I really appreciate it.
you’re absolutely right.
I looked into the Django 5.1 release notes and saw that PostgreSQL now supports pooling via pooling_class, which is great to see. I also checked out those tickets you mentioned (#7732 and #35702), and it’s clear there has been backend-specific consideration in the past.
my concern isn’t about absence of pooling, but more about:
Inconsistency in support across different DB backends (Postgres vs MySQL vs Oracle)
Lack of a unified abstraction or interface to configure and manage pools
Scattered documentation, making it hard for devs to know what’s supported and how to use it properly
So maybe a more valuable contribution could be:
Consolidating DB pooling capabilities into a single place in the docs
Proposing a backend-agnostic POOL_OPTIONS interface (like CACHES)
Adding dev tools/metrics for pool debugging
but I appreciate your direction and make sense. I will dig more and find out what’s already done and what the remaining gap are. if there any room, I will contribute towards improving clarity.
Thank you so much
This sounds a reasonable approach, and you may find that the consolidating the docs might be a sufficient solution.
If you do decide to proceed with other features, then proposing them in the new features repo would be the place to do so, but you could probably also bundle any solution into a third-party package.
I did a review of Django’s documentation and repo:
and as you mentioned eariler in thread.
Django 5.1 officially introduced PostgreSQL connection pooling via OPTIONS: { pool: ... }, using psycopg[pool].
For Oracle, ticket #7732 added a SessionPool, and it’s documented under the Oracle backend notes.
MySQL / MariaDB / SQLite currently have no native pooling support only CONN_MAX_AGE for persistent connections.
Also, while going through various threads and Django’s async roadmap, it seems that connection management including pooling is one of the practical blockers for making the Django ORM fully async.
Better and more consistent connection handling across backends could potentially play a role in unlocking more robust async support down the line.
Would you recommend I put together a draft PR for the docs at this point?
Thanks again for feedback and guidance.
Actually that makes a lot of sense . I’ll go through the Diátaxis model (it’s new to me) and see where this could best fit in the docs. may be I will be having some questions after going through it.
I agree creating a new-feature issue first would be the right way to frame this.