home / databases / pgbouncer

PgBouncer

4k

PostgreSQL connection pooler with admin-console commands for inspecting pools, clients, servers, and connection state.

$brew install pgbouncer
Language
C
Stars
3,963
Category
Databases
Agent
AI Analysis

PgBouncer is a lightweight PostgreSQL connection pooler that sits between applications and PostgreSQL to reuse backend connections and cap connection churn. Its operational surface is the pgbouncer daemon plus a special admin database that exposes SHOW and control commands.

What It Enables
  • Run session, transaction, or statement pooling in front of PostgreSQL to reduce connection overhead and limit backend fan-out.
  • Inspect live pools, clients, servers, DNS cache, socket state, and traffic counters through admin SHOW commands when diagnosing saturation or routing issues.
  • Pause, resume, reconnect, reload, kill, and controlled-shutdown PgBouncer during database restarts, failovers, and config rollouts.
Agent Fit
  • Agents can drive it non-interactively by starting pgbouncer with flags and sending admin SQL commands through psql or another PostgreSQL client.
  • No native JSON output was found, so inspection workflows depend on parsing SQL result sets or client-formatted text.
  • Best fit for Postgres operations loops where an agent needs to inspect pool state, apply a control action, and verify the result.
Caveats
  • Most day-two operations are not top-level CLI subcommands; they require connecting to the pgbouncer admin database with an allowed user.
  • The admin console only supports the simple query protocol, so some drivers will not work unless they can send simple SQL.