RE: force index range scan vs index full scan through hints?

  • From: "" <dmarc-noreply@xxxxxxxxxxxxx> (Redacted sender "Jay.Miller" for DMARC)
  • To: <Oracle-L@xxxxxxxxxxxxx>
  • Date: Fri, 10 Aug 2018 14:06:56 +0000

It would require a fair amount of work since you have a variable number of 
predicates but creating sql baselines for each of the possible combinations 
would do it.

Jay Miller
Sr. Oracle DBA
201.369.8355

From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx] On ;
Behalf Of sachin pawar
Sent: Friday, August 10, 2018 9:57 AM
To: cstephens16@xxxxxxxxx
Cc: Oracle-L@xxxxxxxxxxxxx
Subject: Re: force index range scan vs index full scan through hints?

Hi Chris,
If you are able to rewrite the query , try doing WITH clause,( subquery 
factoring clause), and join those rowsets.

Rgds,
Sachin Pawar
https://twitter.com/sach_pwr<https://urldefense.proofpoint.com/v2/url?u=https-3A__twitter.com_sach-5Fpwr&d=DwMFaQ&c=nulvIAQnC0yOOjC0e0NVa8TOcyq9jNhjZ156R-JJU10&r=aiKV3Uv2Wo7GqYQcis9TSvB1MZslPOnintrOY1rjG58&m=WjakLWs-RF88eDvS88GBlVWsCXVD0b4qufisbIAHSds&s=PID9zSPWY-E4UpqeH8iNKTZ3IIqWCcBlkmTpvPTvDpg&e=>


On Fri, Aug 10, 2018 at 8:50 AM Chris Stephens 
<cstephens16@xxxxxxxxx<mailto:cstephens16@xxxxxxxxx>> wrote:
Is there a way to tell Oracle to use an index range scan instead of an index 
full scan?

We have a table that gets created on the fly and quickly accumulates 100's of 
millions of rows before statistics are collected. Never mind why the table has 
no statistics (it's a (longish) story). As the table accumulates data, another 
process hits it with a piece of SQL that has a variable number of predicates of 
the from "id between :id1 and :id2 OR id between :id2 and id3 OR...". We have 
an index to support that SQL. Oracle initially chooses to full scan that index 
instead of range scan it until statistics are collected. Full scan performance 
is unacceptable.  Is there a way to force the index range scan version? We 
can't use baselines (another story).

We've tried INDEX_RS and INDEX_RS_ASC after observing INDEX hint doesn't get us 
what we want since index is already being used. INDEX_RS and INDEX_RS_ASC 
aren't in official documentation so I'm not even sure they are valid hints.

As I write this, it occurs to me that dynamic sampling might help here and will 
try that but that obviously comes with some overhead.  Any other options?

Thanks for any insight.

chris


Other related posts: