I have this table:
create table demo ( key number(10) not null, type varchar2(3) not null, state varchar2(16) not null, ... lots more columns ... )
and this index:
create index demo_x04 on demo(key, type, state);
When I run this request
select * from demo where key = 1 and type = '003' and state = 'NEW'
EXPLAIN PLAN shows that it performs a full table scan. So I reset the index and created it again. EXPLAIN PLAN is still scanning a full table scan. How can it be?
Some background: this is historical data, so what happens is that I look at the line with the CLEARED state and insert a new line with the NEW state (plus I copy a few values from the old line). Then the old line is updated to USED . Thus, the table is always growing. I noticed that the power of the index is 0 (despite the fact that I have thousands of different values). After the recreation, the power increased, but CBO did not like the index better.
The next morning, Oracle suddenly fell in love with the index (perhaps sleeping over it) and began using it, but not for long. After some time, processing fell from 50 lines / s to 3 lines / s, and again I saw “FULL SCAN TABLES”. What's happening?
In my case, I need to process about a million lines. I make changes in batches of approx. 50. Is there some kind of command that I have to run after committing to update / reorganize the index, or something like that?
I am in Oracle 10g.
[EDIT] I have 969'491 different keys in this table, 3 types and 3 states.
source share