Chapter 21: Storage Engines — InnoDB, RocksDB, WiredTiger

The storage engine is the component that actually reads/writes data to disk. Different engines make different trade-offs.

B-Tree Based Engines (Read-Optimized)

InnoDB (MySQL default)

PostgreSQL's Heap + Indexes

LSM-Tree Based Engines (Write-Optimized)

RocksDB (Facebook), LevelDB (Google)

Write path (LSM-Tree): 1. Write to in-memory buffer (MemTable) — fast! 2. When MemTable full → flush to disk as sorted SSTable file 3. Background compaction merges SSTables Read path: 1. Check MemTable (RAM) 2. Check each SSTable level (disk) — use bloom filters to skip 3. Merge results Trade-off: Writes are FAST (sequential). Reads may check multiple files.
AspectB-Tree (InnoDB/PG)LSM-Tree (RocksDB)
Write speedModerate (random I/O)Fast (sequential I/O)
Read speedFast (one lookup)Moderate (check multiple levels)
Space amplificationLowHigher (multiple copies during compaction)
Best forRead-heavy OLTPWrite-heavy workloads

WiredTiger (MongoDB default)

Hybrid: B-tree structure with LSM-like write buffering. Supports both document and key-value access patterns.

Choosing a Storage Engine

💡 Rule of Thumb
Key Takeaways