Northbound Systems

Engineering notes on backend systems, databases, and small infrastructure.

Tuning Postgres for Write-Heavy Workloads

November 18, 2026 · Databases

Most write-heavy Postgres pain comes from three places: checkpoint storms, index bloat on hot tables, and autovacuum falling behind. They present identically — rising p99 latency, a graph that gets worse every week — so the first job is telling them apart before touching a single setting.

Checkpoints first

If latency spikes arrive on a suspiciously regular cadence, look at checkpoints. Turn on log_checkpoints for a day and read what it tells you. Checkpoints triggered by checkpoint_timeout are healthy; checkpoints triggered because WAL volume hit max_wal_size are the server telling you it is drowning. Our defaults on write-heavy rigs:

checkpoint_timeout = 15min
max_wal_size = 4GB
checkpoint_completion_target = 0.9

Spreading the checkpoint's writes over most of the interval cut p99 write latency by roughly a third on our test rig. The trade is recovery time after a crash, and on small infrastructure that trade is almost always worth making knowingly rather than by default.

Then the indexes

Every index on a hot table is a tax on every insert. We audit with pg_stat_user_indexes and look for indexes with high write counts and near-zero scans. Dropping one unused index on a table doing 3,000 inserts a second recovered more throughput than a month of parameter tuning. Bloat follows the same logic: a table whose indexes are twice the size of its heap is paying storage I/O for history it no longer needs. pg_repack during a quiet window beats a VACUUM FULL lock every time.

Then autovacuum

The default autovacuum scale factor (20% of the table) is calibrated for tables that fit in memory and forgive everything. On a 200-million-row table, 20% means 40 million dead tuples accumulate before anyone cleans up. Per-table settings fix this:

ALTER TABLE events SET (
  autovacuum_vacuum_scale_factor = 0.02,
  autovacuum_analyze_scale_factor = 0.01
);

Raise autovacuum_max_workers only after the per-table thresholds are sane; more workers sweeping up after a bad threshold just moves the I/O contention around.

The order matters

Checkpoints, indexes, vacuum — in that order, because each one can masquerade as the next. Fix the wrong one first and you will tune a healthy subsystem while the real bottleneck keeps compounding quietly.

← All articles