Lock escalation occurs when a transaction is holding many locks on rows and the lock heap is getting tight, i.e. it can't hold much more locks. At that point, DB2 figures that it is better to grab a lock on the table and release all the row locks. Since each lock requires some memory (about 40-80 bytes), DB2 can potentially free up a lot of memory that way in the lock heap. This process is called lock escalation.
The advantage is less pressure on the lock heap and, with fewer locks being held, the check whether a row is locked can be done faster too. The disadvantage is that the table lock is on a coarser granularity, meaning that concurrency is reduced - if lock escalation occurs for write-operations, the impact can be dramatic because the whole table is essentially blocked for all other transactions. Another issue is that lock escalation needs some time, which slows down the transaction in who's context the escalation is done. That may not be acceptable for all transactions.
Thus, you have a few options:
- increase the size of the lock heap to have more memory available in general
- use the LOCK TABLE statement in your applications to grab a table lock right away instead of waiting for the lock escalation
- commit more ofter in your application to release locks earlier and, thus, reduce the pressure on the lock heap