Home » RDBMS Server » Performance Tuning » hint : use of an index Ora 10g  () 1 Vote
hint : use of an index Ora 10g [message #173123] Fri, 19 May 2006 08:42 Go to next message
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 Go to previous messageGo to next message
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.
Re: hint : use of an index Ora 10g [message #173250 is a reply to message #173139] Sun, 21 May 2006 00:42 Go to previous messageGo to next message
rleishman
Messages: 3728
Registered: October 2005
Location: Melbourne, Australia
Senior Member
Try moving the hint to the sub-query.

Ross Leishman
icon7.gif  Re: hint : use of an index Ora 10g [message #173425 is a reply to message #173250] Mon, 22 May 2006 07:34 Go to previous message
luchot
Messages: 6
Registered: March 2006
Junior Member
I have moved the hint to the sub select as you said and it works very fine.
So i thank you for your fast answer.
Previous Topic: buffer busy waits
Next Topic: SQL code block running v.v.v. slow
Goto Forum:
  


Current Time: Sat Nov 23 16:04:29 CST 2024