§ how it works · postgresql
PostgreSQL, down to the page and the tuple.
Each card below is an SVG visualization of one PostgreSQL internal: how an 8 KB page fills from both ends, and why a single UPDATE leaves two versions of the same row on disk. A drawn model of the storage layer, not a list of SQL commands.
These are drawn diagrams, not a sandbox. To open a real page with pageinspect and watch two versions across two sessions, head to the lessons with a live server.
storage · 5 steps
Page anatomy: 8 KB, filled from both ends
A table on disk is an array of 8 KB pages, and each page fills from two sides at once: a line-pointer array grows down from the header, tuples grow up from the end, and the free space is whatever gap is left in the middle. Here is how one page fills up.
view→mvcc · 5 steps
MVCC: one row, two versions
An UPDATE in PostgreSQL never overwrites a row. It writes a new version and stamps the old one with the transaction that retired it. For a while the same row exists twice on the page, and two sessions can read two different truths. Here is how, and how VACUUM cleans up afterward.
view→