hint : use of an index Ora 10g [message #173123] |
Fri, 19 May 2006 08:42 |
luchot
Messages: 6 Registered: March 2006
|
Junior Member |
|
|
Hello,
I want to force Oracle to use the index id_ordkey_orders in the following query :
explain plan for select /*+ INDEX( ORDERS id_ordkey_orders) */ supp_nation,
cust_nation,
l_year,
sum(volume) as revenue
from
(
select
n1.n_name as supp_nation,
n2.n_name as cust_nation,
extract(year from l_shipdate) as l_year,
l_extendedprice * (1 - l_discount) as volume
from
supplier,lineitem,orders,customer,
nation n1,nation n2
where
s_suppkey = l_suppkey
and o_orderkey = l_orderkey
and c_custkey = o_custkey
and s_nationkey = n1.n_nationkey
and c_nationkey = n2.n_nationkey
and (
(n1.n_name = 'BRAZIL' and n2.n_name = 'JORDAN')
or (n1.n_name = 'JORDAN' and n2.n_name = 'BRAZIL'))
and l_shipdate between date '1995-01-01' and date '1996-12-31' ) shipping
group by
supp_nation,cust_nation,l_year
order by
supp_nation,cust_nation,l_year;
The problem is that Oracle continue to not use the index and his doing a table scan.
I have tried to prefix the table name by the name of the user but it do not works.
I do not think it is a problem of syntax on the name of the index because in another query whith the same syntax Oracle use the index .
So i do not understand what it happens and i would like to know if somebody has a solution.
Best Regards,
Luc
|
|
|
Re: hint : use of an index Ora 10g [message #173139 is a reply to message #173123] |
Fri, 19 May 2006 10:47 |
smartin
Messages: 1803 Registered: March 2005 Location: Jacksonville, Florida
|
Senior Member |
|
|
Must be something preventing use, either syntax or invalid index or some factor. I don't use hints much, but try putting the hint on the inner select instead of the outer select.
|
|
|
|
|