Question 3 · Section 11

What is Read Uncommitted?

Imagine the scenario: 4. Transaction B operated on non-existent data (500)

Language versions: English Russian Ukrainian

🟢 Junior Level

Read Uncommitted is the lowest transaction isolation level. At this level, one transaction can see changes made by another transaction even if it has not yet completed (no COMMIT has been issued).

The Main Problem — Dirty Read

Imagine the scenario:

  1. Transaction A changed the balance from 100 to 500
  2. Transaction B read the balance and sees 500
  3. Transaction A was rolled back (ROLLBACK) — balance reverted to 100
  4. Transaction B operated on non-existent data (500)

When It Is Used

Almost never in real applications. Sometimes for quick approximate statistics when accuracy doesn’t matter.

Important Note

In PostgreSQL and Oracle, this level effectively doesn’t exist — if you set it, the database automatically switches you to Read Committed.


🟡 Middle Level

Key Characteristics

  • Anomalies: Allows all three — Dirty Read, Non-repeatable Read, Phantom Read
  • Performance: Theoretically the fastest level since there’s no isolation overhead
  • Locks: Reading is not blocked by writing, writing is not blocked by reading

Dirty Read Scenario in Detail

Time    Transaction A              Transaction B (Read Uncommitted)
T1       BEGIN;
T2       UPDATE accounts SET
         balance = 500 WHERE id = 1;
T3                                    SELECT balance FROM accounts
                                      WHERE id = 1; -- Sees 500!
T4       ROLLBACK;
T5                                    Works with balance 500,
                                      but it's actually 100

Why does B see 500? On Read Uncommitted, the DBMS doesn’t create a snapshot. Reading goes directly from the current row version, even if the authoring transaction hasn’t committed yet.

Why This Is Dangerous

  • Finance: Credit decisions based on an unconfirmed balance
  • Warehouses: Reserving goods that haven’t arrived yet
  • Integrity: You can see data that violates constraints (e.g., negative balance that will be rolled back)

SQL Server NOLOCK

In SQL Server, the hint WITH (NOLOCK) is often used in SELECT queries at this level:

SELECT * FROM accounts WITH (NOLOCK);

This allows reading data without acquiring shared locks, giving the same semantics as Read Uncommitted.

Features in PostgreSQL and Oracle

PostgreSQL: The Read Uncommitted level is physically absent. The command SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED silently switches to Read Committed.

Oracle: Also doesn’t allow going below Read Committed. Architecturally guarantees no dirty reads.


🔴 Senior Level

Why Read Uncommitted Is Practically Unused

Architecture Perspective

In modern MVCC-based systems (PostgreSQL, Oracle), dirty read prevention is built in at the architectural level:

  • Readers always see committed versions only
  • Uncommitted changes create new tuple versions not visible to others
  • No additional overhead to prevent dirty reads — it’s free

When Read Uncommitted Might Be Acceptable

  1. Approximate analytics: “Roughly how many orders today?” — 1-2% accuracy is not critical
  2. Health checks / monitoring: Quick status check without accuracy guarantees
  3. Development/debugging: Temporary use for investigation

Hidden Costs of Read Uncommitted

Despite the lack of isolation overhead:

  • Data corruption risk: Application logic may make decisions based on phantom data
  • Cascading errors: Wrong data → wrong decisions → more wrong data
  • Debugging nightmare: Intermittent bugs, hard to reproduce

Implementation Details in Different DBMS

SQL Server:

  • Read Uncommitted = NOLOCK = reading without shared locks
  • Can read “in-flight” data from uncommitted pages
  • Risk of allocation order scans missing/miscounting rows

PostgreSQL:

  • Automatic elevation to Read Committed
  • On Read Committed: each operator sees a snapshot at the start of the operator
  • Zero overhead for dirty read prevention thanks to MVCC

MySQL/InnoDB:

  • Supports Read Uncommitted literally
  • But the undo log still stores committed versions
  • Minor overhead savings vs Read Committed

Production Recommendation

In most production systems, Read Uncommitted is not needed. Exceptions: approximate dashboards (charts with acceptable margin of error), internal monitoring tools.

Alternative Approaches

Instead of Read Uncommitted for performance:

  1. Read Committed with query optimization: Proper indexes give a bigger gain
  2. Read replicas: Offload reporting queries to a replica
  3. Materialized views: Pre-computed aggregates
  4. Caching layer: Redis/Memcached for approximate data

🎯 Interview Cheat Sheet

Must know:

  • Read Uncommitted — the lowest isolation level, allows all 3 anomalies
  • Main problem — Dirty Read: reading uncommitted data that may be rolled back
  • In PostgreSQL and Oracle, this level doesn’t exist — automatic elevation to Read Committed
  • Almost never used in production, except for approximate analytics and monitoring
  • SQL Server uses the hint WITH (NOLOCK) for dirty reads
  • Dirty read is especially dangerous: decisions are made based on data that “never existed”

Common follow-up questions:

  • Why doesn’t PostgreSQL support Read Uncommitted? — MVCC architecture: dirty read prevention is free
  • When is Read Uncommitted acceptable? — Approximate dashboards, health checks, development/debugging
  • What does a transaction see on Read Uncommitted? — Uncommitted changes from other transactions
  • How does Read Uncommitted differ from Read Committed? — RC doesn’t allow dirty reads

Red flags (DO NOT say):

  • “Read Uncommitted is faster than Read Committed” — no difference in MVCC systems
  • “Can be used for financial reports” — unacceptable risk of corrupted data
  • “NOLOCK = a safe way to read” — NOLOCK can read duplicates and skip rows

Related topics:

  • [[2. What transaction isolation levels exist]]
  • [[7. What is Dirty Read]]
  • [[4. What is Read Committed]]