13, 12 chapters
inside indexes
everything.index_internals
inside indexes
b+trees page by page, splits under concurrency, and how hash, GIN, GiST, BRIN and LSM trees are built.
- 13.01b+treeswide and short, grows at the root, every leaf at the same depth. build one, a key at a time.
- 13.02a real b-tree, page by pagebt_metap, bt_page_items, high keys and sibling links, read off a 10,000-row index.
- 13.03page splitswhat happens when a leaf fills up, and why sequential keys split 90/10 instead of 50/50.
- 13.04b-trees under concurrencylatch crabbing, lehman and yao's right-links, and why readers never wait for a split.
- 13.05deduplication and bottom-up deletionposting lists for repeated keys, and clearing out old versions before resorting to a split.
- 13.06how a unique index says nochecking for a live duplicate, waiting on a transaction that hasn't decided yet, and the 23505 at the end.
- 13.07hash indexesa meta page, buckets, overflow pages, and splitting one bucket at a time. fill it until it splits.
- 13.08GINan inverted index: one entry per key, a posting list of rows, and the pending list that makes writes cheap.
- 13.09GiST and SP-GiSTtrees of bounding boxes for ranges, geometry and nearest-neighbour search.
- 13.10BRINa min and a max per block range. absurdly small, and only useful when the table is physically sorted.
- 13.11LSM trees and bloom filtersmemtables, SSTables, compaction, and the filter that says definitely not. the write-optimized design postgres doesn't use.
- 13.12vector indexesnearest neighbours for embeddings. HNSW graphs and IVF lists, approximate on purpose.