The Idea
MVCC lets the database keep multiple versions of a row at once. Instead of overwriting a row in place, an update writes a new version and leaves the old one for transactions that still need it.
Why It Helps
- Readers never block writers and writers never block readers.
- Each transaction sees a consistent snapshot of data as of its start.
- Old versions stay visible to transactions that began before the change.
How It Works
- Each row version carries transaction visibility markers.
- A transaction reads the version valid for its snapshot.
- Obsolete versions are later cleaned up by a process such as vacuum.
The Cost
- Storage grows with dead versions until cleanup runs.
- Long running transactions hold back cleanup, causing bloat.
MVCC powers snapshot isolation in many engines like PostgreSQL and is why a long report query does not freeze writes.
Key idea
MVCC keeps multiple row versions so readers and writers run without blocking, each seeing a consistent snapshot.