Re: Index help

  • From: "Terry Sutton" <terrysutton@xxxxxxx>
  • To: <oracle-l@xxxxxxxxxxxxx>
  • Date: Mon, 26 Jul 2004 08:43:55 -0700

A key factor is how frequently different values are queried.  As Dan says,
if :1= 46847 then a FTS is the way to go.  How often is this the case?  Or
is the query generally used to find "non-common" values (the other 4%).  If
the latter, then I'd recommend using a literal for the IDA3A5 portion of the
query and have a histogram on the column.  Same for codeC5; it has 3
distinct values, but if 99% are one value and the query is looking for the
other two, then a literal and histograms are better used here.  You need to
look at the query both in terms of the data distributions and the way the
query is being used by the app.

--Terry

----- Original Message ----- 

If the value of :1 = 46847 a full table scan makes sense (96% of the rows
meet the predicate condition). If the value is not 46847,
then an index lookup is probably faster. This is really a catch-22. Bind
variables are helping your parse times, but *may* be
hurting your execution time (hard to tell without knowing how many
executions use 46847 and how many do not). Without a histogram on
the column, Oracle will assume an even distribution, which is incorrect.

You are trapped between a rock and a hard place. If you use hard-coded
values instead of binds and have a histogram on the column,
the CBO should pick the proper execution plan each time. This also means
that you will have unique versions of the statement in your
shared pool. Sorry there is not a simple, quick answer to this one.

I suggest reading Wolfgang's paper "Fallacies of the Cost-Based Optimizer"
at www.centrexcc.com. He explains this issue very well.

Regards,
Daniel Fink

M.Godlewski wrote:
> Data distribution.
>
> IDA3A5     count(IDA3A5)
> 4104                           44
> 4107                         156
> 4110                             1
> 4111                             1
> 4137                             1
> 46847                      4905


----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to:  oracle-l-request@xxxxxxxxxxxxx
put 'unsubscribe' in the subject line.
--
Archives are at //www.freelists.org/archives/oracle-l/
FAQ is at //www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------


----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to:  oracle-l-request@xxxxxxxxxxxxx
put 'unsubscribe' in the subject line.
--
Archives are at //www.freelists.org/archives/oracle-l/
FAQ is at //www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------

Other related posts: