Database Systems
Committing your transactions…
Initializing Sorting Algorithms...
Sorting
Trees
Graphs
Preparing interactive visualizations...
Database Systems
Committing your transactions…
Never update a file in place: buffer writes in memory, flush them as sorted immutable files, and merge those files in the background. Reads pay for it by checking several places — and Bloom filters cut that cost.
Click Play to begin.
| LSM tree | B-tree | |
|---|---|---|
| Write | memtable + sequential flush | random in-place page write |
| Read | memtable, then each level | one root-to-leaf path |
| Delete | tombstone, removed later | remove from the leaf |
| Extra work | background compaction | page splits |
| Best for | write-heavy ingest | read-heavy, range scans |
Real engines keep many levels, each about ten times larger than the one above, and split each level into many small SSTables so compaction can work on a slice at a time.
Question 1 of 3
Why are writes cheap in an LSM tree?