Section 1 of 3 · 6 minutes
Measure how quickly WAL is growing
Your goal
What you will be able to do
Measure WAL generation over a known time window and connect it to workload changes.
Why this matters at work
The practical reason
A WAL total without a rate cannot show whether current growth is normal or accelerating.
Learn
The idea in plain English
PostgreSQL generates WAL for changes that must be recoverable. Large updates, bulk loads, index creation, and full-page images can increase the rate.
Capture two WAL positions with timestamps and calculate the byte difference. Compare the interval with deploys, maintenance, and transaction rates before changing configuration.
Remember these points
- Measure a WAL rate, not only one position.
- Connect rate changes to a workload event.
- Retained WAL may also come from replication slots or archiving failures.
See it in SQL
Record a WAL measurement point
Capture a timestamp and WAL position for a later rate calculation.
SELECT
clock_timestamp() AS measured_at,
pg_current_wal_lsn() AS wal_position,
wal_records,
wal_bytes,
stats_reset
FROM pg_stat_wal;Take a second sample after a known interval. Subtract WAL bytes or use `pg_wal_lsn_diff` between positions.
Include `stats_reset` so a reset is not mistaken for a sudden drop in work.
A timestamped WAL position and cumulative WAL counters with their reset time.
Useful words
Important terms
- WAL generation rate
- The amount of new write-ahead log produced per unit of time.
Quick check · Not graded
Check your understanding
What is needed to calculate a WAL generation rate?
Your progress is saved to your signed-in account.