From fad334e1a9b54ea1acb8cce02a25934c5acfe99f Mon Sep 17 00:00:00 2001 From: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> Date: Mon, 11 Dec 2023 11:37:54 +0100 Subject: Refs #33497 -- Added connection pool support for PostgreSQL. Co-authored-by: Florian Apolloner Co-authored-by: Ran Benita --- docs/ref/databases.txt | 25 +++++++++++++++++++++++++ docs/releases/5.1.txt | 3 +++ 2 files changed, 28 insertions(+) (limited to 'docs') diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt index 1bc787671e..acebfdf348 100644 --- a/docs/ref/databases.txt +++ b/docs/ref/databases.txt @@ -245,6 +245,31 @@ database configuration in :setting:`DATABASES`:: }, } +.. _postgresql-pool: + +Connection pool +--------------- + +.. versionadded:: 5.1 + +To use a connection pool with `psycopg`_, you can either set ``"pool"`` in the +:setting:`OPTIONS` part of your database configuration in :setting:`DATABASES` +to be a dict to be passed to :class:`~psycopg:psycopg_pool.ConnectionPool`, or +to ``True`` to use the ``ConnectionPool`` defaults:: + + DATABASES = { + "default": { + "ENGINE": "django.db.backends.postgresql", + # ... + "OPTIONS": { + "pool": True, + }, + }, + } + +This option requires ``psycopg[pool]`` or :pypi:`psycopg-pool` to be installed +and is ignored with ``psycopg2``. + .. _database-server-side-parameters-binding: Server-side parameters binding diff --git a/docs/releases/5.1.txt b/docs/releases/5.1.txt index b2377608f0..7fc794cd1d 100644 --- a/docs/releases/5.1.txt +++ b/docs/releases/5.1.txt @@ -162,6 +162,9 @@ Database backends to allow specifying :ref:`pragma options ` to set upon connection. +* ``"pool"`` option is now supported in :setting:`OPTIONS` on PostgreSQL to + allow using :ref:`connection pools `. + Decorators ~~~~~~~~~~ -- cgit v1.3