Compare

Side-by-side on the decisions that recur: index vs scan, normalize vs denormalize, optimistic vs pessimistic, partition vs shard, and more — with when to choose each.

Optimistic lockingPessimistic locking
MechanismVersion column; write with WHERE version = ?; retry on 0 rowsSELECT … FOR UPDATE; others wait
WaitingNoneBlocks conflicting transactions
DeadlocksImpossiblePossible; needs consistent lock order
Cost under contentionWasted work from retriesThroughput lost to waiting
Best whenConflicts are rareConflicts are likely and retries are expensive
Choose this whenEditing a profile or a document — simultaneous writers are rare and you do not want to hold locks across think time.Money movement, inventory decrements, seat booking — conflicts are likely and a lost race is costly.