Granularity locking Explanation, How does granularity affect the performance

Granularity is the size of data items that are allowed to lock.

There are three types of lock granularity

  1. Course granularity: It is used to lock tables, files, databases, and records. It reduces the transaction number and decreases the throughput to increase the response time of the transaction. But this also causes the concurrency to get reduced.
  2. Fine granularity: It locks the records and fields to provide high concurrency and throughput. But it leads to very high overhead and low response time.
  3. Intermediate granularity: It locks equal and fixed-size pages that contain a few rows and columns of one or more tables of the database.

Granularity increases the throughput of the system, decreases the overhead, increases the concurrency and also enhance the efficiency of the system.