组合主键、聚集索引引发的死锁问题,还是索引字段顺序、选择性的问题,切记。
-- SPID: 61 exec sp_executesql N'DELETE FROM SYLOCKAID WHERE MKID=@param0 AND DATACAT=@param1 AND DATAID=@param2',N'@param0 varchar(max) ,@param1 varchar(max) ,@param2 varchar(max) ',@param0='JCSF',@param1='JZSF_TD_YSZXZJB',@param2='201504cbb52e-9cfb-46d1-b2dd-c18a54f2db8501' -- SPID: 69 exec sp_executesql N'DELETE FROM SYLOCKAID WHERE MKID=@param0 AND DATACAT=@param1 AND DATAID=@param2',N'@param0 varchar(max) ,@param1 varchar(max) ,@param2 varchar(max) ',@param0='JCSF',@param1='JZSF_TD_YSZXZJB',@param2='201502aa91d5-12e3-40b1-acd1-9c63109a36bc01'
sp_helpindex sylockaid; index_name index_description index_keys PK_SYLOCKAID clustered, unique, primary key located on PRIMARY MKID, DATACAT, DATAID
-- 调整索引字段顺序后,问题解决 alter table sylockaid drop constraint PK_SYLOCKAID; alter table sylockaid add constraint PK_SYLOCKAID primary key clustered(DATAID, MKID, DATACAT);