Planet PostgreSQL·· 9d ago
Umair Shahid: Where 39% of the WAL Came From
Umair Shahid: Where 39% of the WAL Came From
Brief · Based on the source excerpt
Umair Shahid breaks down a Supabase customer case writing 1. 8 TB of WAL per day, where about 39% was full-page-image overhead caused by the five-minute checkpoint_timeout default.
Why It Matters
For workloads that frequently modify hot tables and indexes, check whether repeated checkpoints are inflating WAL through full-page images rather than disabling the full-page writes that protect against torn pages.
Technical Breakdown · Distilled from the original source
What triggers a checkpoint
- PostgreSQL writes changes to the write-ahead log (WAL) before writing them to data files. A checkpoint flushes dirty pages from memory to disk, so crash recovery only needs to replay WAL written after the checkpoint.
- A checkpoint is triggered by whichever limit is reached first:
checkpoint_timeoutormax_wal_size. On a busy system with a reasonably sizedmax_wal_size, the timer usually wins. The default timeout is five minutes.
Why hot pages generate repeated full-page images
- With
full_page_writesenabled by default, the first modification of a page after a checkpoint logs the entire 8 kB page, not just the change. That protects against torn pages if a crash interrupts a page write. - Each checkpoint resets which pages count as modified for the first time. A single-row
UPDATEthat changes only a few bytes can therefore generate a full-page image if it is the first modification of that page since the checkpoint. Frequently modified table and index pages can generate these images in successive checkpoint cycles.
Where the extra WAL adds cost
- More WAL increases disk I/O, takes up more archive and backup storage, sends more data to replicas, and slows recovery. The article recommends leaving
full_page_writesenabled rather than reducing WAL by turning off torn-page protection.
Source: Planet PostgreSQL· postgr.es
PG Radar summarizes verified changes and impact. Read the original post for full technical details and code samples.