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

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Why does this query need a table access by rowid?

Re: Why does this query need a table access by rowid?

From: Tanel Põder <tanel.poder.003_at_mail.ee>
Date: Fri, 23 Jul 2004 21:29:12 +0300
Message-ID: <35b401c470e2$f42c72d0$0a879fd9@porgand>


> > 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





| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
|   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.



Please see the official ORACLE-L FAQ: http://www.orafaq.com

To unsubscribe send email to: oracle-l-request_at_freelists.org put 'unsubscribe' in the subject line.
--
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

Original text of this message

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