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
- Patrick O'Neil, Edward Cheng, Dieter Gawlick, Elizabeth O'Neil (1996). The log-structured merge-tree (LSM-tree).