Previous Topic: Lock Avoidance StrategiesNext Topic: How Optimistic Locking Works


Optimistic Locking

With the high demands for full database availability, as well as high transaction rates and levels of concurrency, reducing database locks is always vitally important. To address this need, many applications employ a technique called optimistic locking to achieve these higher levels of availability and concurrency. This technique traditionally involves reading data with an uncommitted read or with cursor stability. Updated timestamps are maintained in all of the data tables. This updated timestamp is read along with all the other data in a row.

When a direct update is subsequently performed on the row that was selected, the timestamp is used to verify that no other application or user has changed the data between the point of the read and the update. This practice places additional responsibility on the application to use the timestamp on all updates, but the result is a higher level of DB2 performance and concurrency.