It deals with the cost of implementing locks depending upon the space and time. Here, space refers to data structure in DBMS for each lock and time refers to handling of lock request and release.
The cost of implementing locks depends on the size of data items. There are two types of lock granularity:
• Fine granularity
• Coarse granularity
Fine granularity refers for small item sizes and coarse granularity refers for large item Sizes.
Here, Sizes decides on the basis:
• a database record
• a field value of a database record
• a disk block
• a whole file
• the whole database
If a typical transaction accesses a small number of records it is advantageous that the data item granularity is one record. If a transaction typically accesses many records of the same file it is better to have block or file granularity so that the transaction will consider all those records as one data item.
A too-fine granularity will increase the frequency of locks requests and locks releases, which therefore will add additional instructions. You must locate a balance between a too-fine and too-coarse granularity. The figure shows the relation between the throughput and the granularity of locks.
This illustration is a simple two axis chart. The vertical, or y axis, represents throughput.
The horizontal, or x axis, represents granularity going from fine to coarse as it moves out on the scale. An elongated bell curve shows the relationship of granularity on throughput. As granularity goes from fine to coarse, throughput gradually increases to a maximum level and, then slowly starts to decline. It shows that a compromise in granularity is necessary to reach maximum throughput.