Locking terminology: Is the “lock granularity” the size or scope of the lock (for example, row-level vs. page-level vs. table-level)?
-
ACorrect
-
BIncorrect
-
COnly applies to shared locks
-
DOnly applies to exclusive locks
Answer
Correct Answer: Correct
Explanation
Introduction / Context:Locking granularity affects concurrency and overhead. Finer granularity (row) increases concurrency but may require more locks; coarser granularity (table) reduces overhead but can block more operations. This question checks the definition of “lock granularity.”
Given Data / Assumptions:
- Various resources can be locked: rows, keys, pages/blocks, partitions, or entire tables.
- Lock types (shared, exclusive, intent) are orthogonal to granularity.
- Granularity influences contention and performance.
Concept / Approach:“Granularity” literally describes the size or scope of a lockable unit. Databases often support hierarchical locking with intent locks to combine coarse and fine-grained locks safely. Tuning granularity is a trade-off between throughput and overhead.
Step-by-Step Solution:
Recognize possible lock scopes: row, page, table.Relate “granularity” to these scopes.Conclude that lock granularity is the size/scope of the locked resource.Verification / Alternative check:Examine DBMS documentation for lock modes and levels; they explicitly refer to lock levels as granularity choices.
Why Other Options Are Wrong:
- Granularity is not limited to shared or exclusive locks; it applies to both.
- “Incorrect” conflicts with standard terminology.
Common Pitfalls:Assuming finer granularity is always better. More locks mean more overhead and potential deadlock complexity.
Final Answer:Correct