Quick revision
The short answer
A dirty read is reading another transaction's uncommitted change, which may then be rolled back; READ COMMITTED is the first level that prevents it. A non-repeatable read is reading the same row twice and getting different values because another transaction updated and committed it in between; REPEATABLE READ is the first to prevent it. A phantom read is running the same range query twice and seeing new rows another transaction inserted; the SQL standard allows phantoms at REPEATABLE READ and forbids them only at SERIALIZABLE, although real databases differ, PostgreSQL's REPEATABLE READ showing no phantoms at all.
What to remember
In this answer, we saw that a dirty read uses another transaction's uncommitted change and is prevented from READ COMMITTED upward, a non-repeatable read sees a row change between two reads and is prevented from REPEATABLE READ upward, and a phantom read sees new rows in a repeated range query and is forbidden by the standard only at SERIALIZABLE. Real databases differ: PostgreSQL never allows dirty reads and its snapshot-based REPEATABLE READ shows no phantoms, and the standard's list misses anomalies such as lost update and write skew.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
A dirty read is reading another transaction's uncommitted change, which may then be rolled back; READ COMMITTED is the first level that prevents it. A non-repeatable read is reading the same row twice and getting different values because another transaction updated and committed it in between; REPEATABLE READ is the first to prevent it. A phantom read is running the same range query twice and seeing new rows another transaction inserted; the SQL standard allows phantoms at REPEATABLE READ and forbids them only at SERIALIZABLE, although real databases differ, PostgreSQL's REPEATABLE READ showing no phantoms at all.
Why this question is asked
Isolation levels are a setting most developers leave at the default, until a report shows numbers that do not add up or a check passes that should have failed. The three classic read phenomena are the vocabulary for talking about those bugs. Interviewers ask about them to check that we can describe each one precisely, map it to the levels, and know where real databases differ from the textbook. In this answer, we will recap isolation levels, go through each phenomenon with a two-session example, map them to the standard levels, see how PostgreSQL and MySQL actually behave, and note what the standard list leaves out.
1A Quick Recap of Isolation Levels
When transactions run at the same time, the isolation level decides how much one can see of what others are doing. The SQL standard defines four levels, READ UNCOMMITTED, READ COMMITTED, REPEATABLE READ and SERIALIZABLE, in terms of which phenomena each must prevent. A phenomenon, also called an anomaly, is an effect of concurrency that could not happen if the transactions ran one after another.
In the examples below, T1 and T2 are two concurrent transactions, and accounts has a row with id 1 and balance 100.
2Dirty Read
A dirty read happens when T1 reads a change that T2 has made but not committed. If T2 then rolls back, T1 has used data that never existed.
Notice the danger: T1's decision rests on a value that was never committed. READ COMMITTED is the first level that prevents this, because a transaction then only sees data that other transactions have committed; T1 would read 100.
3Non-Repeatable Read
A non-repeatable read happens when T1 reads the same row twice and gets different values, because T2 updated the row and committed between the two reads. Each value T1 saw was committed, so this is not a dirty read, but T1's picture of the row changed in the middle of its work.
A report that reads a balance at the start and again at the end may then show totals that do not match. REPEATABLE READ is the first standard level that prevents this: once T1 has read a row, re-reading it in the same transaction returns the same value.
4Phantom Read
A phantom read is about sets of rows rather than one row. T1 runs the same range query twice, for example all orders with status 'NEW', and the second time sees rows that T2 inserted, or no longer sees rows T2 deleted, and committed in between. The new rows are the phantoms.
| Level | Dirty read | Non-repeatable read | Phantom read |
|---|---|---|---|
| READ UNCOMMITTED | possible | possible | possible |
| READ COMMITTED | prevented | possible | possible |
| REPEATABLE READ | prevented | prevented | possible |
| SERIALIZABLE | prevented | prevented | prevented |
Notice why REPEATABLE READ in the standard does not stop this: it protects rows T1 has already read, and row 900 did not exist when T1 first looked. The standard forbids phantoms only at SERIALIZABLE.
5How Real Databases Differ
The standard defines minimum guarantees, and real databases often give more. PostgreSQL never allows dirty reads: asking for READ UNCOMMITTED gives READ COMMITTED behaviour. Its REPEATABLE READ is implemented as snapshot isolation: the transaction reads from a snapshot taken at its first statement, so it sees neither changed values nor new rows from later commits, which is why the example above returns 7. PostgreSQL's REPEATABLE READ therefore shows no phantoms, even though the standard would allow them.
MySQL's InnoDB, whose default is REPEATABLE READ, also uses a snapshot for ordinary reads, so plain SELECTs do not see phantoms either. Locking reads such as SELECT ... FOR UPDATE read the latest committed rows and use next-key locks, which lock index ranges, so other transactions cannot insert into the range being read. SQL Server, by contrast, uses locking for its standard levels unless snapshot options are enabled. So when someone names an isolation level, the next question is always: in which database?
6What the Standard List Leaves Out
The three phenomena were defined when isolation was mostly implemented with locks, and the list turned out to be incomplete. A lost update, where two transactions read the same value and both write back a result based on it, so one change is lost, is not one of the three. Write skew, where two transactions read overlapping data and each updates a different row, together breaking a rule such as 'at least one doctor on call', is not either, and snapshot isolation allows it. Later research on isolation pointed this out and defined these anomalies, which is why 'REPEATABLE READ prevents the three phenomena' does not mean 'REPEATABLE READ is safe'.
7Follow-up questions
Which anomalies does snapshot isolation still allow?
Mainly write skew: two transactions read the same rows, each decides based on its snapshot, and each writes a different row, so a rule spanning those rows breaks. There is also a read-only anomaly, where a read-only transaction sees a state that no serial order could produce. PostgreSQL's REPEATABLE READ prevents lost updates on the same row, failing the second writer with a serialization error, but write skew needs SERIALIZABLE or explicit locking.
Which isolation level should a typical service use?
READ COMMITTED, the PostgreSQL default, is right for most work, combined with constraints and explicit locks such as SELECT ... FOR UPDATE where a decision depends on what was read. Use REPEATABLE READ for consistent multi-query reports, and SERIALIZABLE for rules across rows that are hard to lock, with retries on serialization failures.
Does MySQL's REPEATABLE READ prevent lost updates?
Not for plain reads followed by writes based on them. Two transactions can each read a balance from their snapshot and each write back a computed value, and InnoDB will apply both, losing one. Using SELECT ... FOR UPDATE, an atomic UPDATE such as balance = balance - 100, or SERIALIZABLE avoids it.
8Conclusion
In this answer, we saw that a dirty read uses another transaction's uncommitted change and is prevented from READ COMMITTED upward, a non-repeatable read sees a row change between two reads and is prevented from REPEATABLE READ upward, and a phantom read sees new rows in a repeated range query and is forbidden by the standard only at SERIALIZABLE. Real databases differ: PostgreSQL never allows dirty reads and its snapshot-based REPEATABLE READ shows no phantoms, and the standard's list misses anomalies such as lost update and write skew.
Open with
A dirty read is when my transaction reads a change another transaction made but has not committed. If that transaction rolls back, I acted on data that never existed.
Then, if they want more
READ COMMITTED is the first standard level that prevents it. A non-repeatable read is when I read the same row twice in one transaction and get different values, because another transaction updated it and committed in between, for example a balance of 100 and then 40. REPEATABLE READ is the first level that prevents that.
A phantom read is about ranges: I run the same query twice, say all orders with status NEW, and the second time I see rows another transaction inserted and committed. The standard still allows phantoms at REPEATABLE READ, because it only protects rows I already read, and forbids them only at SERIALIZABLE. Real databases differ from the standard, though.
PostgreSQL never allows dirty reads, even if you ask for READ UNCOMMITTED, and its REPEATABLE READ is snapshot isolation, so the whole transaction sees one snapshot and no phantoms. InnoDB uses snapshots for plain reads too, and next-key locks for locking reads.
And the standard list is incomplete: lost updates and write skew are not among the three phenomena, and snapshot isolation still allows write skew, which is why SERIALIZABLE or explicit locking is needed for rules that span several rows.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- PostgreSQL documentation, MySQL reference manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Define dirty reads, non-repeatable reads and phantom reads with a short example of each...": https://scrivio-interview-library.netlify.app/databases/acid-and-isolation/81a3655faf/