Systems & Backend

Memtable

The in-memory, sorted write buffer of an LSM store — flushed to an immutable SSTable when it fills.

A memtable is the in-memory, sorted structure where an LSM-tree database buffers recent writes. Writes go to the memtable (and a write-ahead log for durability); when it reaches a size threshold it is flushed to disk as an immutable SSTable and a fresh memtable takes over.

Worked example: a write updates the memtable in RAM and appends to the WAL, so it is fast and crash-safe; reads check the memtable first (newest data) then progressively older SSTables. Gotcha: the memtable is why LSM writes are fast (sequential, in-memory) but also why a crash relies on the WAL to replay un-flushed writes — lose the WAL and you lose everything since the last flush; its size tunes the write/flush frequency trade-off.