Isolation level
How much a transaction is protected from seeing other transactions' concurrent changes.
Definition
The SQL standard defines Read Uncommitted, Read Committed, Repeatable Read and Serializable, by which anomalies they prevent: dirty reads, non-repeatable reads, phantoms. Real databases differ: PostgreSQL defaults to Read Committed and its Repeatable Read is snapshot isolation; MySQL InnoDB defaults to Repeatable Read. Stricter levels can abort a transaction with a serialization error that the app must retry.
In practice
A report runs several queries in one REPEATABLE READ transaction so all of them see the same snapshot.
Related terms
- ACIDAtomic, Consistent, Isolated, Durable: the guarantees a database transaction gives.
- MVCCMulti-version concurrency control: writers create new row versions so readers never wait for them.
- Optimistic lockingDetecting that someone else changed a record since you read it, and failing your update instead of overwriting theirs.