Desculpe contrariar sua resposta, mas "depende", se o otimizador achar
vantagem usar o índice, mesmo que voce mencione somente um dos campos ele
usa o índice. Ex.

ops$marcio:LX10G> create table t ( x int, y int, z int);

Table created.

ops$marcio:LX10G>
ops$marcio:LX10G> insert into t select mod(rownum,1000), mod(rownum,100),
rownum from all_objects;

52864 rows created.

ops$marcio:LX10G> create index t_i on t(x,y);

Index created.

ops$marcio:LX10G> exec dbms_stats.gather_table_stats( user, 'T', cascade =>
true )

PL/SQL procedure successfully completed.

ops$marcio:LX10G> set autotrace on
ops$marcio:LX10G> select * from t where x = 1;

            X             Y             Z
------------- ------------- -------------
            1             1          1001
            1             1          2001
            1             1             1
            1             1          3001
            1             1          4001
            1             1          5001
            1             1          7001
            1             1          9001
            1             1          8001
            1             1          6001
            1             1         10001
            1             1         11001
            1             1         12001
            1             1         15001
            1             1         14001
            1             1         13001
            1             1         52001
            1             1         19001
            1             1         16001
            1             1         17001
            1             1         18001
            1             1         20001
            1             1         21001
            1             1         22001
            1             1         23001
            1             1         24001
            1             1         25001
            1             1         27001
            1             1         28001
            1             1         26001
            1             1         29001
            1             1         30001
            1             1         31001
            1             1         33001
            1             1         34001
            1             1         32001
            1             1         35001
            1             1         36001
            1             1         37001
            1             1         38001
            1             1         40001
            1             1         41001
            1             1         39001
            1             1         42001
            1             1         43001
            1             1         44001
            1             1         46001
            1             1         47001
            1             1         45001
            1             1         51001
            1             1         48001
            1             1         49001
            1             1         50001

53 rows selected.


Execution Plan
----------------------------------------------------------
Plan hash value: 1658221841

------------------------------------------------------------------------------------
| Id  | Operation                   | Name | Rows  | Bytes | Cost (%CPU)|
Time     |
------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |      |    53 |   583 |    55   (0)|
00:00:01 |
|   1 |  TABLE ACCESS BY INDEX ROWID| T    |    53 |   583 |    55   (0)|
00:00:01 |
|*  2 |   INDEX RANGE SCAN          | T_I  |    53 |       |     2   (0)|
00:00:01 |
------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("X"=1)


Statistics
----------------------------------------------------------
          1  recursive calls
          0  db block gets
         56  consistent gets
          0  physical reads
          0  redo size
       1054  bytes sent via SQL*Net to client
        400  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
         53  rows processed



On 10/30/07, joao batista <[EMAIL PROTECTED]> wrote:
>
>   Somente quando vc faz referência as 02 chaves que fazem parte de indice.
>
> Att,
> João Batista
>
> fabiopdb <[EMAIL PROTECTED] <fabiopdb%40yahoo.com.br>> escreveu:
> Quando tenho um indice composto ex (cod_cli,cpf_cli) e faço uma busca
> usando apenas uma chave , ele usa o indice ou ele so usa quando chamo
> as duas chaves ?
>
> Abra sua conta no Yahoo! Mail, o único sem limite de espaço para
> armazenamento!
>
> [As partes desta mensagem que não continham texto foram removidas]
>
>  
>



-- 
Marcio Portes
Material Tecnico em Portugues - http://mportes.blogspot.com
Practical Learning Oracle     -
http://mportes.blogspot.com/2006/02/practical-learning-oracle.html


[As partes desta mensagem que não continham texto foram removidas]

Responder a