storage
LSM Tree
Log-Structured Merge Tree: write to sorted memtable → flush to L0 when full → compact deeper.
memtable0/4
L00
L10
total0
🧠 Memtable (in-memory, sorted) — 0/4
empty
↓ flush when full ↓
💾 Level 0 (on disk, sorted) — 0 entries
empty
💾 Level 1 (on disk, sorted) — 0 entries
empty
// operation log
No operations yet
How It Works
- Writes go to in-memory sorted memtable (fast)
- When full, memtable flushed as sorted run to L0
- Background compaction merges levels (deduplicates)
- Reads check memtable → L0 → L1 (newest first)
Use Cases
- LevelDB, RocksDB, Cassandra
- Write-heavy workloads
- Time-series databases
- Key-value stores with high throughput