Cards/Storage EnginesSystem Design · Day 28Aug 28, 2026

Two Ways To Write A Number Down

B-tree versus LSM tree — updating a page in place against appending to a memtable and flushing to sorted files, with compaction as the hidden cost

Change one number in a row. Postgres goes and finds the page holding it and edits that page where it sits, splitting the page if it has filled up. One lookup to read, real work to write.

Cassandra takes the opposite deal. The new value is appended to a sorted table in memory and flushed to disk later, and the old value stays exactly where it is. Writes cost almost nothing. Reads now have to check several files, newest first, because the same key lives in three places at once.

Every database picks one of these, and the choice decides everything else about what it is good at.

The LSM side carries a bill that arrives quietly. Background compaction merges those files and discards stale versions, and it competes for precisely the disk your queries want. The work never disappears — it moves to a moment you did not choose.

You can do the hard part now, or schedule it for later. There is no third option.