在下面的查询(查询从 c# 应用程序运行)中给出长时间的 DateTime 时,我遇到了超时问题。表有 3000 万行,在 ID(不是主键)上有一个非聚集索引。
发现没有主键,所以我最近将 ID 更新为主键,现在它没有给我超时。谁能帮我在下面的查询中为将来创建多个键的索引,以及如果我从该表中删除非聚集索引并在多个列上创建索引?数据增长迅速,性能需要改进
select
ID, ReferenceNo, MinNo, DateTime, DataNo from tbl1
where
DateTime BETWEEN '04/09/2013' AND '20/11/2013'
and ReferenceNo = 4 and MinNo = 3 and DataNo = 14 Order by ID
这是创建脚本
CREATE TABLE [dbo].[tbl1]( [ID] [int] IDENTITY(1,1) not null, [ReferenceNo] [int] not null, [MinNo] [int] not null, [DateTime] [datetime] not null, [DataNo] [int] not null, CONSTRAINT [tbl1_pk] PRIMARY KEY CLUSTERED ([ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS
= ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY]