The lock table command allows you to explicitly request that before a table is accessed, a table lock be put on it for the duration of a transaction. This is useful when an immediate table lock may reduce the overhead of acquiring a large number of row or page locks and save locking time. Examples of such cases are:
A table will be scanned more than once in the same transaction, and each scan may need to acquire many page or row locks.
A scan will exceed a table’s lock-promotion threshold and will therefore attempt to escalate to a table lock.
If a table lock is not explicitly requested, a scan acquires page or row locks until it reaches the table’s lock promotion threshold (see the system procedure sp_setpglockpromote, in the Reference Manual), at which point it tries to acquire a table lock.
Copyright © 2005. Sybase Inc. All rights reserved. |