The structural trade
Storage engines arrange data to favor either reads or writes. Making reads cheap usually means doing more work at write time, and making writes cheap usually means doing more work at read time.
Read optimized designs
- A B tree keeps data sorted in place, so a lookup or range scan is fast.
- Maintaining that order on every write costs random in place updates, which are slower.
- Materialized views and precomputed aggregates push work to write time so reads are trivial.
Write optimized designs
- An LSM tree appends writes to a log and a memory table, turning writes into fast sequential appends.
- Reads may need to check several layers, and background compaction merges them, paying the cost later.
How to choose
- A read heavy workload, like a product catalog, favors read optimized structures and aggressive precomputation.
- A write heavy workload, like metrics ingestion or event logging, favors write optimized structures.
Match the engine to where your work actually concentrates.
Key idea
Read optimized structures do work at write time so reads are cheap while write optimized structures append fast and defer work to read or compaction time.