Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (6.28 KB, 3 trang )
Avoiding Locking Scenarios
• Best Practices – Application
– Use least restrictive isolation level that maintains the data integrity
requirements of the application
– Reduce Isolation level of specific statements by using statement level
isolation (i.e., WITH clause)
– CLOSE cursors WITH RELEASE to free locks prior to end of
transaction
– Perform updates as close to the end of the transaction as possible, to
reduce exclusive lock duration
– COMMIT frequently to release locks
– Avoid multiple applications accessing the same tables, but acquiring
locks in different orders (Access patterns should be similar)
– Avoid having multiple processes that access the same table for both
reads and writes within the same transaction
Avoiding Locking Scenarios
• Best Practices – Database
– Avoid lock escalations by increasing DB CFG parameters
LOCKLIST and/or MAXLOCKS
– Avoid lock timeouts:
• Adjust the DB CFG parameter LOCKTIMEOUT or use the SET
CURRENT LOCK TIMEOUT command
– Avoid deadlocks:
• Reduce row blocking during index and table scans:
– DB2_SKIPINSERTED to skip/ignore uncommitted inserted rows
– DB2_SKIPDELETED to skip/ignore uncommitted deleted rows
– DB2_EVALUNCOMMITTED to defer locking until row is known to
satisfy query. Uncommitted data will be evaluated. Skips deleted rows
on table scans.
More Useful Registry Variables for
Locking