這是我的表的構造這個表,有一個最常用的查詢,如何建立良好的索引來提高速度
CREATE TABLE [dbo].[InterfaceMeraAdReport_CAV](
[ID] [int] IDENTITY(1,1) NOT NULL,
[reportID] [nvarchar](100) NOT NULL,
[FromTime] [nvarchar](100) NOT NULL,
[ToTime] [nvarchar](100) NOT NULL,
[Customer] [nvarchar](100) NOT NULL,
[Area] [nvarchar](100) NOT NULL,
[Vendor] [nvarchar](100) NOT NULL,
[SuccessCalls] [nvarchar](100) NOT NULL,
[TotalCalls] [nvarchar](100) NOT NULL,
[TotalMins] [nvarchar](100) NOT NULL,
[ASR] [nvarchar](100) NOT NULL,
[ACD] [nvarchar](100) NOT NULL,
[Fee] [nvarchar](100) NOT NULL,
[Cost] [nvarchar](100) NOT NULL,
[Profix] [nvarchar](100) NOT NULL,
CONSTRAINT [PK_MeraAdvReport_CA] 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]
和兩個主要用於查詢這種形式: 一個
select Customer,vendor,SUM(cast(SuccessCalls as int)) as successCalls,
SUM(cast(TotalCalls as int)) as TotalCalls,
SUM(cast(TotalMins as decimal(18,2))) as TotalMins,
case when SUM(cast(TotalCalls as decimal(18,2))) = 0 then 0.0 else (SUM(cast(SuccessCalls as decimal(18,2)))/SUM(cast(TotalCalls as decimal(18,2)))) end as ASR,
case when SUM(cast(SuccessCalls as decimal(18,2))) = 0 then 0.0 else (SUM(cast(TotalMins as decimal(18,2)))/SUM(cast(SuccessCalls as decimal(18,2)))) end as ACD,
SUM(cast(Profix as decimal(18,2))) as profix
from InterfaceMeraAdReport_CAV
where FromTime >= '20140128020000' and ToTime <= '20140128030000'
and Customer= '01.2136' and Area in ('62817','62818','62819','62859','62877','62878','62879')
group by Customer,Vendor
select Customer,SUM(cast(SuccessCalls as int)) as successCalls,
SUM(cast(TotalCalls as int)) as TotalCalls,
SUM(cast(TotalMins as decimal(18,2))) as TotalMins,
case when SUM(cast(TotalCalls as decimal(18,2))) = 0 then 0.0 else (SUM(cast(SuccessCalls as decimal(18,2)))/SUM(cast(TotalCalls as decimal(18,2)))) end as ASR,
case when SUM(cast(SuccessCalls as decimal(18,2))) = 0 then 0.0 else (SUM(cast(TotalMins as decimal(18,2)))/SUM(cast(SuccessCalls as decimal(18,2)))) end as ACD
from InterfaceMeraAdReport_CAV
where FromTime >= @timeFrom and ToTime <= @timeTo
and Customer= @customer and Area in ('62817','62818','62819','62859','62877','62878','62879')
group by Customer
此表增加了30多萬記錄的每一天,所以現在上面的查詢是來越來越慢,
我想創建索引來提高速度,但我不知道最有效的方式,有誰能夠告訴我哪些列將是最好的索引列