IntermediateAbout 15 min

    LSM-Trees & SSTables

    Read the full article on Substack

    7 min read.

    Watch writes land in a memtable and a log, flush into sorted SSTables, get read newest-first with bloom filters, and merge during compaction.

    Think of it this way: An LSM-tree is like a busy office that never edits old paperwork. New notes go on a sorted desk pad; when the pad is full it is filed as a dated folder. To answer a question you check the pad, then the newest folder, then older ones. Once a week someone merges old folders and throws away notes that were replaced.

    In memorydisk writes: 0
    Memtablesorted, in RAM
    empty
    On disk
    Write-ahead logappend only
    empty

    An LSM-tree turns every write into a fast append. Watch 6 writes arrive, including an update and a delete.

    1/16

    Check your understanding

    Answer from memory before you scroll back up. Pulling an idea out of your head is what makes it stay there.

    Follow a write into an LSM-tree

    Sequence

    Order what happens from the moment a put arrives until its old value is cleaned up.

    Tap a piece, then tap where it goes — or drag it. Tap the tray to take one back.

    1. 1Drop a step here
    2. 2Drop a step here
    3. 3Drop a step here
    4. 4Drop a step here
    5. 5Drop a step here
    5 pieces left to place

    Quiz

    8 questions
    Question 1 of 8
    Score: 0

    Where does an LSM-tree put a new write first?

    Done with this lesson?

    Sign in free to keep your progress, streak and quiz scores.

    Keep going