Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: index not used in LIKE 'aaa%'
"Ted Chyn" <tedchyn_at_yahoo.com> wrote in message
news:44a19320.0404190856.79c7c92c_at_posting.google.com...
> I have a table with 5 million rows with cbo.
>
> An nonunique index is defined on patient_acct. There are only 6 rows
> qualified for the selection and why index is not used for query 2.
>
>
> 1. index used with following sql.
> select patient_acct from pymtitem
> where (PATIENT_ACCT like '613%3713HENSL')
>
> 2. index was not used with following sql when additional field appear
> in select clause. full table scan is used for the sql.
>
> select patient_acct,pi_surr_id from pymtitem
> where (PATIENT_ACCT like '613%3713HENSL').
>
>
> thanks ted
Couple of things:
If you never changed these parameters from their default value of 100 and 0, then it could a major contributing factor in why the index is not being used. However, a lot of testing is required
if you plan on changing them now (to a more realistic value for your env).
For example: Try your query after setting the init ora parameters to the following: alter session set optimizer_index_caching = 70; alter session set optimizer_index_cost_adj = 20;
(Note: I'm not suggesting that 70 / 20 are good values .. you have to find the sweet spot for your env .. yourself)
HTH Anurag Received on Mon Apr 19 2004 - 15:55:42 CDT