Module 5 · Transactions and concurrency control
Episode 38 MVCC
▶ This video is coming to YouTube soon.
How can one transaction read a row while another is changing it, with nobody waiting? This episode animates Postgres's MVCC: every update writes a new row version with xmin and xmax, a snapshot picks exactly one version, and VACUUM removes the rest. Then pageinspect shows both versions in a real page, and a second session keeps reading the old balance after the update commits.
Chapters
- 0:00Intro
- 0:13Same row, same moment, no waiting
- 0:34One copy: wait, or read dirt
- 1:16Every update writes a new version
- 2:15A snapshot picks exactly one version
- 3:20The code: the visibility rule
- 4:02Readers never wait; writers still queue
- 4:53Garbage, the horizon and VACUUM
- 5:48Versions in the heap, or in an undo log
- 6:35Proof: two versions in one page
- 7:43Proof: a snapshot ignores a commit
- 8:41Trade-offs
- 9:08Recap
- 9:35Next: Isolation Levels in Real Life