Data and Storage
Every database is a file, plus the rules that keep it honest when two things touch it at once and when the power goes out. These chapters build those rules from nothing: append-only records, a lock, an index, and a log written before the change it describes.
- An append-only file cannot delete. Removal is a record you add, which is why every log-structured store has tombstones.
- Read, modify, write is three steps, and the gap between the first and the third is where the other writer gets in.
- A race gives a different answer every run. That is what makes it expensive to find, not what makes it rare.
- An index does not make the data smaller. It adds a second structure you now have to keep in step with the first.
5 chapters.
- An Append-Only Record StoreNever modify what is written. Deleting is something you add.
- Two Writers, One FileWhat a lost update looks like, and the lock that prevents it.
- An Index Over the LogA second structure, derived from the first, that you now have to keep in step.
- A Write-Ahead LogWrite down what you are about to do, then do it. Recovery is replaying the note.
- A Query EngineParsing asks what. Planning asks how, and that is where a database earns its keep.