Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Oracle not using indexes on char/varchar columns

Oracle not using indexes on char/varchar columns

From: Kamil Okac <kamil_at_okac.org>
Date: Wed, 08 Oct 2003 10:54:57 +0200
Message-ID: <3f83d0da$1@vse470.vse.cz>


Hello,

We've migrated to Oracle 9.2.0.1.0 (Solaris, 64bit) and are encountering problem with indexes. Oracle won't use indexes on char/varchar columns, until any (even unrelated to the query or the table referenced in query) 'explain plan' is run in that session. The first 'explain plan' of the query says that 'FULL SCAN' would be used, the same 'explain plan' ran for the second time gives correct information (INDEX UNIQUE SCAN).

What to do? Workaround would be to call 'EXPLAIN PLAN FOR SELECT * FROM DUAL' at the beginning of every session, but i don't like that :)

Thanks,

Kamil


Example:

CREATE TABLE TEST
(

   COL1 varchar2(4) primary key
)

...
insert data
...

select * from TEST where COL1=1;

explain plan for select * from TEST where COL1=1

explain plan for select * from TEST where COL1=1

select * from TEST where COL1=1;

Received on Wed Oct 08 2003 - 03:54:57 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US