In short
Every database lets you choose how much your transaction is shielded from others running at the same time. More shielding means fewer surprises, but more waiting or retries.
Isolation levels set how much one transaction can see of others: READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ and SERIALIZABLE. Stronger levels prevent more anomalies but can cause more waiting or retries. PostgreSQL defaults to READ COMMITTED, MySQL InnoDB to REPEATABLE READ.

Think of it like this
Reading the college noticeboard
Read uncommitted is peeking at notices still being drafted in the office. Read committed is checking the board every time you look up, so you always see the latest pinned notices. Repeatable read is taking a photo of the board when you arrive and reading only from your photo. Serializable is the office making everyone use the board one at a time, as if no one else existed.
Watch it happen
Four levels, weakest to strongest
1/5The SQL standard defines four levels. Each one blocks more anomalies than the one before.
The big ideas
What you need to know
Stronger is safer
Higher levels prevent more anomalies, such as non-repeatable and phantom reads.
Stronger costs more
Higher levels mean more blocking or more transactions cancelled with 'could not serialize' errors.
Defaults differ
PostgreSQL uses READ COMMITTED, MySQL InnoDB uses REPEATABLE READ, SQL Server uses READ COMMITTED.
Retry on SERIALIZABLE
Apps using SERIALIZABLE must catch SQLSTATE 40001 and rerun the whole transaction.
See it in code
Walk through the code
1SHOW transaction_isolation; -- usually 'read committed'2 3BEGIN ISOLATION LEVEL REPEATABLE READ;4 5SELECT SUM(balance) FROM accounts WHERE branch = 'Kochi';6-- Another session now commits a ₹5,000 deposit in Kochi...7 8SELECT SUM(balance) FROM accounts WHERE branch = 'Kochi';9-- ...same total as before: this transaction reads one snapshot10 11COMMIT;12 13-- Strongest level, for logic that must never interleave14BEGIN ISOLATION LEVEL SERIALIZABLE;15-- ... reads and writes ...16COMMIT; -- may fail with SQLSTATE 40001: retry the whole transaction1/5Check what level new transactions get by default.
PostgreSQL syntax. PostgreSQL's REPEATABLE READ also blocks phantom reads. In MySQL, run SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; before START TRANSACTION.
Save yourself the pain
Common mistakes
Oops
Setting the whole database to SERIALIZABLE 'to be safe' without retry logic.
Do this instead
Use it only where needed, and make the app retry on serialization failures.
Oops
Assuming your SQL behaves the same on MySQL and PostgreSQL.
Do this instead
Their default levels differ. A report that's stable on MySQL may see changing data on PostgreSQL unless you set the level.
Your mission
See the snapshot
Quick check
What is the default isolation level in PostgreSQL?
Go deeper
- 1Check your database's default isolation level.
- 2Set a session to REPEATABLE READ and repeat the two-session experiment.
- 3Learn that SERIALIZABLE transactions may fail and need to be retried by the application.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.