Bird
0
0

In PostgreSQL, when using Read Committed isolation, what happens if a query reads a row that another transaction is currently updating but not yet committed?

easy📝 Conceptual Q2 of 15
PostgreSQL - Transactions and Concurrency
In PostgreSQL, when using Read Committed isolation, what happens if a query reads a row that another transaction is currently updating but not yet committed?
AThe query reads the committed data immediately.
BThe query waits until the other transaction commits or rolls back.
CThe query skips the row and continues.
DThe query returns an error.
Step-by-Step Solution
Solution:
  1. Step 1: Understand MVCC behavior in Read Committed

    PostgreSQL uses MVCC; SELECT queries read the latest committed version without blocking on exclusive locks held by updating transactions.
  2. Step 2: Evaluate options

    The query reads the committed data immediately. is correct. The query waits until the other transaction commits or rolls back. is incorrect because plain SELECT does not acquire locks or wait. Options C and D do not describe PostgreSQL behavior.
  3. Final Answer:

    The query reads the committed data immediately. -> Option A
  4. Quick Check:

    Read Committed SELECT reads committed data without waiting [OK]
Quick Trick: Plain SELECT does not wait for UPDATE locks in PostgreSQL [OK]
Common Mistakes:
  • Thinking SELECT waits for locks
  • Assuming dirty reads are allowed
  • Thinking queries skip locked rows

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes