SQL Performance (MOSC)

MOSC Banner

Use index with a OR

edited May 30, 2017 12:11PM in SQL Performance (MOSC) 7 commentsAnswered ✓

Hi,

Here is the test case :

create table test1(c1 number, c2 varchar2(30),c3 number,c4 varchar2(30));

insert into test1 values(1,'test1',11,'');

insert into test1 values(2,'test2',22,'t2');

insert into test1 values(3,'test3',33,'');

insert into test1 values(4,'test4',44,'t4');

insert into test1 values(5,'test5',55,'');

insert into test1 values(6,'test6',66,'');

insert into test1 values(7,'test7',77,'t7');

insert into test1 values(8,'test8',88,'');

commit;

create index test1_c4_idx on test1(c4);

exec dbms_stats.gather_table_stats(ownname=>'USERA',tabname=>'TEST1',cascade=>true);

select * from test1 where (c4=:test or :test is null);

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center