How can you force the optimizer to use a particular index?

Showing Answers 1 - 3 of 3 Answers

siddharth ranga

  • Sep 29th, 2005
 

use hints /*+ <hint> */, these acts as directives to the optimizer

  Was this answer useful?  Yes

siddharth ranga

  • Sep 29th, 2005
 

an eg for hints:

Direct use of indexes.

select /*+ index(a index_name) full(b) */ *from  table1 a, table2 bwhere  b.col1 = a.col1 and    b.col2= 'sid'and    b.col3 = 1;

  Was this answer useful?  Yes

Gaurav Rustogi

  • Sep 7th, 2007
 

Explicitly chooses an index scan for the specified table. You can use the INDEX hint for domain, B*-tree, and bitmap indexes.

CREATE INDEX ix_customers_gender
ON customers(gender);

set autotrace traceonly explain

SELECT *
FROM customers
WHERE gender = 'M';

SELECT /*+ INDEX(customers ix_customers_gender) */ *
FROM customers
WHERE gender = 'M';

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions