PolarDB supports a transaction-level connection pool to reduce database load from a large number of connections.
Prerequisites
The transaction-level connection pool requires PolarProxy version 2.3.46 or later.
Background information
In and PolarDB for PostgreSQL, each database connection requires a dedicated backend process. This model can cause high database pressure and severe performance degradation when clients maintain many long-lived connections or frequently create new ones.
To improve performance in these scenarios, and PolarDB for PostgreSQL provide a transaction-level connection pool. This feature allows multiple client connections to share a single backend connection, reducing the number of new and maintained backend connections and improving throughput.
How it works

The transaction-level connection pool is designed to reduce the number of direct connections to the database and minimize the overhead from frequently creating short-lived connections.
When the transaction-level connection pool is enabled, a client request first establishes a connection with PolarProxy. Instead of immediately creating a new backend connection, PolarProxy searches the transaction-level connection pool for an available one. A connection is considered available if its user, dbname, and system variable settings match the request. If a matching connection is found, it is reused. If not, PolarProxy creates a new connection to the database. After the transaction ends, PolarProxy returns the connection to the pool for the next request. This process reduces the total number of connections between PolarProxy and the database.
With the transaction-level connection pool enabled, you can have thousands of connections between clients and PolarProxy, while PolarProxy maintains only dozens or hundreds of connections to the backend database.
PolarProxy itself does not have a maximum connection limit. The specifications of the compute nodes in the backend database determine the connection limit. When the transaction-level connection pool is disabled, each client connection creates a corresponding connection on the primary node and on each read-only node.
Instructions
Enable the transaction-level connection pool
-
Log on to the PolarDB console.
-
In the upper-left corner of the console, select the region of your cluster.
-
Find the target cluster and click the cluster ID.
-
In the URL section, click Configuration.
-
To the right of Connection Pool, click Transaction-level.
-
Click OK.
Disable the transaction-level connection pool
-
Log on to the PolarDB console.
-
In the upper-left corner of the console, select the region of your cluster.
-
Find the target cluster and click the cluster ID.
-
In the URL section, click Configuration.
-
To the right of Connection Pool, click Disable.
-
Click OK.
Limitations
-
When the transaction-level connection pool is enabled, sending a
CANCELrequest may cause the session to hang (Hang). We recommend that you disable the transaction-level connection pool when you use theCANCELfeature. -
The following actions cause connection pinning, where a connection is locked to a client session and is not returned to the pool until the session ends:
-
Executing a
PREPAREstatement -
Processing large packets (for example, larger than 16 MB)
-
Using
copy mode -
Using
flush mode -
Using a
temporary table,sequence, orview -
Running within a transaction
-
Declaring a
cursor
-
-
The following PostgreSQL features are not fully compatible with the transaction-level connection pool and may cause unexpected behavior. We recommend disabling the transaction-level connection pool when you use these features to ensure correct semantics:
-
sequence -
advisory lock -
LISTEN/NOTIFY -
holdable cursor
-
-
Because connections may be reused, the
pidreturned byselect pg_backend_pid()may change. -
Because connections are reused, the IP address and port displayed in
pg_stat_activityor SQL Explorer may not match the client's actual IP address and port.
Choosing a connection pool
Use the following recommendations to decide whether to enable the connection pool:
-
If your workload primarily uses a small number of long-lived connections, or if your application already has a well-configured connection pool, you may not need the PolarDB connection pool feature.
-
If your workload requires a large number of connections (for example, tens of thousands), or if you use a Serverless service where the number of connections increases linearly as your service scales out, you can enable the transaction-level connection pool. Ensure your workload is unaffected by the limitations described in the Limitations section.