(8.0.29)
drop table tab1;
create table tab1(col1 int not null, col2 int);
insert into tab1 values(1,1);
select * from tab1;
analyze table tab1;
explain analyze
select * from tab1 where ifnull(col1,0) != 0 and ifnull(col2,0) != 0;
→NOT NULLカラムへのifnullは除去されない
(19c)
drop table tab1 purge;
create table tab1(col1 int not null, col2 int);
insert into tab1 values(1,1);
commit;
select * from tab1;
exec dbms_stats.gather_table_stats(user,'TAB1');
explain plan for
select * from tab1 where nvl(col1,0) != 0 and nvl(col2,0) != 0;
select * from table(dbms_xplan.display(format=>'ALL') );
→NOT NULLカラムへのnvlは除去される
(14)
drop table tab1;
create table tab1(col1 int not null, col2 int);
insert into tab1 values(1,1);
select * from tab1;
analyze tab1;
explain analyze
select * from tab1 where coalesce(col1,0) != 0 and coalesce(col2,0) != 0;
→NOT NULLカラムへのcoalesceは除去されない
(2019)
drop table tab1;
create table tab1(col1 int not null, col2 int);
insert into tab1 values(1,1);
select * from tab1;
update statistics tab1;
set showplan_all on
go
select * from tab1 where isnull(col1,0) != 0 and isnull(col2,0) != 0;
→NOT NULLカラムへのisnullは除去される