Two databases can speak identical SQL and behave completely differently under load — because underneath, they made opposite choices about one question: when you write a row, where do the bytes actually go? A B-tree finds the right page and overwrites it in place. An LSM-tree refuses to overwrite anything — it appends the write to memory, and later rewrites whole files in the background. That one difference is why Postgres and Cassandra have such different performance shapes.
The LSM write path is the one worth seeing, because it moves. Write keys and watch them collect in the in-memory memtable; when it fills, it flushes to an immutable file (SSTable); as files pile up, compaction merges them. Then read a key and watch how many layers it has to probe.
Writes are cheap (append to RAM). Reads pay for it — more un-compacted L0 SSTables mean more probes. Compact to collapse them.
- Empty engine. Writes land in the in-memory memtable first.
The whole story in one contrast
Why you should care which one you’re running
- Write throughput. LSM turns random writes into sequential appends + batched flushes, so it absorbs far higher write rates. If your workload is ingest-heavy (time-series, event logs, messaging), that’s decisive.
- Read latency & range scans. A B-tree read is a single top-down traversal to one page; an LSM read may check several files. For read-heavy and range-scan workloads, B-trees are often simpler and more predictable.
- Space & background work. LSM compaction reclaims space from overwritten/deleted keys but spends I/O rewriting data (write amplification) and can cause latency spikes. B-trees fragment and carry a write-ahead log, but have no compaction storms.
The members-only deep-dive builds both engines properly: the B-tree page model and why it’s read-optimized; the full LSM machinery (WAL, memtable, SSTables, the layered read with bloom filters, and compaction); the read/write/space amplification tradeoff and the RUM conjecture that says you can’t win all three; size-tiered vs leveled compaction (Cassandra vs RocksDB); a decision guide for which engine fits which workload; and how RocksDB, InnoDB, Postgres, and Cassandra/ScyllaDB actually ship this — with an interview challenge and quiz.
Keep reading with Premium
You've reached the members-only part of this deep-dive — the full implementation, the interactive ring simulator, and the step-by-step walkthrough. Unlock it with a membership.
Discussion
Loading the conversation…
Discussion
Loading the conversation…