我有一张包含以下架构的表格......
CREATE TABLE [dbo].[Object1](
[id] [bigint] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[Column1] [datetime] NOT NULL,
[Column2] [int] NOT NULL,
[Column4] [char](4) NOT NULL,
[Column5] [money] NOT NULL,
[Column6] [bigint] NOT NULL,
[Column7] [char](6) NOT NULL,
[Column3] [bit] NOT NULL,
[Column8] [bigint] NULL,
CONSTRAINT [pk_Object1] PRIMARY KEY NONCLUSTERED
([id] ASC) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF
, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON))
GO
ALTER TABLE [dbo].[Object1] ADD CONSTRAINT [DF_Object1_Column1] DEFAULT (getutcdate()) FOR [Column1]
GO
ALTER TABLE [dbo].[Object1] ADD CONSTRAINT [DF_Object1_Column3] DEFAULT ((0)) FOR [Column3]
GO
每晚都会对此表运行删除查询...
delete from Object1
where ( Column1 < DATEADD(dd, -40, GETUTCDATE()) )
OR ( Column3 = ? and Column1 < DATEADD(dd, -3, GETUTCDATE()))
表格有
查询产生以下计划......
Execution Plan for Delete Statement
该语句导致高度并发的表中出现阻塞。阻塞会导致系统错误。
如果我重新创建“Object1_IX”以覆盖“Object1”字段,这仍然会发生。该表有6,568,449行,每晚修剪约200,000个。