Skip to content

Snapshots & the four levels ​

Isolation controls what concurrent transactions can observe and which combinations can commit. Concepts: isolation levels introduces the vocabulary. This chapter separates PostgreSQL 18 Documented contracts from outcomes demonstrated on the version printed in each Transcript, currently 18.6.

How PostgreSQL actually does it: snapshots ​

PostgreSQL's MVCC introduction documents snapshot-based access to row versions. Plain SELECTs do not wait for the row-update locks shown in this chapter. That does not mean only same-row writers can wait: table locks can block SELECT, and locking reads can wait for row locks.

The following table summarizes the PostgreSQL 18 isolation contracts. Snapshot visibility includes prior writes by the reading transaction; sequences have separate rules. Updating and locking commands need the operation-specific rules in the following lessons.

You ask forYou getPlain SELECT snapshot
READ UNCOMMITTEDREAD COMMITTED behaviornew snapshot per query
READ COMMITTED, the defaultREAD COMMITTEDnew snapshot per query
REPEATABLE READPostgreSQL snapshot isolation, no phantoms from concurrent commitssnapshot from the first non-transaction-control statement
SERIALIZABLEREPEATABLE READ visibility plus SSI monitoringtransaction snapshot, with possible serialization failure

The READ UNCOMMITTED schedule demonstrates one uncommitted UPDATE remaining invisible. The REPEATABLE READ schedule demonstrates exclusion of later committed changes and visibility of own writes. Neither finite schedule establishes the complete contract by itself.

Choosing a level ​

sql
BEGIN ISOLATION LEVEL REPEATABLE READ;
BEGIN; SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
SET default_transaction_isolation = 'repeatable read';

These are alternative forms, not a sequence to run inside one transaction. SET TRANSACTION documents that the isolation level cannot change after the first query or data-modification statement. The session default applies to subsequent transactions; it does not change a current transaction's established snapshot.

Further reading ​

MIT Licensed · Every transcript on this site was generated by a real database run against MySQL 8.4.11 and PostgreSQL 18.6 at 8fa27b8; shared YAML has an independent psycopg/PyMySQL check.