LSM trees can do partial updates: how RocksDB's merge operator avoids read-modify-write
arpit_bhayani · x · 2026-12-06
The author debunks a common misconception: LSM trees don't only support full-value replacement via Put — modern implementations like RocksDB offer a merge operator that accepts deltas (e.g. +1 for a counter), avoiding read-modify-write cycles that defeat the LSM write-optimized design.
How it works
- Merge is still a blind append on the write path — no reads happen.
- The key accumulates a chain of operands, resolved lazily in two places:
- On read: Get or an iterator collects operands newest-to-oldest until it hits a base value or end of history, then applies them.
- During compaction: operands are folded so the chain doesn't grow forever.
The trade-off: cost moves from writes to reads. If operands pile up faster than compaction folds them, reads must walk a long chain — read amplification. A hot counter never read, then read once, can be surprisingly slow.
LevelDB lacks this; RocksDB, Pebble, and others expose a similar Merger interface.
More from coding & agent
- Dev Builds a TAS Bot to Break Crimsonland, Hits the 2.1B XP Score Cap — banteg · 2026-12-06
- Grok Bot now runs dev tasks via Grok Build agents after plan migration — testingcatalog · 2026-12-06
- Claude Sonnet built an open-world LEGO pirate game in 3 hours, fully playable in the browser — Promptmethus · 2026-12-06
- Evgeny Morozov built his own research software for 2 years to write a 400-page essay with 1,800+ footnotes — Promptmethus · 2026-12-06
- 6 concepts and free GitHub repos to learn AI agents without a $2,000 course — mhdfaran · 2026-12-06
- Advent of Enterprise AI ships one practical AI workflow per day through December — LeelooAI_fr · 2026-12-06