Disabling lock escalation for SQL Server

Source: Internet
Author: User

Lock Escalation
Related to the number of locks and memory pressure, after the threshold is reached, upgrade directly to table lock without minor upgrade to page lock

There are several ways to reduce lock escalation:

    • Disabling lock escalation for SQL Server instances
    • Disabling lock escalation for a specific table
    • Increase the valve value, reduce the possibility of lock escalation (sp_configure ' locks ', 10000; RECONFIGURE;)
    • Enable row versioning

Disabling lock escalation for a DB instance

In SQL Server 2005, you can use trace flag 1211, 1224来 to disable lock escalation throughout the instance.

    • Flag 1211-Lock escalation is completely forbidden, but the memory used by the lock is limited to 60% of the dynamically allocated memory, and when this value is exceeded, more locks will fail with a memory overflow error.
    • Flag 1224-Lock escalation is forbidden, but memory usage exceeds 40% automatically
    • If the flag 1211 and 1224 trace flags are set at the same time, only the flag 1211 will take effect.

Prohibit lock escalation for specific tables

In SQL Server 2008 and later versions, you can use the new selection to disable lock escalation for a table

ALTER TABLE SET (lock_ecalation = AUTO | TABLE | DISABLE)

    • Table: Upgrade directly from row lock to table lock (this is the default value)
    • AUTO: If a table partition exists, it is promoted to a partition lock, but not further upgraded.
    • DISABLE: Disabling lock escalation does not mean that table locks are disabled (table locks are also required for operations such as table scans when serializing isolation levels)

About Rowlock

A lot of information on the web mentions that using Rowlock in a statement can force the use of row locks, but the actual test finds no effect.

Check data display: Use locking hints such as rowlock only change the initial lock plan. Lock hints do not prevent lock escalation.

Using a lock hint such as Rowlock only alters the initial lock plan. Lock hints do not prevent lock escalation.

Https://msdn.microsoft.com/zh-cn/library/ms184286.aspx

https://support.microsoft.com/zh-cn/kb/323630

Disabling lock escalation for SQL Server

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.