Isolation levels.
A dial that trades how much overlapping transactions can see of each other for how fast they run.
- 1
Two people edit the same document at once. The database has to decide how much each sees of the other’s half-typed work.
- Wait, where did that line go?2
Loosest setting: you read a sentence the other person hasn’t saved — then they delete it. That’s a dirty read.
- 3
Turn the dial up to read committed: you only ever see saved work, never anyone’s drafts.
- 4
Higher still — repeatable read: a line you’ve read stays put for the rest of your turn, even if someone edits it.
- That paragraph wasn’t there a second ago.5
But brand-new lines can still appear between two reads of the same section. Those are phantoms.
- 6
Top of the dial — serializable: it acts as if you each took the whole document in turn. Spotless, but everyone waits more.
Semicolony semicolony.dev/eli5/isolation-levels/comic