Transaction Isolation Levels

Transaction isolation levels regulate how operations within a transaction observe data modified by others, balancing data integrity with system concurrency.

Transaction isolation levels govern how concurrently executing transactions interact with shared data. The four standard ANSI isolation levels are READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ, and SERIALIZABLE, each trading off concurrency and data consistency. READ UNCOMMITTED allows reading uncommitted changes (dirty reads), READ COMMITTED prevents dirty reads but permits non-repeatable and phantom reads, REPEATABLE READ guarantees that data read within a transaction remains stable for the duration of that transaction and prevents non-repeatable reads but may allow phantom reads, and SERIALIZABLE ensures a strictly serial execution order that eliminates dirty reads, non-repeatable reads, and phantom reads at the cost of higher blocking and lower throughput. In practice, implementations vary: MVCC-based systems (e.g., PostgreSQL, Oracle in MVCC mode) provide snapshot-based reads; classic locking approaches (e.g., some modes in SQL Server, Oracle) rely more on locks. Snapshot isolation (SI) is often implemented as a distinct approach using MVCC to present a consistent snapshot, but SI can permit write skew anomalies under certain workloads. When choosing an isolation level, teams should weigh data consistency requirements against concurrency and performance. Vendors differ in default levels and guarantees, so consult the specific database's documentation.

        graph LR
  Center["Transaction Isolation Levels"]:::main
  Rel_transaction["transaction"]:::related -.-> Center
  click Rel_transaction "/terms/transaction"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧒 Explain Like I'm 5

Generated ELI5 content

🤓 Expert Deep Dive

Generated expert content

❓ Frequently Asked Questions

What is a dirty read?

Reading data that has been modified but not yet committed by another transaction.

What is a non-repeatable read?

Reading the same data twice within a single transaction yields different results because another transaction committed changes in between.

What is a phantom read?

A new row matching a query appears in subsequent reads within the same transaction, due to inserts by other transactions.

Which isolation level prevents dirty reads?

READ COMMITTED or SERIALIZABLE (and REPEATABLE READ) prevent dirty reads.

How should I choose an isolation level?

Base the choice on the required balance between correctness guarantees and concurrency, adjusting per operation, and consider MVCC or locking behavior of your DBMS.

📚 Sources