Snapshot Isolation Explained: How Databases Read Without Waiting

Snapshot isolation explained in plain terms means understanding how a database can let a transaction read a consistent picture of the data without waiting for anyone else to finish. The central question is how readers and writers can work at the same time without blocking each other, and the answer is a snapshot: each transaction sees the database exactly as it was when the transaction began.

Snapshot isolation is a transaction isolation level in which each transaction reads from a private, frozen copy of the data taken at its start. Writes made by other transactions after that point are invisible to it, and its own writes are checked at commit time, so that two transactions that change the same row cannot both succeed.

The idea is simple: readers never block writers, and writers never block readers, because they work on different versions of the same rows. A transaction that only reads can run for as long as it likes without ever waiting, and a transaction that writes only fails if someone else changed the same data first. This article explains what snapshot isolation is, how it works, and where it is used.

Key takeaways

  • Snapshot isolation gives each transaction a frozen view of the data.
  • Readers never block writers, and writers never block readers.
  • Two transactions that write the same row cannot both commit.
  • It prevents dirty reads and lost updates, but not write skew.
  • It is the default in PostgreSQL and a common option elsewhere.

What snapshot isolation is

Snapshot isolation sits between read committed and serializable in the spectrum of isolation levels. A transaction sees a consistent snapshot of the database as it was at the moment the transaction started, which means it never sees a half-finished transaction, never sees a row change underneath it, and always gets the same answer if it reads the same row twice.

The guarantee is built on multi-version concurrency control. Instead of overwriting a row, the database keeps several versions of it, each stamped with the transaction that created it. A reader picks the version that was current when its snapshot was taken, while a writer creates a new version, so the two never interfere with each other.

The level was first described by Hal Berenson and his colleagues in 1995, in a paper that examined what the standard isolation levels actually guaranteed in practice. It has since become one of the most widely used isolation levels in real systems. Our guide to ACID explains the isolation guarantee that snapshot isolation partly provides, and our guide to SQL explains the databases in which these levels are set.

How snapshot isolation works

When a transaction begins, the database records a snapshot point, usually a transaction identifier or a timestamp. Every row the transaction reads is fetched from the version that was visible at that point, even if a newer version has since been written by someone else. The transaction therefore sees a stable, unchanging picture of the data for its whole lifetime.

Writes are handled differently. When a transaction updates a row, it creates a new version of that row and marks it with its own identifier, but the new version stays invisible to other transactions until the writer commits. If another transaction has already created a newer version of the same row, the writer discovers the conflict and is aborted, which is the rule that prevents two concurrent transactions from overwriting each other’s changes.

At commit time, the database runs a first-committer-wins check. The transaction is allowed to commit only if no other transaction has committed a change to any row it wrote since its snapshot was taken. If such a change exists, the transaction is rolled back and the application is expected to retry, usually with a fresh snapshot, which is the same retry pattern used by optimistic concurrency control.

Old versions are kept only as long as they are needed. A version can be removed once no running transaction can still see it, which is why long-running transactions are expensive under snapshot isolation: they force the database to keep old versions around, and the storage they use grows until those transactions finish.

The mechanism also explains why reads are so fast. A read never takes a lock, never waits for a writer, and never risks a deadlock, because it simply picks the right version from the history. This is the main reason snapshot isolation is popular in systems where reporting queries and long reads run alongside a heavy stream of writes.

A dark office with a glowing green database on screen, frozen rows of data captured in a still frame while new rows flow in behind
A dark office with a glowing green database on screen, frozen rows of data captured in a still frame while new rows flow in behind, shows how snapshot isolation works: each transaction reads its own frozen moment.

Comparing snapshot isolation with other isolation levels

Snapshot isolation is one of several isolation levels, and each was built with a different emphasis. Read committed shows the latest committed data but lets rows change between reads, while serializable guarantees a result as if transactions ran one after another, and each level trades safety for speed in a different way.

The table below sets out the main contrasts between the leading approaches.

Aspect Snapshot isolation Read committed Serializable
What a reader sees Frozen snapshot from start Latest committed data As if run one by one
Readers block writers Never Never Sometimes
Write conflicts First committer wins Last writer wins Detected and aborted
Write skew possible Yes Yes No
Best for Mixed reads and writes Simple, fast reads Money and stock

