Part 3 of 5 · 1 min read
Snapshot isolation
A transaction sees a consistent snapshot of the database as of its own start time, regardless of later writes.
Think of taking a single photograph of a room at the exact moment a transaction begins. That transaction consults only that photograph for the rest of its work, no matter how much the real room changes afterward.
In plain words: snapshot isolation means a transaction sees the database exactly as it existed at the transaction's own start time: a consistent snapshot. For every row it reads, the transaction is given whichever version of that row was the current one at its own start time, ignoring any newer versions created by transactions that started later. This directly guarantees a transaction never sees a dirty read or a non-repeatable read, covered earlier in this level, since the snapshot itself never changes partway through the transaction's execution.
A worked example. A transaction that begins at a specific moment and reads the same row twice always sees the same version, the one current at its start time, even if several other transactions commit new versions of that row in between its two reads.
The key lines. No new SQL; snapshot isolation is the isolation guarantee MVCC provides by construction, simply by choosing which version of each row a transaction is allowed to see.
Snapshot isolation
Snapshot isolation gives a transaction a consistent view of the database as of its own start time, reading whichever version of each row was current then, regardless of newer versions created afterward.
Example: a single photograph of a room, consulted for the rest of a transaction's work regardless of later changes to the real room, mirrors a snapshot.