What is connection pooling in databases?

Answer

Connection pooling maintains a pool of pre-established database connections that are reused rather than opened and closed for each request. Opening a new database connection is expensive (TCP handshake, authentication, session setup — 20–200ms). A connection pool reduces this overhead dramatically. A pooler (PgBouncer for PostgreSQL, HikariCP for Java) manages the pool: when a request needs a connection, it borrows one from the pool; when done, it returns it. Key parameters: min_connections, max_connections, connection_timeout. Sizing the pool: too small causes queueing; too many exhausts the RDBMS's connection limit and increases memory pressure.