Explain like I'm five · Database

What is Database Concurrency Control?

Concurrency control, told as a story about a packer and a driver reaching for the same box at once.

the packer and the driver reach for the same box at onceif nobody decides who goes first, the two collide

The packer and the driver both reach for the same box at once.If nobody decides who goes first, the two collide.

when two people edit the count at once, one edit gets erasedthe rule that stops lost edits is 'concurrency control'

When two people edit the count at once, one edit gets erased.The rule that stops lost edits is 'concurrency control'.

wait in line, in ordershow each person a separate snapshot (MVCC)concurrency control = rules that stop simultaneous edits from collidinglock the box, order the work, or show separate versions

Concurrency control is rules that stop simultaneous edits from colliding.Lock the box, order the work, or show separate versions.

Pessimistic lockinglocks the box up front to avoid conflict
Optimistic controledits first, checks for conflicts later
Timestamp orderingorders the work by start time
MVCC (multi-version)shows each person a data snapshot
four common concurrency control methodspessimistic locking — lock the box up frontblocks conflict from the startoptimistic — edit first, check for conflicts laterfast when conflicts are raretimestamp ordering — order work by start timeprocessed in arrival orderMVCC — show each person a snapshotreads don't block writes

Concurrency control has four common methods.MVCC lets reads and writes avoid blocking each other.

locking the box keeps the count safebut the next person waits in linethe locking method and isolation level together set the safety-speed balance

The more tightly locks guard the data, the longer the next person waits.The locking method and isolation level together set the safety-speed balance.

In one breath

Concurrency control is the set of rules — locking, ordering, or versioning — that keeps simultaneous edits from colliding.

Concurrency control preserves correctness when multiple transactions run at once, using techniques like pessimistic locking (e.g. two-phase locking), optimistic concurrency control, timestamp ordering, and MVCC (multi-version concurrency control). It's how ACID's Isolation is actually implemented, and the choice of method shapes both isolation level and performance.

When grown-ups say it

Pessimistic Locking
Locking the box up front. Two-phase locking is the classic form.
Optimistic Concurrency Control
Trying first, checking for conflicts later. Fast when conflicts are rare.
Timestamp Ordering
Ordering work by its start time. Honors arrival order.
MVCC
Showing each transaction its own snapshot. Reads don't block writes.
Deadlock
Both sides stuck waiting on each other's lock. Happens when a wait cycle forms.
Isolation Level
The setting for how strictly to guard simultaneous work. Concurrency control methods realize this level. → how much to hide when hands overlap
ACID
The four promises a receipt keeps. Concurrency control is what keeps the Isolation promise. → the four promises a receipt keeps
Consensus
A story from the SRE field about servers agreeing. When many servers must agree on one value, they use a consensus algorithm. → consensus
Next story
The Express Desk That Skips the Deep Shelf →
Want another term as a picture book? Request →