← back to stream

Postgres WAL

WAL (Write-Ahead Log) is the foundational mechanism that makes Postgres durable: every change is first written sequentially to the WAL on disk, then applied to the actual data pages in memory asynchronously. On crash, Postgres replays the WAL from the last checkpoint and recovers. The insight is subtle but important: sequential WAL writes are fast (disks love append-only), and the actual data-page rewrites can be batched and deferred, so you get durability without paying the cost of random writes on every commit. WAL is also the substrate for everything else that needs to know "what changed": streaming replication (ship WAL to standby servers), point-in-time recovery (archive WAL segments, replay to any moment), logical replication and CDC (parse WAL into change events for Kafka, Debezium, etc.). If someone asks how any reliability or replication feature in Postgres works, the answer almost always starts with "the WAL".