1.创建测试表及谓词条件中包含is null模拟语句
create table t641 as select * from dba_objects;
set autot trace
select SUBOBJECT_NAME,OBJECT_NAME from t641 where OBJECT_NAME='WRI$_OPTSTAT_SYNOPSIS$' and SUBOBJECT_NAME is null;
2.全表扫描逻辑读1237
3.创建等值谓词条件的单列索引
create index idx_t641_01 on t641(object_name) online;
OBJECT_NAME字段索引范围范围,回表过滤SUBOBJECT_NAME is null,逻辑读7
3.创建复合索引,包含SUBOBJECT_NAME is null条件字段
create index idx_t641_02 on t641(object_name,SUBOBJECT_NAME) online;
索引范围扫描,无需回表过滤,逻辑读4
注意,null字段在索引第一列,也能使用到索引,但需要索引扫描后走filter,null不参与排序。