13. Understanding the Locking System : Ways to Avoid Lock Delays
 
Share this page                  
Ways to Avoid Lock Delays
There are several approaches to prevent delays due to lock waits:
Keep transactions as short as possible.
SET LOCKMODE…READLOCK=NOLOCK, but be aware that "dirty reads" can occur.
Use SET LOCKMODE...TIMEOUT=n to indicate how long to wait for a lock. The default (0) is to wait forever. If timeout occurs, an error is returned, which must be checked for in the application, and the current statement (not the transaction) is aborted.
For details on the SET LOCKMODE statement, see User-Controlled Locking (see page User-Controlled Locking--SET LOCKMODE).