English 中文(简体)
2008年服务器——填充指数
原标题:SQL Server 2008 - Filtered Indexes

我的指数如下:

CREATE NONCLUSTERED INDEX [IX_Marker] ON [dbo].[Marker] 
(
    [Run] ASC,
    [EquipmentID] ASC,
    [ReadTime] DESC
)
INCLUDE ( [Sequence]) 
WHERE ([ReadTime]> 07/01/2011 )

在什么情况下,SQ服务器机能选择这一指数? 例如,我要问:

Select * From Marker Where ReadTime >  3/1/2011 

I assume the index wouldn t be used in this case? But if I changed the Where clause to 8/1/2011 , it would get used?

最佳回答

该指数包括查询所需记录的superset,而不是subset

如果KNOWS或SUSPECTS的发动机认为该指数排除了在设定结果中可能需要的记录,那么该指数就赢得了使用。

问题回答

此外,仅是谨慎之词——只有在条款日期价值难以编码的情况下才能使用你的过滤指数。 如果您在条款中使用参数(或分化点或SP),则不能使用过滤指数。

So if you have:

declare @d date =  8/1/2011 
Select * From Marker Where ReadTime > @d

在上述情况下,将不使用过滤指数。





相关问题
Performance impact of indexed view in MS SQL Server 2008

Does anyone have experience with using indexed view in MS SQL Server 2008? I am trying to find out how does indexed view affect performance of insert / update statements, that are adding / updating ...

Lock Escalation - What s happening here?

While altering a table (removing a column) in SQL Server 2008, I clicked the Generate Change Script button and I noticed that the change script it generated drops the column, says "go" and then runs ...

Round to nearest 5 in SQL Server

I have a Money column in my SQL Server 2008 table. In my below query how can I round it to nearest 5$ select FineAmount from tickets Thanks

热门标签