Skip to main content

Transactions and Concurrency

Isolation Levels

0:00
LearnStep 1/2

Isolation Levels

Concurrency Problems

1. Dirty Read

Reading uncommitted changes from another transaction:

2. Non-Repeatable Read

Same query returns different results:

3. Phantom Read

New rows appear between reads:

Isolation Levels

LevelDirty ReadNon-RepeatablePhantom
Read Uncommitted✓ Possible✓ Possible✓ Possible
Read Committed✗ Prevented✓ Possible✓ Possible
Repeatable Read✗ Prevented✗ Prevented✓ Possible
Serializable✗ Prevented✗ Prevented✗ Prevented

Setting Isolation Level

sql

Trade-offs

Higher isolation = More correct but slower

Lower isolation = Faster but may have anomalies