Semicolony ELI5 · comic

B-tree vs LSM-tree.

Filing each card neatly in place as it arrives, versus jotting everything in order and tidying up in batches later.

  1. 1

    A B-tree is a librarian who re-shelves every returned book the instant it comes back.

  2. Back and forth all day.
    scattered, random writes
    2

    Keeping the shelves sorted means lots of walking around — scattered, random writes.

  3. Right where it should be.
    straight to the spot
    3

    The payoff: reads are direct. Walk straight to the exact shelf and grab it.

  4. On the cart, sort it later.
    on the cart
    4

    An LSM-tree dumps returns on a cart and jots them down fast — quick, sequential writes.

  5. Now where did I put it…
    cart file 1 file 2 check several
    5

    A reader may now check the cart and several shelves — so reads can touch more places.

  6. merge sorted
    6

    In the background, compaction sweeps the carts onto sorted shelves and drops stale copies.

Re-shelving every book the instant it returns, versus a cart and batch sweeps later. (Bit runs the library.)
Semicolony semicolony.dev/eli5/btree-vs-lsm/comic
← All ELI5 explainers