Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Index, filtered or not

Author  Topic 

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-05-20 : 04:17:52
I should probably know this (and I have a suggestion) but I'm asking for second opinions.

I have this query: "select * from table where transferdate is null" where transferdate is a datetime column that gets populated after each row is transferred to another system. Data distribution is roughly 6 mill non-null values with one distinct value per day across a full year, and about 100k null rows.

How would you index this column? Standard non-unique, nonclustered index? Filtered in some way..?

- Lumbago
My blog-> http://thefirstsql.com/2011/02/07/regular-expressions-advanced-string-matching-and-new-split-function-sql-server-2008-r2/

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-05-20 : 05:36:01
Probably a filtered index.
But I would populate that column with 19000101 on insert then update so that it is not going from null to a value.
Then filter on 19000101.

Would need to test to see what happens - I never trust these new features but this does seem to work the few times I've used it.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -