concept Data & storage
MVCC snapshot visibility across concurrent transactions
In PostgreSQL Repeatable Read, a later commit by another transaction does not change an established snapshot. The reader can still see its own earlier writes.
What it means
In PostgreSQL Repeatable Read, an ordinary SELECT can return an older row version even after another transaction has committed a newer one. The reader keeps its snapshot: a later commit by someone else does not change what that snapshot includes. The reader can, however, see changes it made in an earlier statement of its own transaction.
This is the distinction behind multiversion concurrency control (MVCC): a row can have more than one version. “Which version was written last?” and “Which version can this transaction read?” are different questions.
Try it
Simulation: follow one row with an already visible version, v1, and a replacement, v2. The sequence numbers represent order, not seconds or PostgreSQL transaction IDs. Start with snapshot 5, new version commit 7, owner/status other-committed, and evidence provided. The reader sees v1: the other transaction committed v2, but commit 7 falls after the snapshot's cutoff of 5.
MVCC snapshot visibility across concurrent transactions
Explain which row versions a transaction can see under a fixed isolation model
New version is outside the snapshot or uncommitted by another transaction.
Version visibility
- New version stateother-committed
- Snapshot5
- New commit position7
- Returned versionv1
Only the other committed version is compared with the snapshot cut. Equality belongs to the visible side in this fixture.
Evaluated inputs
- Required scenario evidence
- provided
- New version owner/status
- other-committed
- New version commit sequence
- 7 count
- Snapshot sequence
- 5 count
Simplified PostgreSQL repeatable-read visibility with abstract commit order, v1 preexisting, no xid wraparound, deletes or real snapshot format.
About this model
The controls set only a local, bounded scenario. The computed branch is not a verdict about a live system. Inputs listed as not evaluated did not participate in this branch after validation.
Reset restores the original inputs. It does not change the open or closed state of help or FAQ answers.
Change only New version commit sequence from 7 to 5. The reader now sees v2. The cutoff is inclusive in this simulation: commit 5 is the last commit included in snapshot 5. You changed when the writer committed, not when the reader looked.
Use Reset to restore the original inputs. Now change only New version owner/status to own. The result is again v2, but for a different reason: it is the reader's own prior write. The selected numbers are still 7 and 5; neither number is used to decide this case.
Two reads, one snapshot
Suppose the row holds a page title. A reader establishes snapshot 5 and reads the title as v1. An editor working in a different transaction commits the revised title, v2, at 7. The reader then asks for the title again in the same Repeatable Read transaction. The second query comes after the editor's commit, but the reader's snapshot still comes before it. That is why the second query can return v1 without implying that the editor's commit failed.
There is another way to get v1. Set the owner/status to other-uncommitted. Even a selected commit number of 1 does not make v2 visible: the editor has not committed in this scenario, so there is no commit to compare with the cutoff. Only other-committed calls for a comparison of the two numbers.
An unknown result is different from v1. With valid inputs and Required scenario evidence set to missing, the simulation does not select either version. An invalid input, such as a fractional snapshot sequence, also gives no version; it needs a correction rather than more evidence.
At the exact boundary, a stipulated commit at position 5 and a snapshot at position 5 select v2. The visual commit marker lies on the cutoff, not beyond it. This inclusive arithmetic belongs to the synthetic ordering convention, not a rule for comparing actual PostgreSQL transaction identifiers.
In practice
If two queries report different titles for the same row, identify the transactions and their isolation levels before interpreting the values. Did the reads share a snapshot? Did the reader itself write the revised title? If someone else wrote it, was that change committed and included in the reader's snapshot? The old title alone cannot distinguish an uncommitted edit from a commit that the snapshot excludes.
Snapshot lifetime matters here. Under PostgreSQL Read Committed, a later ordinary SELECT in the same transaction uses a new query-start snapshot and can pick up an intervening commit. Do not apply the fixed-snapshot result to those two reads.
The simulation does not inspect a database or reproduce PostgreSQL's internal snapshot format. Its useful rule is narrower: for another transaction's write, compare the commit with the snapshot that governed the read, not just with the time the query returned. For the reader's own earlier write, transaction identity explains the result.
Frequently asked questions
Editorial questions based on the listed sources and explicitly labeled local examples.
Does snapshot mean a full copy?
No. PostgreSQL MVCC presents a view of visible row versions rather than making a physical copy of the entire database for every snapshot. The cutoff in this example is a simplified visibility condition, not the contents of a real snapshot.
Are own writes visible?
Yes in this example. The reader can see its own stipulated version even when other transactions still see an older committed version. The engine defines the exact visibility rules.
Does Read Committed use the same snapshot lifetime?
No. In PostgreSQL Read Committed, an ordinary SELECT sees committed data as of that query's start, plus applicable changes in its own transaction. A later SELECT can see a newer committed version. Repeatable Read uses a different transaction snapshot lifetime.
Does MVCC alone prevent every anomaly?
No. Versioned reads can coexist with serialization anomalies. In PostgreSQL, Repeatable Read uses a snapshot but does not guarantee serializability.
Sources & model boundaries
Primary references used for this explanation. The interactive example is an educational model, not a live check.
- PostgreSQL transaction isolation
Sections 13.2.1 and 13.2.2. PostgreSQL Read Committed uses a fresh snapshot for ordinary SELECT statements, with own-transaction changes visible. Repeatable Read uses a stable transaction snapshot.
Checked .
- PostgreSQL MVCC introduction
Section 13.1 (introduction). MVCC lets readers see versions according to visibility rules, not a complete physical database copy for every snapshot.
Checked .