Can filtered indexes help improve queries that are based on a time entered or should this be avoided?

dba.stackexchange https://dba.stackexchange.com/questions/447

문제

I'm just learning about the new filtered indexes in MS SQL 2008 and I'm trying to understand where they would hurt and where they would help.

I can see that adding a filtered index to an employees table to index only the current employees would be a good idea.

But what about applying a couple filtered indexes to a large table based on time. For example, say I have a table that has an enteredOn date/time field and the table has many years worth of data. If queries are typically done based on date and some other field such as enteredby would it be good to have a few filtered indexes that have a where clause limiting the index to a timespan? In my example the query would be something like

select enteredOn, Description, ...
from myTable
where enteredOn > '2011/01/01' and enteredBy = "My, User"

Would having an filtered index for each year be reasonable or would that cause to much of a problem when the below was queried for instead?

select enteredOn, Description, ...
from myTable
where enteredOn > '2009/06/01' and eneteredOn < '2010/06/01' and enteredBy = "My, User"
도움이 되었습니까?

해결책

BitOff,

It depends on a few factors, there is no one answer for every scenario. For example, you may want to partition and archive some old data onto a dedicated set of disks becvause it is accessed infrequently. I doubt you would consider swapping such a partition for a filtered index. And I doubt you want to create a partition for all the values of NULL in a specific column as opposed to using a filtered index.

You should read the partitioning whitepaper by Kimberley Tripp at http://msdn.microsoft.com/en-us/library/ms345146%28v=sql.90%29.aspx, and the filtered index design guidelines found at http://technet.microsoft.com/en-us/library/cc280372.aspx.

Those two links should help point you in the right direction as far as all the design considerations you need to take into account.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 dba.stackexchange
scroll top