CS FundamentalsVery hardGATE CS (PYQ pattern)
Snapshot isolation with first-committer-wins: a transaction aborts at commit time if some other transaction that committed after it started (and before its own commit) wrote an item it also wrote. Transactions (start time, commit attempt time, write set): T1 (1, 5, {A}), T2 (2, 6, {B}), T3 (3, 7, {A, C}), T4 (6, 8, {C}), T5 (4, 9, {B}). Which transactions abort?
- A. T3 and T5
- B. T3, T4 and T5
- C. T3 only
- D. T5 only
Correct answer: A. T3 and T5
In commit order: T1 commits (5); T2 commits (6). T3 started at 3 and T1 committed A at 5, so T3 aborts. T4 started at 6; the only other writer of C was T3, which aborted, so T4 commits. T5 started at 4 and T2 committed B at 6, so T5 aborts. T4 would wrongly abort if the aborted T3's write were counted.
More DBMS and SQL questions
- In a wait-for graph over transactions T1..T7 the edges (Ti waits for Tj) are T1→T2, T2→T3, T3→T1, T3→T4, T4→T5, T5→T4, T6→T3, T2→T7…
- Under strict two-phase locking (shared locks for reads, exclusive for writes, all locks held until commit; a transaction whose lock…
- A B+ tree has leaf nodes holding at most 3 keys. Keys are inserted in the order 50, 20, 80, 10, 30, 60, 90, 70, 40, 25, 35, 5, 65, 75, 95…
- A query joins 5 relations R1..R5 and the optimiser considers every possible join tree, including bushy trees, with every distinct…
- R occupies 1000 pages with 100 tuples per page. S has a B+ tree index on the join attribute (3 levels, so 3 page reads to reach a leaf…
- A table has 100,000 rows in 2500 pages, and a predicate selects 3% of the rows, which are spread uniformly at random over the pages. An…