Databases & Storage · advanced

Storage Engines

B-tree vs LSM, indexing, WAL.

databasesstorage-engines

Mental model

A storage engine is the layer that actually puts bytes on disk and finds them again. The defining choice is the write path: B-trees update pages in place (read-optimized), LSM trees append and merge (write-optimized). Everything else — WAL, indexes, caching — serves durability and lookup speed.

How to study Storage Engines

Begin by restating the mental model in your own words, then connect it to a concrete system you have built or operated. Name the mechanism, the constraint it addresses, and the trade-off it introduces. Use Designing Data-Intensive Applications (Kleppmann) — book site, The Log-Structured Merge-Tree (O'Neil et al.), SQLite — Write-Ahead Logging to check details, but close the source before writing your explanation. Retrieval is the learning step; rereading is only preparation.

Next, compare Storage Engines with B-Tree, LSM Tree. Ask what changes in correctness, latency, resource use, operability, and failure recovery. Complete Storage vs retrieval API and preserve the command, input, output, and one failed attempt as evidence. Finish by explaining the idea without jargon to someone who has not studied the track.

Proof of understanding

  • Explain the mechanism from first principles and identify the state it reads or changes.
  • Give one situation where the concept is the right choice and one where it is not.
  • Predict a realistic failure mode before running the drill, then compare the prediction with evidence.
  • Connect the result to a roadmap or build artifact instead of treating the concept as isolated trivia.

Common mistakes

  • Picking an engine without knowing the read/write ratio of the workload
  • Ignoring write amplification and its effect on SSD lifetime
  • Forgetting that every secondary index is extra write cost

Learn from primary sources

Practice and explain it back

Storage vs retrieval API

Design blob store: PUT by id vs GET by tag. Which needs secondary index? Which is O(1) lookup?

Expected evidence: PUT/GET by id is primary key O(1); tag search needs inverted/secondary index.

Open the interactive drill →

Review prompts

  • B-tree versus LSM: which one has read amplification and which has write amplification, and where does each come from?

Build evidence

Use a roadmap capstone to turn this concept into working evidence.

Prerequisites

None assigned yet.

Related concepts

Learning paths