</>CodexBash
All articles
Databases

Isolation levels

Transaction isolation levels in practice: the anomalies they prevent (dirty reads, non-repeatable reads, phantoms, lost updates and write skew), how read committed, repeatable read and serializable behave in PostgreSQL and MySQL, and how to choose.

CodexBash, , 5 min read

Two transactions running at the same time can see each other's work in surprising ways. One reads a balance, another changes it, and the first acts on a number that is no longer true. Isolation levels control how much of this is allowed. Stronger levels prevent more anomalies but cost more in waiting and retries; weaker levels are faster but leave some problems for your code to handle. This article names each anomaly, shows which level prevents it, and explains how PostgreSQL and MySQL actually behave.

Sign in to read the rest

The whole 5 minute article is free with an account, along with every problem, lesson and tutorial. No card.