Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force oracle to not to use an index

I have a requirement in which i have to force the sql not to use a particular index which exists on a table.

for example,

create table t1(id varhcar2(10),data1 varchar2(3000));
create table t2(id varhcar2(10),data2 varchar2(3000));

create index id1 on t1(id);

select * from t1,t2 where t1.id=t2.id;

I cannot drop the index id1 and neither drop it as i dont have rights on it. therefore i want to add some kind of hint to avoid using it..

Is there any such hint, or is there any workaround for this.

Thanks in advance

like image 730
Fr_nkenstien Avatar asked Jun 17 '13 06:06

Fr_nkenstien


1 Answers

use NO_INDEX hint

http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements006.htm#BABHJBIB

for instance

SELECT /*+ NO_INDEX(t1 id1) */ 
  FROM t1,
       t2  
 WHERE t1.id = t2.id;
like image 64
Dmitry Bychenko Avatar answered Sep 28 '22 08:09

Dmitry Bychenko