Curriculum · Module 07, Storage Engines
LSM trees and compaction
Turn random writes into sequential ones with a memtable and sorted files, then pay the bill in compaction. Leveled and tiered policies trade write, read and space cost.
What each topic covers
- A B-tree writes pages in random places. An LSM tree turns writes into appends and pays for it later.
- How a write becomes a sorted file, how a read finds a key, and how a merge removes old versions.
- Write forty thousand keys, switch the compaction policy, and read the three amplification numbers.
- Leveled compaction pays in writes, tiered compaction pays in reads and space, and overwrites decide how big the space bill gets.
- A point read, a miss and a range scan each touch files differently, and the number of files is what you pay for.
- Compaction is debt paid in the background. If ingest outruns the merge, files pile up and the store must slow the writer.
- Three quick checks on the LSM write path, the cost of a miss and the choice of policy, with the sources behind the lesson.
Topics
Practise this lesson
8 interview questions on lsm trees, with worked answers and sources.
Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms