Oracle 10g - optimize WHERE IS NOT NULL

后端 未结 9 1848
长情又很酷
长情又很酷 2020-12-13 20:56

We have Oracle 10g and we need to query 1 table (no joins) and filter out rows where 1 of the columns is null. When we do this - WHERE OurColumn IS NOT NULL - we get a full

9条回答
  •  星月不相逢
    2020-12-13 21:11

    It can depend on the type of index you have on the table.

    Most B-tree indexes do not store null entries. Bitmap indexes do store null entries.

    So, if you have:

    select * from mytable where mycolumn is null

    and you have a standard B-tree index on mycolumn, then the query can't use the index as the "null" isn't in the index.

    (If the index is against multiple columns, and one of the indexed columns is not null then there will be an entry in the index.)

提交回复
热议问题