Module 2 · Indexes
Episode 16 Compaction
▶ This video is coming to YouTube soon.
Why does RocksDB rewrite your data again and again? This episode animates the k-way merge, size-tiered and leveled compaction, and measures read, write and space amplification on one 6,000-write workload, then shows Postgres paying for old row versions with VACUUM and VACUUM FULL.
Chapters
- 0:00Intro
- 0:15Every flush adds a file
- 0:38Without compaction, files pile up
- 1:24Compaction is a merge of sorted files
- 2:23The code: merge sorted runs
- 2:54Size-tiered: merge files of similar size
- 4:02Leveled: one sorted run per level
- 5:29Read, write, space: pick two
- 6:08Measured: one workload, three strategies
- 6:44A tombstone drops only at the last level
- 7:34Proof: Postgres pays for old versions too
- 8:36Who uses what
- 9:01Recap
- 9:31Next: Bloom Filters