|< < 5 > >|

Isolation levels

The SQL standard defines four isolation levels which trade isolation for concurrency.

Isolation level Characteristics Isolation properties Concurrency
Serializable
  • No compromises on isolation.
  • Execution of concurrent transactions is really equivalent to some serial execution.
  • Lowest level of concurrency.
  • Often unacceptable in practice.
Repeatable Reads
  • A row that has been read must look the same each time it is read.
  • But a query that is run multiple times may return additional rows on each run.
  • These are phantom reads resulting from committed inserts by other transactions.
  • Imperfect isolation.
  • More concurrency than serializable.
Read Committed
  • Reads are non-repeatable. Multiple reads of the same row might look different.
  • These differences are due to updates from recently committed transactions.
  • Phantom reads may occur.
  • Rows may disappear on a subsequent read (due to a committed delete).
  • Lowest level of isolation.
  • More concurrency than repeatable read.
Read Uncommitted
  • Reads may see uncommitted data!
  • These are dirty reads.
  • "Yes, my code is buggy, but at least it's fast."
  • No isolation!
  • Read uncommitted changes!
  • Fast and out of control.
  • All bets are off.
  • Don't use this!

|< < 5 > >|