How databases lay data out on disk and find it again: logs, hash indexes, LSM trees, B-trees, and column stores.
Why Two Families Exist — A database stores and retrieves; every engine is a bet on which half to make expensive, and that bet splits OLTP storage into log-structured and in-place families. (4 min read)
The Log and Its Hash Index — Appending is the fastest thing a filesystem does; a log plus an in-memory hash index keeps that property and makes reads survivable, until the keys outgrow RAM. (3 min read)
SSTables and Sparse Indexes — A sorted, immutable file needs only a sparse index of one key per block, and it works precisely because it is never mutated in place. (8 min read)
Memtable, Flush, and Ref-Counting — How writes land in a memtable, get flushed to SSTables, and how RocksDB's SuperVersion and ref counts free old files without ever deciding to. (14 min read)
The WAL: Durability Before the Data Lands — The write is acknowledged after one sequential fsync to the write-ahead log, and a torn final entry is safe to drop because it was never acknowledged. (5 min read)
Concurrency, Tombstones, and Compaction — Atomic pointer publication keeps concurrent readers from crashing while sequence numbers keep their answers correct; tombstones and compaction reclaim what deletes leave behind. (13 min read)
Bloom Filters — A Bloom filter does not find keys faster; it proves a key is absent, which is the expensive case for an LSM read. (5 min read)
Compaction Strategies — Leveled compaction buys predictable reads by rewriting the same bytes 10 to 30 times; size-tiered buys write throughput by tolerating duplicates. (7 min read)
The Numbers on Disk — Block sizes, file counts and flush arithmetic worked through, including how file count multiplies the Bloom filter false-positive rate into real disk reads. (7 min read)
B-Tree Fundamentals — A B-tree is wide and shallow because every extra level is another disk read on every lookup; fixed-size pages are overwritten in place. (5 min read)
Splits, Borrows, and Merges — Inserts only ever split pages; borrowing and merging are deletion concerns, and most production engines skip merges entirely. (4 min read)
Heap and Index: Two Separate Structures — In PostgreSQL the table heap and each B-tree index are separate files; a TID is decided once by two unrelated searches and remembered forever. (11 min read)
Leaf Traversal: Sibling Pointers and Latch Coupling — Key order lives in leaf sibling pointers, not block numbers, which is why a range scan needs latch coupling where a point lookup does not. (6 min read)
MVCC and Visibility — PostgreSQL keeps every row version in the heap with xmin and xmax, and visibility is decided there, never in the index. (11 min read)
VACUUM, Dead Tuples, and Free Space — VACUUM reclaims dead tuples, but its existential job is freezing old rows before the 32-bit transaction ID counter wraps around. (12 min read)
In-Place Writes: WAL, Buffer Pool, Latches — When the client hears success only the WAL is on disk; the write-ahead rule, the buffer pool and page latches are what make in-place updates safe. (14 min read)
MVCC: LSM vs B-Tree, Side by Side — RocksDB needs one number where PostgreSQL needs three, because a RocksDB sequence number cannot exist before its write commits. (3 min read)
In-Memory Databases — In-memory databases are fast not because they skip the disk, which a warm B-tree also does, but because they skip encoding and decoding. (2 min read)
Query Execution: Compilation, Vectorization, Cubes — Query compilation and vectorized execution chase the same prize, a tight loop over sequential column bytes held in CPU cache; cubes precompute instead. (3 min read)
Multidimensional Indexes — No total order on a plane preserves proximity, so spatial indexes either linearize space (geohash, Z-order) or build trees over overlapping regions (R-trees). (13 min read)
Full-Text Indexes — An inverted index turns one document into hundreds of scattered keys, which is why Lucene's segments are the LSM tree's SSTables under another name. (13 min read)
Appendix A: The Logical to Physical Map — How a filesystem maps a file's logical offsets to disk blocks: block-to-block, stored in the inode, and in modern filesystems a B+tree of extents. (11 min read)
Appendix B: Logical vs. Physical Offset — A side read on what a file's private address space is, why an insert renumbers bytes without moving them, and why redirection cannot avoid the O(n) rewrite. (3 min read)
Synthesis and Self-Test — How the two families solve the same problems at different moments, then questions that each need at least two parts to answer. (14 min read)