Systems & Backend

SSTable

also: sorted string table

A Sorted String Table: an immutable, sorted-on-disk file of key-value pairs — the on-disk unit of LSM-tree stores.

An SSTable (Sorted String Table) is an immutable file storing key-value pairs sorted by key, the on-disk building block of LSM-tree databases. Once written it is never modified; updates and deletes are new entries in newer SSTables, reconciled at read time and during compaction.

Worked example: when the in-memory memtable fills, it is flushed to disk as a new SSTable; because each SSTable is sorted, a read can binary-search within one, and a sparse index plus a bloom filter tell it which SSTables to even check. Gotcha: immutability makes writes fast and crash-safe but pushes cost to reads (a key may live across several SSTables) — which is why compaction, bloom filters, and block indexes exist: to keep the read from scanning every file.