AI for Postgres
Tune, debug, and design PostgreSQL with AI — slow queries and EXPLAIN plans, indexing, vacuum/bloat, replication, and safe schema migrations.
Prompts
- Intermediate
Postgres postgresql.conf Workload Tuning Prompt
Get a reviewed postgresql.conf tuning plan for your specific hardware and workload — memory, WAL/checkpoint, planner, and autovacuum settings explained one by one, with how to verify each took effect.
- Claude
- ChatGPT
- Cursor
Open prompt - Advanced
Postgres Declarative Partitioning Design Prompt
Design a declarative partitioning scheme for a large table — pick the strategy and key, plan indexes and constraints, and lay out a safe migration from the existing monolith with automated partition maintenance.
- Claude
- ChatGPT
- Cursor
Open prompt - Advanced
Postgres Index Advisor from pg_stat_statements Prompt
Mine pg_stat_statements for your most expensive queries and get a prioritized list of missing indexes to add and redundant indexes to drop — with the write cost of each spelled out.
- Claude
- ChatGPT
- Cursor
Open prompt - Advanced
Postgres Lock Contention & Deadlock Investigation Prompt
Untangle blocking chains and deadlocks from pg_locks, pg_stat_activity, and log output — pinpoint the blocker, explain the lock conflict, and fix the access pattern so it stops recurring.
- Claude
- ChatGPT
- Cursor
Open prompt - Intermediate
Postgres pgbouncer Pool Sizing & Connection Tuning Prompt
Size pgbouncer pools and pick a pooling mode for your app's connection behavior — so you stop exhausting max_connections, cut connection overhead, and avoid the subtle bugs transaction pooling introduces.
- Claude
- ChatGPT
- Cursor
Open prompt - Advanced
Postgres Replication Lag Debugging Prompt
Diagnose streaming or logical replication lag from pg_stat_replication and pg_replication_slots — find where the bytes are stuck (send, write, flush, replay) and fix the cause without losing WAL or risking the primary.
- Claude
- ChatGPT
- Cursor
Open prompt - Intermediate
Postgres Slow Query EXPLAIN Triage Prompt
Turn a confusing EXPLAIN (ANALYZE, BUFFERS) plan into a ranked, plain-English diagnosis with concrete index/rewrite fixes and a verification step — so you fix the real bottleneck, not a guess.
- Claude
- ChatGPT
- Cursor
Open prompt - Advanced
Postgres VACUUM, Bloat & Autovacuum Tuning Prompt
Diagnose table and index bloat, decide between VACUUM, autovacuum tuning, and a rebuild, and produce per-table autovacuum settings — so dead tuples and wraparound risk stop quietly degrading your database.
- Claude
- ChatGPT
- Cursor
Open prompt - Advanced
Postgres Zero-Downtime Schema Migration Planner Prompt
Turn a risky schema change into a lock-aware, multi-step migration plan that avoids long ACCESS EXCLUSIVE locks — with the exact statements, lock_timeout guards, and a back-out path for each phase.
- Claude
- ChatGPT
- Cursor
Open prompt
Guides
- · 11 min read
AI-Assisted Postgres Index Design and Killing Redundant Indexes
Use AI to propose composite and partial indexes, justify column order, and find redundant or unused indexes in Postgres — then verify every one on a replica.
Read guide - · 11 min read
Debugging Slow Postgres Queries With AI and EXPLAIN ANALYZE
Use AI to decode EXPLAIN (ANALYZE, BUFFERS) output and draft fixes for slow Postgres queries — then verify every change on a replica before it touches prod.
Read guide - · 11 min read
Diagnosing Postgres Lock Contention and Deadlocks With AI
Use AI to read pg_locks, untangle blocking chains, and decode deadlock logs in Postgres — then fix the access pattern, verified on a replica, not in prod.
Read guide - · 12 min read
Partitioning Large Postgres Tables With AI
Use AI to choose a partition key, design range or list partitions, and plan a lock-aware migration of a huge Postgres table — verified on a replica before prod.
Read guide - · 11 min read
Postgres Connection Pooling With PgBouncer and AI
Use AI to size PgBouncer pools, pick the right pool mode, and debug exhausted Postgres connections — verified with pgbouncer SHOW stats, not guesswork.
Read guide - · 12 min read
Setting Up and Debugging Postgres Replication With AI
Use AI to stand up streaming and logical replication, read replication lag and slot stats, and debug a stuck Postgres replica — verified on the catalog, not guesses.
Read guide - · 11 min read
Taming Postgres Bloat and Autovacuum With AI
Use AI to read autovacuum stats, size table and index bloat, and tune autovacuum thresholds for hot Postgres tables — verified against the catalog, not vibes.
Read guide - · 11 min read
Tuning postgresql.conf for Your Workload With AI
Use AI to reason about shared_buffers, work_mem, WAL and planner settings for your actual Postgres workload — then verify every change with measurements, not defaults.
Read guide - · 12 min read
Zero-Downtime, Lock-Aware Postgres Schema Migrations With AI
Use AI to review Postgres migrations for dangerous locks and draft safe multi-step rollouts — NOT NULL, new columns, type changes — verified on a replica first.
Read guide