Try
↑ ↓ move↵ openesc close

Interview prep / LSM trees

Junior · LSM trees · System design interview question

Files in an LSM tree are never edited. How does a delete work?

Sketch your own answer first, then compare it with the one below.

A strong answer

The engine writes a marker, called a tombstone, for the key. A read that finds the tombstone first treats the key as deleted, because the newest version wins.

The old value is still in older files. Compaction removes it later, and the tombstone itself can be dropped only when the compaction reaches the oldest data that could hold the key.

So a delete does not free space right away, and a heavy delete workload can slow reads, because scans must step over many tombstones.

Sources

Learn it by running it

The lsm trees and compaction lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms