Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Why does this query need a table access by rowid?
> > Try to do a composite index on f(doc_id), doc_id.
>
> (I did hit send too early..)
> Of course this kind of composite index would eliminate the benefit of
having
> smaller index, since all doc-ids would be stored in index anyway...
I did hit send too early again :)
Try this:
SQL> create table t (a number, b number, status char(1));
Table created.
SQL>
SQL> create index i on t(decode(status, 'Y', a, null));
Index created.
SQL> analyze table t compute statistics;
Table analyzed.
SQL>
SQL> select /*+ INDEX(t i) */ decode(status, 'Y', a, null) from t where
decode(status, 'Y', a, null) = 1;
no rows selected
SQL> SQL> @x SQL> set termout off
PLAN_TABLE_OUTPUT
| 0 | SELECT STATEMENT | | 1 | 16 | 2 (50)| |* 1 | INDEX RANGE SCAN | I | 1 | 16 | 2 (50)| -------------------------------------------------------------------------
Predicate Information (identified by operation id):
1 - access(DECODE("T"."STATUS",'Y',"T"."A",NULL)=1) SQL> Applying the function to the column you're selecting will make use of the index...
Tanel.
-- Archives are at http://www.freelists.org/archives/oracle-l/ FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html -----------------------------------------------------------------Received on Fri Jul 23 2004 - 13:25:57 CDT
![]() |
![]() |