Write-Ahead Log
ELI5 — The Vibe Check
The Write-Ahead Log (WAL) is the database's diary. Before changing any actual data, the database first writes what it's about to do in this log. If the power goes out mid-operation, the database reads its diary on restart and either finishes or rolls back the work. No data lost. It's like writing your grocery list before going shopping.
Real Talk
A Write-Ahead Log (WAL) is an append-only log where all modifications are recorded before being applied to the actual data pages. This ensures durability (the D in ACID) by allowing crash recovery through log replay. WAL also enables replication, point-in-time recovery, and logical decoding in PostgreSQL.
When You'll Hear This
"The WAL ensures no committed transaction is ever lost, even during a crash." / "Streaming replication works by shipping WAL segments to replicas."
Related Terms
LSM Tree
An LSM tree (Log-Structured Merge Tree) is a write-optimized data structure. It buffers writes in memory, then flushes them to disk in sorted chunks.
MVCC
MVCC (Multi-Version Concurrency Control) is how databases let multiple users read and write at the same time without stepping on each other's toes.
Point-in-Time Recovery
Point-in-time recovery (PITR) is the database equivalent of a time machine. Accidentally deleted all your users at 3:47 PM?
Read Replica
A read replica is a copy of your database that only handles read queries.