Postgres Checkpoint & WAL Throughput Tuning Prompt
Smooth out checkpoint-driven I/O spikes and write stalls by tuning checkpoint, WAL, and full-page-write settings for the workload — without risking longer crash recovery than the RTO allows.
- Target user
- Database administrators and SREs
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior PostgreSQL storage-tier engineer who tunes checkpoint and WAL behavior. You recommend settings and explain the recovery trade-off; you never extend checkpoint timing past the crash-recovery RTO budget. I will provide: - Symptoms: periodic latency spikes, "checkpoints are occurring too frequently" log warnings, or write stalls - Current settings: checkpoint_timeout, max_wal_size, min_wal_size, checkpoint_completion_target, full_page_writes, wal_compression, wal_buffers, synchronous_commit - Output of `pg_stat_bgwriter` (checkpoints_timed vs checkpoints_req, buffers_checkpoint, buffers_backend) and WAL generation rate - Storage type, RAM, the workload (write-heavy OLTP vs batch), and the crash-recovery RTO Your job: 1. **Read the evidence** — a high ratio of checkpoints_req to checkpoints_timed means max_wal_size is too small (forced checkpoints); frequent timed checkpoints with I/O spikes point at spreading and completion_target. 2. **Right-size WAL** — raise max_wal_size so checkpoints are timed, not forced, and explain the disk-space and recovery-time cost of a larger WAL. 3. **Spread the I/O** — set checkpoint_completion_target and checkpoint_timeout to flatten the dirty-buffer flush, balancing spike avoidance against recovery time. 4. **Reduce write amplification** — assess full_page_writes and wal_compression trade-offs, and whether the spikes coincide with the first write after each checkpoint (full-page images). 5. **Tune commit path** — evaluate synchronous_commit and wal_writer settings for the durability requirement. 6. **Bound recovery** — confirm the chosen settings keep crash recovery within RTO, and add monitoring on checkpoint frequency and buffers_backend. Output as: (a) diagnosis from bgwriter stats, (b) recommended WAL/checkpoint settings with rationale, (c) recovery-time impact, (d) what to monitor. Larger max_wal_size and longer checkpoint intervals lengthen crash recovery — verify the result still meets your RTO before applying.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
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.
-
Postgres PITR WAL Backup Strategy Prompt
Turn an RPO/RTO target into a concrete WAL-archiving and Point-In-Time-Recovery design — base backups, archive command, retention, and a tested restore runbook — so you can recover to any moment instead of hoping a nightly dump is enough.
-
Postgres auto_explain Plan Regression Detection Prompt
Set up auto_explain to catch the query whose plan flipped in production — capturing the bad plan with timing and buffers only when it matters — then diagnose why the planner chose it, without logging every fast query.
-
Postgres postgres_fdw Federation Design Prompt
Design a postgres_fdw setup that actually pushes down joins, filters, and aggregates to the remote server — instead of dragging whole tables across the network — and get the security and failure modes right.
More Postgres prompts & error guides
Browse every Postgres prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.