14, 12 chapters
MVCC and vacuum
everything.mvcc
MVCC and vacuum
why an UPDATE writes a new row, who can see which version, and the vacuum that cleans up after everyone.
- 14.01an UPDATE is an INSERTpostgres never overwrites a row. it writes a new version and stamps the old one with xmax.
- 14.02transaction ids, xmin and xmaxwho made this version and who ended it. virtual xids, lazy assignment, and SELECT xmin, xmax, ctid.
- 14.03snapshotsxmin, xmax and the in-progress list. three numbers that decide everything your query can see.
- 14.04the visibility rulesis this version visible to me? the whole decision as a flowchart, checked against real rows.
- 14.05the commit log and hint bitspg_xact, two bits per transaction, and the SELECT that dirties a page.
- 14.06HOT updates and pruningan update that skips every index, if the page has room and no indexed column changed.
- 14.07VACUUMremoving dead versions, cleaning indexes, and why the file doesn't shrink. VACUUM FULL and the bloat it fixes.
- 14.08autovacuumthresholds, scale factors, cost limits, and the busy table it never seems to reach.
- 14.09the xmin horizonone forgotten transaction and nothing gets cleaned. dead, but not yet removable.
- 14.10freezing and wraparound32-bit transaction ids go round in a circle. freezing, age(), and the shutdown nobody wants.
- 14.11MultiXactswhen several transactions lock one row at once. the other counter that can wrap.
- 14.12MVCC with undo logshow InnoDB and Oracle keep old versions in an undo log instead, and what each design pays.