CS FundamentalsVery hardProduct company interview · GATE level

Multiple Granularity Locking uses intention locks (IS, IX, SIX) on coarser objects like a table, in addition to ordinary shared/exclusive locks on rows. Why does a transaction take an IX lock on a table before taking an X lock on one of its rows?

  1. A. IX locks are always acquired automatically and transparently with no protocol needed
  2. B. It replaces the need for a row-level lock entirely
  3. C. IX locks have no real purpose beyond documentation
  4. D. It signals to other transactions trying to lock the WHOLE table that a finer-grained lock exists somewhere underneath, so a conflicting table-level request (e.g. another transaction's S or X lock on the whole table) can be correctly blocked without needing to check every individual row

Correct answer: D. It signals to other transactions trying to lock the WHOLE table that a finer-grained lock exists somewhere underneath, so a conflicting table-level request (e.g. another transaction's S or X lock on the whole table) can be correctly blocked without needing to check every individual row

Without intention locks, a transaction wanting to lock an entire table (say, for a table scan with S, or a schema change with X) would have to check every single row for conflicting locks, which is expensive. An IX lock at the table level makes that table-level check cheap: a table-level S/X request simply checks whether any intention locks are present and defers if so, rather than scanning row-by-row.

More DBMS and SQL questions

Exams that ask this topic