---
name: "postgres-pgbouncer-connection-pooling"
description: "Manage thousands of concurrent client connections with low overhead using PgBouncer."
metadata:
  author: "PgBouncer"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "setup pgbouncer pool"
  - "configure transaction pooling"
  - "fix prepared statements pgbouncer"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# PgBouncer High-Throughput Connection Pooling

Sets up PgBouncer connection pooling: transaction pooling vs session pooling, user authentication via userlist.txt / auth_query, pool sizing mathematics, and handling prepared statements safely.

## When to Invoke
Invoke this skill whenever you need to:
- setup pgbouncer pool
- configure transaction pooling
- fix prepared statements pgbouncer

## Execution SOP & Rules
1. Set pool_mode = transaction in pgbouncer.ini to maximize connection reuse across short-lived workers.
2. Configure max_client_conn = 10000 and default_pool_size based on: ((core_count * 2) + effective_spindle_count).
3. Disable server-side prepared statements or use named prepared statement workarounds for transaction mode.
4. Monitor pool health via psql -p 6432 -U pgbouncer pgbouncer -c 'SHOW POOLS;' and 'SHOW STATS;'.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
