Does SQL Server Index Null Values in a Non-Clustered Non-Unique index?

前端 未结 1 1092
失恋的感觉
失恋的感觉 2020-12-18 18:25

I am considering adding a column to a database table, and that column will be null possibly for most rows however I do want to be able to query on that column for particular

相关标签:
1条回答
  • 2020-12-18 19:20

    I would suggest a filtered index, such as WHERE column IS NOT NULL; - this will allow you to create an index that only bothers to index the non-NULL values, and ignores all of the rows with no value. You'll probably want to make sure the index covers the queries you want to run with this type of predicate, so that you don't have to go back into the whole table to lookup the other columns the query needs to output (or use in a join, or otherwise filter, etc).

    More details here.

    0 讨论(0)
提交回复
热议问题