Docs

Pooling and timeouts

Choose how PgBouncer shares database connections (transaction, session or statement mode), size the pool, and set how long one SQL statement may run before it is cancelled.

Updated Oct 17, 2026Open in console

Postgres can only keep a few hundred connections open; a serverless app can open thousands. The pooler (PgBouncer) sits in front of the database and shares a small set of real connections among many clients. Both settings on this page are applied by the database, so they hold for every client — the API, the SQL editor, functions and your own servers.

Pool mode, pool size and statement timeout settingsPool mode, pool size and statement timeout settings
Pooling & timeouts
one transactionone transactionClient AClient BClient C… 1,000 morePgBouncertransaction modeServer connection 1Server connection 2Postgres

Pool mode

ModeBehaviourChoose it when
TransactionA server connection is lent for one transaction, then returned.Almost always: serverless, functions, web apps. Session features (LISTEN, session SET, prepared statements kept across transactions) don’t work.
SessionA client keeps its server connection until it disconnects.You need session features through the pooler. You run out of connections sooner.
StatementConnections return after every statement; multi-statement transactions are refused.Rarely — very simple, high-volume reads.

Saving restarts PgBouncer; open pooled connections reconnect. On Free the pooler is shared and these settings are fixed.

Pool size

How many real server connections each database/user pair may use, up to the maximum your compute size allows (shown next to the field). More connections let more queries run at once but use more memory. Leave the default unless clients wait for a connection (no more connections allowed or slow first queries).

Statement timeout

A query running longer than this is cancelled with canceling statement due to statement timeout. It applies to new connections; empty uses the server default. Keep it short for user-facing traffic — a slow query is usually a missing index — and give long jobs their own longer timeout, up to your plan’s maximum.

begin;
set local statement_timeout = '45s';   -- only for this transaction, up to the plan maximum
refresh materialized view sales_by_day;
commit;
FreeProUltraTeamEnterprise
Default SQL statement timeout (ms)3 s8 s15 s30 s60 s
Longest SQL statement timeout a client may request (ms)8 s30 s60 s120 s300 s
Rows one SQL query may return1,0005,00010,00025,00050,000
Dedicated connection poolerSharedSharedSharedDedicated nodeDedicated cluster
Concurrent database connections202005002,00010,000

Common mistakes

  • Using session mode for a serverless app: every cold start holds a connection until it times out.
  • Prepared statements through transaction mode — turn them off in your driver (prepare: false in postgres.js, statement_cache_size=0 in asyncpg).
  • Raising the timeout to hide a slow query instead of adding an index.
Something unclear or missing on this page?Tell us