Bird
0
0

You want to ensure that two concurrent transactions in PostgreSQL never see inconsistent data and avoid phantom reads. Which isolation level should you choose and why?

hard📝 Application Q15 of 15
PostgreSQL - Transactions and Concurrency
You want to ensure that two concurrent transactions in PostgreSQL never see inconsistent data and avoid phantom reads. Which isolation level should you choose and why?
AREAD UNCOMMITTED, because it allows maximum concurrency
BREPEATABLE READ, because it prevents non-repeatable reads but allows phantoms
CREAD COMMITTED, because it is fastest and avoids dirty reads
DSERIALIZABLE, because it fully isolates transactions preventing phantoms
Step-by-Step Solution
Solution:
  1. Step 1: Understand phantom reads and isolation levels

    Phantom reads occur when new rows appear in repeated queries within a transaction.
  2. Step 2: Match isolation level to requirement

    SERIALIZABLE prevents phantom reads by fully isolating transactions, ensuring consistency.
  3. Final Answer:

    SERIALIZABLE, because it fully isolates transactions preventing phantoms -> Option D
  4. Quick Check:

    SERIALIZABLE = no phantoms, full isolation [OK]
Quick Trick: Use SERIALIZABLE to prevent phantom reads fully [OK]
Common Mistakes:
  • Choosing REPEATABLE READ and expecting no phantoms
  • Thinking READ COMMITTED prevents phantoms
  • Confusing READ UNCOMMITTED as safe option

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes