1 of 4

Your RightSignal

How databases work · 6 of 91 / 3

Isolation levels

The concept

How two shoppers can both buy the last concert ticket

An isolation level sets how much transactions running at the same time see of each other's work. SQL names four, from loosest to strictest: Read Uncommitted, Read Committed, Repeatable Read and Serializable.

Say one seat is left. Two checkouts each read seats_left = 1, insert a ticket and write seats_left = 0. Together they sell two tickets for one seat. Loose levels allow this; Serializable does not.

Levels differ in which anomalies (wrong results) they rule out. Dirty reads see changes that aren't committed. Non-repeatable reads see a row change between two reads. Phantoms are new rows matching a rerun query.