The information in this article applies to:
SUMMARYMore than 200 page locks held by a large insert transaction may not be promoted to a table lock if the transaction has a while loop. MORE INFORMATION
This behavior is as expected. Since the insert statements are inside a while loop each one is considered an individual statement with its own private session. Since the total number of locks are kept on a per session basis, this number is 1 for every session; thus, it never gets escalated to a table lock. SQL Server is designed for an OLTP environment where transactions are typified by a relatively small size, and the design point of SQL Server is to maximize concurrency for a typical OLTP query/transaction mix. To meet this goal, SQL Server uses page-level locking as its finest granularity and usually escalates to table locking at 200 page locks per SDES. SDES is the SQL Server session descriptor structure used to maintain session information. A session in this context is an active query from a process which affects a single object. Exceptions to this include some types of inserts, which for concurrency reasons retain page locks, and extent locks used in clustered index creation. The below example queries all escalate to a table lock:
Whereas this query does not escalate:
To avoid situations where too many page locks are being held by a transaction which has a while loop or separate insert statements, break the transaction into smaller ones, or increase the lock configuration number. Page locks held by a bcp process are not escalated to table lock either. If that is a problem, the transaction should be broken down into smaller batches. Additional query words: 4.2930824 Windows NT
Keywords : kbprg SSrvProg SSrvWinNT |
Last Reviewed: March 18, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |