What is the core principle of write-ahead logging (WAL)?
Write-ahead logging: before modifying the actual data pages, the database appends the intended change to a sequential log on disk. This guarantees that committed changes survive a crash because they can be replayed.
2 / 5
How does WAL improve write performance?
Sequential append: the WAL is written sequentially, which spinning disks and SSDs handle efficiently. The slower random updates to data pages can then be batched and flushed lazily, boosting throughput.
3 / 5
What is crash recovery using the WAL?
Crash recovery: on restart, the database reads the WAL and redoes committed transactions not yet flushed to data files, and undoes incomplete ones, restoring a consistent state without losing committed work.
4 / 5
What is a checkpoint in a WAL-based system?
Checkpoint: periodically the system flushes in-memory dirty pages to data files and records a checkpoint. WAL segments older than the checkpoint are no longer needed for recovery and can be reused or archived.
5 / 5
How does WAL enable features like replication?
WAL for replication: because the log captures every change in order, shipping it to standby servers lets them replay the same operations and mirror the primary, the basis of PostgreSQL streaming replication.