Sample Exam Questions

From the objective of OSS-DB Exam Silver
S3.3 Transactions (Transaction isolation level (read committed, repeatable read, serializable))

Sample Question

3.56

When executing the following series of transactions, choose the expected transaction isolation level for (tx2) from the following options: Read uncommitted, Read committed, Repeatable read, Serializable.


(tx1) BEGIN;
(tx2) BEGIN;
(tx1) SELECT * FROM test;
       id
      ----
        1
(tx1) INSERT INTO test VALUES (2);
(tx2) SELECT * FROM test;
       id
      ----
        1
(tx1) UPDATE test SET id=3 WHERE id = 1;
(tx2) SELECT * FROM test;
       id
      ----
        1
(tx1) COMMIT;
(tx2) SELECT * FROM test;
       id
      ----
        2
        3

※This sample exam is different from those that appear in the actual OSS-DB Exam.
2024/05/10

Answer and Explanation

The weaker the isolation, the more advantageous it is in terms of performance; however, it becomes difficult to ensure consistency as transactions can affect each other. PostgreSQL uses Read committed by default.
In the execution results of the statement of this question, (tx2) does not use dirty reads, but does use non-repeatable reads and phantom reads.
Note that for each phenomenon, dirty reads can see the results of uncommitted insert/update/delete operations of another transaction, non-repeatable reads can see the results of committed update/delete operations of another transaction, and phantom reads can see the results of committed insert operations of another transaction.

Therefore, the correct answer is Read committed.