Bird
0
0

You want a transaction under Read Committed isolation to execute multiple queries without seeing changes committed by other transactions between them. Which method achieves this?

hard📝 Application Q8 of 15
PostgreSQL - Transactions and Concurrency
You want a transaction under Read Committed isolation to execute multiple queries without seeing changes committed by other transactions between them. Which method achieves this?
ADisable autocommit mode globally
BSet the isolation level to Read Uncommitted for the transaction
CRun each query in a separate transaction
DUse explicit locking (e.g., SELECT ... FOR SHARE) to prevent concurrent modifications
Step-by-Step Solution
Solution:
  1. Step 1: Understand Read Committed limitations

    Read Committed allows different queries to see different snapshots, so changes committed between queries are visible.
  2. Step 2: Prevent changes between queries

    Explicit locking (e.g., SELECT ... FOR SHARE or FOR UPDATE) can lock rows to prevent concurrent commits affecting them.
  3. Step 3: Evaluate other options

    Read Uncommitted is not supported in PostgreSQL; separate transactions or disabling autocommit do not solve the problem.
  4. Final Answer:

    Use explicit locking (e.g., SELECT ... FOR SHARE) to prevent concurrent modifications -> Option D
  5. Quick Check:

    Explicit locks prevent concurrent changes [OK]
Quick Trick: Use explicit locks to prevent mid-transaction changes [OK]
Common Mistakes:
  • Assuming Read Uncommitted exists in PostgreSQL
  • Thinking separate transactions isolate queries
  • Believing disabling autocommit affects isolation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes