Pcornel
Databases · Transactions, MVCC & Locking

Isolation Levels

Cheat sheet · https://pcornel.dk/topic.php?topic=6173

Back to the Topic

Answer

Isolation levels (Read Uncommitted, Read Committed, Repeatable Read, Serializable, plus SQL Server Snapshot) decide which concurrency anomalies a transaction can see.

Remember

Defaults: PostgreSQL and SQL Server Read Committed, MySQL InnoDB Repeatable Read. Higher isolation means more retries or blocking — applications must retry serialization failures.

First checks

  • SHOW transaction_isolation; — first check for this topic
  • psql -c "SELECT now(), version();" — PostgreSQL reachable and version
  • mysql -e "SELECT NOW(), VERSION();" — MariaDB/MySQL reachable and version
  • sqlcmd -S <server> -Q "SELECT @@VERSION" — SQL Server reachable and version

Verify in this order

transaction starts with an isolation level → snapshot/locks → visible data

Where it usually breaks

Read-then-update without FOR UPDATE can lose updates under read committed.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6173

Confirmation

Confirm action

Continue?