Transaction isolation levels define how concurrent transactions interact to maintain data consistency and integrity. As part of the ACID properties, isolation ensures each transaction acts independently. The four levels, Read Uncommitted, Read Committed, Repeatable Read, and Serializable, balance performance and data accuracy.
- Help control concurrent transaction behavior in multi-user databases.
- Define when and how changes made by one transaction become visible to others.
- Prevent issues like dirty reads, non-repeatable reads, and phantom reads.
- Offer a trade-off between system performance and data reliability.
- Higher isolation ensures greater data accuracy but reduces concurrency.
- SQL defines four standard isolation levels under ANSI/ISO standards.
Phenomena Defining Transaction Isolation Levels
These phenomena determine how transactions interact and where data inconsistencies may occur:
1. Dirty Read
A Dirty read is a situation when a transaction reads data that has not yet been committed.
Example:
Let's say transaction 1 updates a row and leaves it uncommitted, meanwhile, Transaction 2 reads the updated row. If transaction 1 rolls back the change, transaction 2 will have read data that is considered never to have existed.
2. Non Repeatable read
Non-repeatable read occurs when a transaction reads the same row twice and gets a different value each time.
Example:
suppose transaction T1 reads data. Due to concurrency, another transaction T2 updates the same data and commit, Now if transaction T1 rereads the same data, it will retrieve a different value.
3. Phantom Read
Phantom Read occurs when two same queries are executed, but the rows retrieved by the two, are different.
Example:
suppose transaction T1 retrieves a set of rows that satisfy some search criteria. Now, Transaction T2 generates some new rows that match the search criteria for Transaction T1. If transaction T1 re-executes the statement that reads the rows, it gets a different set of rows this time.
The Table given below clearly depicts the relationship between isolation levels, read phenomena, and locks:

Anomaly Serializable is not the same as Serializable. That is, it is necessary, but not sufficient that a Serializable schedule should be free of all three phenomena types. Transaction isolation levels are used in database management systems (DBMS) to control the level of interaction between concurrent transactions.
The four standard isolation levels are:
1. Read Uncommitted
This is the lowest level of isolation where a transaction can see uncommitted changes made by other transactions. This can result in dirty reads, non-repeatable reads, and phantom reads.
2. Read Committed
In this isolation level, a transaction can only see changes made by other committed transactions. This eliminates dirty reads but can still result in non-repeatable reads and phantom reads.
3. Repeatable Read
This isolation level guarantees that a transaction will see the same data throughout its duration, even if other transactions commit changes to the data. However, phantom reads are still possible.
4. Serializable
This is the highest isolation level where a transaction is executed as if it were the only transaction in the system. All transactions must be executed sequentially, which ensures that there are no dirty reads, non-repeatable reads, or phantom reads.
Choosing the Right Isolation Level
The isolation level should match the application’s needs balancing data accuracy and performance.
- Higher levels (e.g., Serializable): Strong consistency, lower concurrency, slower performance.
- Lower levels (e.g., Read Uncommitted): Better concurrency, faster performance, risk of inconsistencies.
Advanced options
- Snapshot Isolation: Uses consistent data snapshots.
- MVCC(Multi-Version Concurrency Control): Maintains multiple data versions for smoother concurrency.