HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMajor

What is the purpose of session pool_mode in pgbouncer?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
pgbouncerthepool_modewhatsessionpurpose

Problem

Since in this mode pgbouncer creates outbound connection for each inbound connection it seems to me that pgbouncer doesn't work as pooler.
It's just 1 to 1 mapping.

Where am I wrong?

Solution

There would be 1 connection to the server for each connection to pgbouncer, but not necessarily a new connection. When a connection to pgbouncer is closed it doesn't close the connection to the server, just makes that connection available to the pool. Then when a new connection comes in, that pooled connection can be reused.

If the connections to pgbouncer are generally long-lived ones, this might not be of much benefit. But, if there are a lot of short connections, it could result in a major improvement.

There was an excellect blog post published recently about pgbouncer, and the different modes of operation.

Context

StackExchange Database Administrators Q#29856, answer score: 22

Revisions (0)

No revisions yet.