开发者

Can I index the existence of a value in a column (whether it is null or not)?

开发者 https://www.devze.com 2023-02-13 04:19 出处:网络
I have a varch开发者_开发百科ar(999) column that I want to select only when it is not NULL. Is there an efficient way to check whether a row has NULL value or not without indexing all the possible va

I have a varch开发者_开发百科ar(999) column that I want to select only when it is not NULL.

Is there an efficient way to check whether a row has NULL value or not without indexing all the possible values for this column?


Well, the WHERE col IS NOT NULL may use the NULL bitmap but it's a clustered index scan.

Or you just index the column and take the hit. Or use an indexed view with the IS NOT NULL filter.

Unfortunately, this isn't resolved elegantly until "filtered indexes" SQL Server 2008

0

精彩评论

暂无评论...
验证码 换一张
取 消