Home » RDBMS Server » Performance Tuning » How can i force a sql use index range scan (11.2.0.1.0 Windos XP)
How can i force a sql use index range scan [message #516108] Fri, 15 July 2011 02:10 Go to next message
andy huang
Messages: 498
Registered: July 2011
Senior Member
Dear all,
How can i force a sql use index range scan?
Re: How can i force a sql use index range scan [message #516125 is a reply to message #516108] Fri, 15 July 2011 03:06 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Why do you want to force this?

Regards
Michel
Re: How can i force a sql use index range scan [message #516153 is a reply to message #516125] Fri, 15 July 2011 04:35 Go to previous messageGo to next message
andy huang
Messages: 498
Registered: July 2011
Senior Member
Because the sql run quickly using index range scan before,but now it use index full scan and is very slow.
so I want to use hint and force it use index range scan,but i don't know how to do.
Re: How can i force a sql use index range scan [message #516157 is a reply to message #516153] Fri, 15 July 2011 04:41 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Investigate why Oracle does not choose the "correct" access path.

Regards
Michel
Re: How can i force a sql use index range scan [message #516178 is a reply to message #516157] Fri, 15 July 2011 06:16 Go to previous messageGo to next message
LNossov
Messages: 318
Registered: July 2011
Location: Germany
Senior Member
It can be not so easy. For ex. in case of bug. If Andy needs a hint as a quick solution, why not. So he can use a hint
INDEX(<table alias or table name> <index name>)
, for ex.

select /*+ index(t i_ttt) */ * from ttt t where a= 100
or
select /*+ index(ttt i_ttt) */ * from ttt where a= 100


But you are right, after that he needs to analyze his problem.
Re: How can i force a sql use index range scan [message #516200 is a reply to message #516178] Fri, 15 July 2011 08:08 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Quote:
It can be not so easy. For ex. in case of bug.

Before thinking of a bug, I should think about statistics.
Anyway, a simple explain plan trace will give a first answer.
Then an optimizer trace will help to go further.

Using hint means "I failed to use Oracle" (either writing the query, either following the prerequisites). The bug is very very rare compare to the other cases.

Regards
Michel

[Updated on: Fri, 15 July 2011 08:09]

Report message to a moderator

Re: How can i force a sql use index range scan [message #516253 is a reply to message #516200] Fri, 15 July 2011 13:51 Go to previous messageGo to next message
LNossov
Messages: 318
Registered: July 2011
Location: Germany
Senior Member
Not so rare as you think Sad . The reason could be also complex pradicates (in 10g) and other similar things, where the statistics are not so helpful. Hints (as well as stored outlines) means a quick help (sometimes the only help) in serious situations. Or do you think, that the whole concept of plan stability means "I failed to use Oracle" too?
Re: How can i force a sql use index range scan [message #516256 is a reply to message #516253] Fri, 15 July 2011 13:56 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
The key part is "compare to the other cases".
Just read the topics we have here and you will see that not up to date statistics or comparison between 2 different environments are the most ones and Oracle bugs are rare.

I do not say that you failed to use Oracle, I say most of those that post failed to use Oracle. And here we have no information, so I think it tends to the most likely case as the experienced people that post here give the whole and complete information about his/her problem.
I bet if you have some kind of performance problem you do not just post "How can i force a sql use index range scan?".

Regards
Michel

[Updated on: Fri, 15 July 2011 14:02]

Report message to a moderator

Re: How can i force a sql use index range scan [message #516273 is a reply to message #516256] Fri, 15 July 2011 15:23 Go to previous messageGo to next message
LNossov
Messages: 318
Registered: July 2011
Location: Germany
Senior Member
I understood you correctly.

I can understand people, who have big problems (regardless real or imaginary) and call for help. So they can post "How can i force a sql use index range scan?". Why not?

In my opinion, they have to get firstly a help, then perhaps investigations, training courses and so on.

Kind regards
Leonid

[Updated on: Fri, 15 July 2011 16:13]

Report message to a moderator

Re: How can i force a sql use index range scan [message #516407 is a reply to message #516108] Sun, 17 July 2011 22:17 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>How can i force a sql use index range scan?
This is an interesting problem statement.
If "index range scan" was really the correct solution,
you would NOT need to ask how to force it,
since you would have already successfully tested index range scan!

So what problem are you really trying to solve?
Re: How can i force a sql use index range scan [message #516440 is a reply to message #516407] Mon, 18 July 2011 03:33 Go to previous message
cookiemonster
Messages: 13958
Registered: September 2008
Location: Rainy Manchester
Senior Member
BlackSwan wrote on Mon, 18 July 2011 04:17
>How can i force a sql use index range scan?
This is an interesting problem statement.
If "index range scan" was really the correct solution,
you would NOT need to ask how to force it,
since you would have already successfully tested index range scan!

You make it sound like the CBO never gets it wrong.
Previous Topic: Data dictionary Cache - dc_objects
Next Topic: DBMS_UTILITY
Goto Forum:
  


Current Time: Sun Nov 24 21:46:42 CST 2024