How PostgreSQL Actually Handles Row Updates Using MVCC
When a row is updated in PostgreSQL, the database does not overwrite the existing data but instead creates a new version of the tuple while preserving the old one. This behavior is driven by Multi-Version Concurrency Control (MVCC), which allows multiple transactions to read consistent data simultaneously without blocking each other. Each row, or tuple, is stored in fixed-size 8 KB pages and located via a system column called ctid, which references a page number and a line pointer. Tuple headers carry transaction metadata fields — xmin and xmax — that record which transaction created or replaced a given version, allowing PostgreSQL to determine which version is visible to each transaction. This means two concurrent transactions can legitimately see different versions of the same row depending on their individual snapshots.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in