1. 程式人生 > >Oracle 區域性字首索引和區域性非字首索引

Oracle 區域性字首索引和區域性非字首索引

create index ind_local_prfixed on TEST_P(owner,object_id) local nologging;
exec dbms_stats.gather_table_stats(user,'TEST_P',cascade => true);
SQL> set autotrace traceonly
SQL> select * from TEST_P where object_id = 4903;
執行計劃
----------------------------------------------------------
Plan hash value: 3793878917
------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                          | Name              | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                   |                   |     1 |    97 |    28   (0)| 00:00:01 |       |       |
|   1 |  PARTITION LIST ALL                |                   |     1 |    97 |    28   (0)| 00:00:01 |     1 |    10 |
|   2 |   TABLE ACCESS BY LOCAL INDEX ROWID| TEST_P            |     1 |    97 |    28   (0)| 00:00:01 |     1 |    10 |
|*  3 |    INDEX SKIP SCAN                 | IND_LOCAL_PRFIXED |     1 |       |    27   (0)| 00:00:01 |     1 |    10 |
------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   3 - access("OBJECT_ID"=4903)
       filter("OBJECT_ID"=4903)
統計資訊
----------------------------------------------------------
          1  recursive calls
          0  db block gets
         38  consistent gets
          0  physical reads
          0  redo size
       1294  bytes sent via SQL*Net to client
        472  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed


SQL> select * from TEST_P where object_id = 4903 and owner='SYS';
執行計劃
----------------------------------------------------------
Plan hash value: 1414917495
------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                          | Name              | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                   |                   |     1 |    96 |     2   (0)| 00:00:01 |       |       |
|   1 |  PARTITION LIST SINGLE             |                   |     1 |    96 |     2   (0)| 00:00:01 |   KEY |   KEY |
|   2 |   TABLE ACCESS BY LOCAL INDEX ROWID| TEST_P            |     1 |    96 |     2   (0)| 00:00:01 |     1 |     1 |
|*  3 |    INDEX RANGE SCAN                | IND_LOCAL_PRFIXED |     1 |       |     1   (0)| 00:00:01 |     1 |     1 |
------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   3 - access("OWNER"='SYS' AND "OBJECT_ID"=4903)
統計資訊
----------------------------------------------------------
          1  recursive calls
          0  db block gets
          4  consistent gets
          0  physical reads
          0  redo size
       1294  bytes sent via SQL*Net to client
        472  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
          1  rows processed