Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle8 Reverse Indexes Problem
A copy of this was sent to "Alexandre Leite" <aleite_at_sysdesign.com.br>
(if that email address didn't require changing)
On Sat, 27 Mar 1999 21:14:17 -0300, you wrote:
>Hi all,
>
>We did the follow test in Oracle 8.0.5:
>
[snip]
>
>Why the Oracle RDBMS didn't use "ind_col2_t3" reverse index?
>My select statment uses an equality expression in where clause.
>
the reverse key index is visible to the CBO (cost based) only. RBO doesn't see it. Even so, if you just analyze the table -- you probably won't get the index to be used either (table is too small). Here is a sample:
SQL> create table t3 (
2 col1 varchar2(10) primary key,
3 col2 varchar2(10));
Table created.
SQL> insert into t3 values ('1','12134'); SQL> insert into t3 values ('2','14123'); SQL> insert into t3 values ('3','19769');
SQL> create index ind_col2_t3 on t3(col2); Index created.
SQL> set autotrace on explain;
SQL> select * from t3 where col2='22222'; no rows selected
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE
1 0 TABLE ACCESS (BY INDEX ROWID) OF 'T3'
2 1 INDEX (RANGE SCAN) OF 'IND_COL2_T3' (NON-UNIQUE)
SQL> drop index ind_col2_t3;
Index dropped.
SQL> create index ind_col2_t3 on t3(col2) reverse; Index created.
SQL> select * from t3 where col2='22222'; no rows selected
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE 1 0 TABLE ACCESS (FULL) OF 'T3'
SQL> select col2 from t3 where col2='22222'; no rows selected
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE 1 0 TABLE ACCESS (FULL) OF 'T3'
SQL> analyze table t3 compute statistics; Table analyzed.
SQL> select * from t3 where col2='22222'; no rows selected
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=11) 1 0 TABLE ACCESS (FULL) OF 'T3' (Cost=1 Card=1 Bytes=11)
SQL> select col2 from t3 where col2='22222'; no rows selected
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=11) 1 0 INDEX (RANGE SCAN) OF 'IND_COL2_T3' (NON-UNIQUE) (Cost=1 C
SQL> insert into t3 select rownum+100, rownum from all_objects; 18724 rows created.
SQL> analyze table t3 compute statistics; Table analyzed.
SQL> select * from t3 where col2='22222'; no rows selected
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=3 Card=2 Bytes=28) 1 0 TABLE ACCESS (BY INDEX ROWID) OF 'T3' (Cost=3 Card=2 Bytes 2 1 INDEX (RANGE SCAN) OF 'IND_COL2_T3' (NON-UNIQUE) (Cost=1
SQL> select col2 from t3 where col2='22222'; no rows selected
Execution Plan
0 SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=2 Bytes=28) 1 0 INDEX (RANGE SCAN) OF 'IND_COL2_T3' (NON-UNIQUE) (Cost=1 C
>Thanks in advance,
>
>Alexandre Leite
>leite_alexandre_at_hotmail.com
>
>
Thomas Kyte
tkyte_at_us.oracle.com
Oracle Service Industries
Reston, VA USA
--
http://govt.us.oracle.com/ -- downloadable utilities