pgBouncer is a thread-based pooler (spawns a thread for each connection), designed and built for PostgreSQL. It receives a connection, puts it in the pool, then redirects the connection to a persistent process on the database. It understands the PostgreSQL protocol very well. pgBouncer can be implemented using the following three modes:
- Session Mode: When pool_mode is set as session, the connection given by pgBouncer to the client stays until the client disconnects. The client could either run one transaction or more transactions through one session at a time. This is the safest method when we are not sure whether the application uses prepared statements or some of the features that are not supported by the other pool modes.
- Transaction Mode: pgBouncer is said to perform the best when pool_mode is set as transaction. In this mode, a client connection is active until the transaction is active. Once the transaction is completed, the client is disconnected...