Will looking up a null-able column in oracle 9i suppress the column's index?
According to Oracle 9i performance tuning tips and techniques, using IS NULL
开发者_高级运维 or IS NOT NULL
will suppress the index of the column - if there is an index on the column, and recommends making the column not null-able and using a DEFAULT
.
The question is, will a null-able column suppress an index even if my select query does not use IS NULL
or IS NOT NULL
explicitly?
For a general query, the fact that a column is nullable won't prevent the optimizer or query engine from using an index unless the criterion on the column is IS NULL
or IS NOT NULL
. So, a general WHERE column = somevalue
query will use the index if that is appropriate.
The situation where the (nullable) column is one of several columns in the index is less clear. In the absence of concrete information to the contrary, I'd assume that the index will be used if there are criteria on the other columns in the index, possibly even with an IS [NOT] NULL
criterion on the nullable column. It might depend on whether or not the nullable column is the lead column for the index.
精彩评论