🗃️Write-Ahead Log (WAL)
Also known as WAL, Write-Ahead Logging, Redo Log, Transaction Log
A log the database writes each change to first. Then a crash loses nothing.
Think of it like
Think of it like a diary you write in first. If you get called away, it says what you meant to do.
Example
PostgreSQL writes every change to its WAL before its tables. After a power cut, it replays the WAL and loses no saved order.
Why it matters
It is how a database keeps saved changes safe through a crash. Copies of the log also feed backups and replicas.
Definition
Common mistake
Key takeaways
- 1Log first. Write the change to the log first.
- 2Then the data. Main files are updated later.
- 3Replay on crash. The log finishes unfinished work.