码迷,mamicode.com
首页 > 其他好文 > 详细

设置 LOCK_ESCALATION (Lock升级)选项

时间:2015-12-12 18:52:01      阅读:307      评论:0      收藏:0      [点我收藏+]

标签:

如果对分区表配置锁升级选项设置为Auto(设置 Lock_Escalation 为 auto),那么对表加锁的最大粒度是Partition,这样能在一定程度上提高表的并发度,提高更新速度,甚至防止发生deadlock。

 

Syntax

ALTER TABLE [ schema_name . ] table_name 
SET ( LOCK_ESCALATION = { AUTO | TABLE | DISABLE } )

 

SET ( LOCK_ESCALATION = { AUTO | TABLE | DISABLE } )

Specifies the allowed methods of lock escalation for a table.

AUTO

This option allows SQL Server Database Engine to select the lock escalation granularity that is appropriate for the table schema.

  • If the table is partitioned, lock escalation will be allowed to partition. After the lock is escalated to the partition level, the lock will not be escalated later to TABLE granularity.

  • If the table is not partitioned, the lock escalation will be done to the TABLE granularity.

TABLE

Lock escalation will be done at table-level granularity regardless whether the table is partitioned or not partitioned. This behavior is the same as in SQL Server 2005. TABLE is the default value.

DISABLE

Prevents lock escalation in most cases. Table-level locks are not completely disallowed. For example, when you are scanning a table that has no clustered index under the serializable isolation level, Database Engine must take a table lock to protect data integrity.

Sample

Allowing lock escalation on partitioned tables

The following example enables lock escalation to the partition level on a partitioned table. If the table is not partitioned, lock escalation is to the TABLE level.

ALTER TABLE T1 SET (LOCK_ESCALATION = AUTO);


参照文档:

https://msdn.microsoft.com/en-us/library/ms190273(v=sql.105).aspx

 

设置 LOCK_ESCALATION (Lock升级)选项

标签:

原文地址:http://www.cnblogs.com/ljhdo/p/5041597.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!