/ai-stuff:postgres-connection-poolingfrom ai-stuff
Size and configure PostgreSQL connections and connection pooling: max_connections, idle-connection and per-connection costs, PgBouncer pool modes and what transaction mode breaks (SET, advisory locks, temp tables, LISTEN/NOTIFY, prepared statements), PgBouncer sizing, auth, monitoring and multi-process setups, alternatives (PgCat, PgDog, Supavisor, RDS Proxy), timeouts, dead connections, and retry storms. Use when an app hits "too many clients", connection latency, pool exhaustion, or when adding or configuring a pooler.
Ships in ai-stuff. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
A playbook distilled from Scaling Postgres. Evidence, benchmarks and version history are in reference.md.
max_connections low. About 10x vCPUs at most; thousands is a
smell. Waiting in a pooler queue beats overloading the backend.lock_timeout), LISTEN workers, and admin work.| Feature | Problem | Fix |
|---|---|---|
SET, SET search_path | Leaks to other clients' transactions | SET LOCAL inside the transaction, or role/database-level settings |
| Session advisory locks | Lock outlives your transaction on a shared backend | pg_advisory_xact_lock |
| Temp tables | Bound to a backend | ON COMMIT DROP within one transaction, or unlogged tables |
LISTEN | Needs a persistent session | Dedicated direct connection |
| Prepared statements | Named statements land on the wrong backend | PgBouncer ≥ 1.21 with max_prepared_statements (protocol-level only, not SQL PREPARE) |
| RLS via session variables | Session state | SET LOCAL, or session mode for that path |
pool_mode = transaction
max_client_conn = 5000
default_pool_size = 20 ; per user/db pair; total must fit max_connections minus admin headroom
max_db_connections = 50
max_prepared_statements = 100 ; 1.21+
query_wait_timeout = 30
server_lifetime = 3600 ; recycle backends whose caches grew
so_reuseport, and use peers so cancel requests find the
right process.SHOW POOLS. A rising cl_waiting explains latency that
pg_stat_statements never sees.PAUSE/RESUME for planned cutovers.auth_query with a SECURITY DEFINER lookup function over
userlist.txt sprawl, and SCRAM.idle_in_transaction_session_timeout, plus a per-role
statement_timeout.client_connection_check_interval stops queries whose client has gone.idle_session_timeout can kill healthy pooled connections. Use it only to
reap backends behind a pooler, or not at all.target_session_attrs) so clients
find the new primary after failover.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
25 skills in this plugin
/brainstormingYou MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation./codebase-designShared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary./dispatching-parallel-agentsUse ONLY when the developer has explicitly told you to dispatch subagents — never infer or self-authorize it. Splits 2+ independent tasks across isolated subagents, assigns them cheap models, and polls at a per-harness cadence that preserves prompt cache (Claude Code vs Codex/opencode).npx claudepluginhub pauldotsh/ai-stuff --plugin ai-stuff