The practical result is that snapshot isolation is the right choice for most applications that mix reads and writes, read committed suits simple workloads where consistency matters less, and serializable is needed where a wrong result costs real money.

Where snapshot isolation is used

PostgreSQL uses snapshot isolation as its default level, under the name repeatable read. Every transaction in PostgreSQL gets a snapshot when it first reads, and its writes are checked with first-committer-wins, which is why a reporting query in PostgreSQL can run for minutes without ever blocking an update.

Oracle Database has offered snapshot isolation since the 1990s, under the name serializable in its own terminology, though it is really snapshot isolation rather than true serializability. Oracle’s design keeps old versions in rollback segments, so that a long-running query can always find the version it needs.

SQL Server offers snapshot isolation as an option that can be enabled per database. When it is on, readers use row versions stored in the tempdb database instead of taking locks, which removes the blocking that otherwise happens between reporting queries and updates in a busy system.

Distributed databases use snapshot isolation to let reads run on any replica. A read can be served from a snapshot taken on a nearby replica, without coordinating with the rest of the cluster, which keeps latency low while still giving the reader a consistent view of the data.

Web applications rely on snapshot isolation to keep forms and pages consistent. When a user opens a record to edit it, the application reads a snapshot, and when the user saves, the first-committer-wins check catches the case where someone else saved first, so the second save is refused instead of silently overwriting the first.

Strengths and limits

The greatest strength of snapshot isolation is that reads never wait. A long report, a backup, or an analytics query can run for as long as it needs without slowing down the writers, and writers can proceed without worrying about the readers, which is why the level scales so well under mixed workloads.

It is also a strength that the snapshot is genuinely consistent. A transaction that reads several tables sees them all as they were at the same moment, which is exactly what a report needs, and it never sees a half-finished update, which is what read committed cannot promise.

The limits are real, though. Snapshot isolation allows write skew, an anomaly in which two transactions each read data the other writes, and both commit, leaving the database in a state that no serial order of the two transactions could produce. It also keeps old versions around, which costs storage, and a long transaction can hold that storage hostage.

Snapshot isolation checklist

  • Use snapshot isolation as the default for mixed read-write workloads.
  • Keep transactions short so old versions can be cleaned up.
  • Retry transactions that fail the first-committer-wins check.
  • Watch for write skew in any transaction that reads then writes.
  • Use serializable for money, stock, and other critical invariants.
  • Monitor version storage; long transactions make it grow.
  • Test reports under load; they should never block writers.
  • Document which level each part of the application uses.
  • Never assume snapshot isolation is the same as serializable.

Frequently asked questions

What is snapshot isolation in simple terms?

It is a way of running a transaction against a frozen picture of the database taken when the transaction began, so that reads never change during the transaction and never wait for writers.

What is write skew?

It is an anomaly in which two transactions each read data the other one writes, and both commit, producing a result that no serial order of the two could give. A classic example is two doctors both reading that one on-call slot is free, and both booking it.

How is snapshot isolation different from read committed?

Under read committed, each statement sees the latest committed data, so the same row can change between two reads in one transaction. Under snapshot isolation, every read in the transaction sees the same frozen snapshot.

Why do long transactions cost storage under snapshot isolation?

Because the database must keep every version that a running transaction might still read. A transaction that runs for an hour forces the database to retain an hour of old versions.

Is snapshot isolation the same as serializable?

No. Serializable guarantees a result equivalent to running transactions one after another, while snapshot isolation still allows write skew. Some databases label snapshot isolation as serializable, which is a well-known source of confusion.

When should I not use snapshot isolation?

When the application must enforce an invariant across rows, such as a bank balance that must never go negative, or stock that must never be oversold. In those cases true serializable isolation is needed.

The bottom line

Snapshot isolation explained in one line is this: give every transaction a frozen picture of the data, and reads never have to wait.

It is the isolation level that keeps most real systems fast and consistent at once, with write skew as the one anomaly to watch for.

This article is general information about how snapshot isolation works, not advice about choosing an isolation level for a particular system.

Latest articles

Scroll to Top