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?
- A. IX locks are always acquired automatically and transparently with no protocol needed
- B. It replaces the need for a row-level lock entirely
- C. IX locks have no real purpose beyond documentation
- 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
- A foreign key column is declared ON DELETE CASCADE. If the referenced (parent) row is deleted, what happens to the child rows referencing…
- A schema uses salary DECIMAL(8,2) for a salary column. Which value would be REJECTED when inserted?
- A column is declared VARCHAR(10) vs. CHAR(10). For a value like 'cat' (3 characters), which statement is correct about storage and…
- A query planner chooses a full table scan over using an available index on a WHERE column. Which scenario makes this the RIGHT choice, not…
- Which statement about a query execution plan using a hash join versus a nested-loop join is correct?
- A sort-merge join requires both input relations to be sorted on the join key (or sorted as part of the plan). When is sort-merge join…