Isolation Levels: Performance
Module: Data Modification & Transactions
Isolation Level Performance:
1. Lock Duration:
Read Uncommitted: No locks (fastest)
Read Committed: Short locks (released immediately after read)
Repeatable Read: Long locks (held until transaction ends)
Serializable: Range locks (held until transaction ends, locks entire range)
Impact: Longer locks = more waiting = slower throughput
2. Lock Contention:
Read Committed: Low contention (locks released quickly)
Repeatable Read: Medium contention (locks held longer)
Serializable: High contention (range locks block inserts/updates/deletes)
Example: 1000 concurrent transactions reading same account
- Read Committed: All execute concurrently (short locks)
- Repeatable Read: Execute sequentially (long locks, wait for each other)
- Serializable: Execute sequentially (range locks, highest wait time)
3. Deadlock Frequency:
Read Committed: Low deadlock risk (short locks, less overlap)
Repeatable Read: Medium deadlock risk (long locks, more overlap)
Serializable: High deadlock risk (range locks, most overlap)
Example: Two transactions updating different accounts
- Read Committed: Low deadlock risk (locks released quickly)
- Serializable: High deadlock risk (range locks may overlap)
4. Throughput Comparison:
Test: 1000 concurrent transactions, same query
- Read Uncommitted: 1000 TPS (no locks)
- Read Committed: 900 TPS (10% slower, short locks)
- Repeatable Read: 500 TPS (50% slower, long locks)
- Serializable: 100 TPS (90% slower, range locks + deadlocks)
5. Transaction Duration:
Read Committed: Fast (< 10ms for simple query)
Repeatable Read: Slower (10-50ms, waiting for locks)
Serializable: Slowest (50-500ms, waiting for range locks + deadlock retries)
6. Optimization Strategies:
Use Read Committed for most transactions:
- 99% of applications do not need stronger isolation
- High throughput (900+ TPS)
- Low deadlock risk
Use Repeatable Read for reports:
- Need consistent snapshot (same query returns same results)
- Can tolerate slower performance (reports run off-peak)