OOmnistu

Blog / Databases

Databases

PostgreSQL isolation levels: what concurrent transactions can see

Compare Read Committed, Repeatable Read and Serializable in PostgreSQL, including snapshots, serialization failures and transaction retries.

OOmnistu
Reviewed 2026-11-16 · 4 min read

Transaction isolation determines how concurrent database operations observe one another. In PostgreSQL 18, Read Committed is the default; Repeatable Read provides a stable transaction snapshot; Serializable adds checks intended to make successful concurrent transactions behave like some one-at-a-time order. Stronger isolation does not mean the application can ignore errors or retry handling.

This guide follows the PostgreSQL 18 transaction-isolation manual. The same level names can have different details in other database systems. Do not choose a production isolation setting from a name alone.

The anomalies in plain language

A dirty read sees another transaction's uncommitted changes. A nonrepeatable read occurs when a later read finds a row changed by a transaction that committed in the meantime. A phantom read concerns a changed set of rows matching a repeated query.

A serialization anomaly is broader: the combined committed outcome does not match any order in which the transactions could have run one at a time.

PostgreSQL's documented behaviour is:

Requested level Dirty reads Nonrepeatable reads Phantom reads Serialization anomalies
Read Uncommitted Prevented in PostgreSQL Possible Possible Possible
Read Committed Prevented Possible Possible Possible
Repeatable Read Prevented Prevented Prevented in PostgreSQL Possible
Serializable Prevented Prevented Prevented Prevented for successful Serializable transactions

PostgreSQL implements Read Uncommitted like Read Committed. Its Repeatable Read is stronger than the SQL standard's minimum on phantom reads. These are PostgreSQL-specific facts, not universal promises about every database.

Read Committed: each statement gets its view

An ordinary SELECT at Read Committed sees committed data as of the statement's start, along with the transaction's own earlier changes. Two successive reads inside one transaction can therefore see different committed data if another transaction commits between them.

Updating statements have additional concurrency rules. When a target row has been changed by another transaction, the later updater may wait and then re-evaluate its condition against the updated row. The manual explains why that can matter for complex search conditions.

The practical lesson is not "the default is unsafe." It is that the application's rule must fit the concurrency behaviour. Putting several statements between BEGIN and COMMIT does not automatically give them one unchanging view of the database.

Repeatable Read: stable does not mean serial

Repeatable Read uses a snapshot from the first non-transaction-control statement. Later reads do not pick up changes another transaction committed after that snapshot, although the transaction can see its own changes.

If an updating transaction encounters a conflicting change made after its snapshot, PostgreSQL can raise a serialization failure. The application must abort and retry the entire transaction from the beginning, rather than rerunning only the final statement with earlier decisions left intact.

A stable snapshot is still not a guarantee that all successful concurrent transactions match some serial order. PostgreSQL's manual explicitly warns that enforcing business rules at this level may need careful additional concurrency control.

Serializable: correctness includes handling retries

Serializable monitors read/write dependencies that could create a serialization anomaly. It can allow one transaction to commit and abort another with a serialization failure when the concurrent combination cannot be accepted.

That failure is not evidence that the protection has failed. It can be how the database prevents an invalid combined result. The application needs a general strategy for retrying the whole transaction and handling a result that ultimately cannot be completed.

Do not treat data read in a transaction that later aborts as a successfully committed business outcome. PostgreSQL also documents particular treatment for deferrable read-only transactions; this introduction is not a complete implementation guide for that mode.

Serializable is not a substitute for writing each transaction correctly. Nor does it mean every error disappears: the manual discusses possible unique-constraint errors even in overlapping Serializable work.

Example: two people compete for one resource

Suppose a hypothetical service checks availability and then confirms a reservation. Testing each request alone can miss what happens when both read "available" before either confirms.

Write down the invariant first: which combinations of confirmed records must never exist? Then review the transaction, database constraints and appropriate concurrency controls as one design. The right solution depends on how availability is represented and how all competing code paths update it.

This example is a design question, not a claim that switching one setting makes every booking system correct. Test the actual conflicting operations together.

A sequence is not a gap-free business counter

The manual notes that sequence changes are visible to other transactions immediately and are not rolled back when a transaction aborts. A gap in a sequence-backed identifier can therefore be normal.

Do not infer that a record was deleted or an order was lost solely because identifiers skip a value. If the product needs a separate numbering rule, define and review that requirement explicitly.

Questions for the engineering review

Our suggested checklist is:

  1. Which isolation level is actually used by the relevant transactions?
  2. What business invariant must hold under concurrent requests?
  3. Which statements depend on earlier reads?
  4. What happens on a serialization failure or other conflict?
  5. Does retry logic restart the whole transaction appropriately?
  6. Have competing requests been tested on the real transaction paths?

There is no throughput or performance recommendation here. Select the design around correctness requirements, measured workload and operational behaviour, not an assumption that a stronger-sounding label is automatically the best setting everywhere.

By Omnistu. Reviewed against PostgreSQL 18 documentation on 16 November 2026. No concurrency test or production configuration change was performed.

Sources

Previous
PostgreSQL constraints: CHECK, UNIQUE and foreign keys explained