Skip to main content
InterviewHubPRO
Section Overview
Q45

Question 45 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

90%
PostgreSQL Enterprise (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

Connection Pooling with PgBouncer: Sizing and Modes.

senior LevelPostgreSQL

In Simple Words: PostgreSQL uses a process-based model (each client connection spawns a new OS backend process consuming ~10MB RAM). PgBouncer multiplexes thousands of client connections onto a tiny pool of backend PostgreSQL connections:

  1. Session Pooling: Connection held for the lifetime of client connection.
  2. Transaction Pooling (Most Common): Connection returned to pool as soon as COMMIT or ROLLBACK executes (enables 10,000 clients to share 50 DB connections!).
  3. Statement Pooling: Connection returned after every single SQL statement (does not support multi-statement transactions).