Right-size synchronous_commit for latency
A real PG16 top-level DO lab committed 300 single-row transactions in each mode. synchronous_commit=off was much faster on local storage, but recently acknowledged transactions can be lost after a crash.
Problem
What you're actually looking at
The symptom as it shows up on a real server.
Every COMMIT with synchronous_commit on waits for WAL to reach durable storage. For a transaction that did real work the wait is amortized into nothing. For a stream of tiny transactions it is most of the cost, and the shape of the fix, batch the work, or relax durability for that specific job, depends on knowing how big the gap actually is on your hardware.
An acknowledgement feed performs 300 real commits with synchronous_commit on and 300 with it off, using top-level transaction control in psql.
Simple terms
With synchronous_commit on, every COMMIT waits for the WAL to be physically flushed to durable storage before it returns. For a transaction that did real work, that wait disappears into the noise. For a flood of tiny one-row transactions, that flush is almost the entire cost. Turning it off makes those commits dramatically faster, but the trade is real: after a crash you can lose the most recently committed transactions, so it is a per-job decision, not a global switch.
Full runbook for this incident
- The full identify checklist, the exact signals that tell you it's this incident
- Every diagnostic query; lab output is attached only to the steps we actually captured
- The resolution path and the pitfalls that make it worse
- Mitigation steps to stop it recurring, plus a verify-you're-done query
Card required. Cancel before day 7 and you are not charged.
More in this category
Other WAL & replication runbooks
Neighbouring incidents that share the same diagnostic surface.
Connected
How this connects to the rest of the library
A live view of this page's real cross-references, what explains it, what fixes it, what to tune, and where to go next. Every link is an authored relationship, not a guess.
Fixes these errors
Need the full procedure?
Pro runbooks finish the incident path
Free runbooks teach the shape. Pro opens the full step transcript, edge cases, and prevention depth.