索引唯一性掃描(INDEX UNIQUE SCAN)

weixin_34279184發表於2015-04-28
 

     索引唯一性掃描(INDEX UNIQUE SCAN)是針對唯一性索引(UNIQUE INDEX)的掃描,它僅僅適用於where條件裡是等值查詢的目標SQL。因為掃描的物件是唯一性索引,所以索引唯一性掃描的結果至多隻會返回一條記錄。

Emp表中empno為primary key,對應一個unique index


SCOTT@PDBORCL> select * from emp where empno=7369;


執行計劃
----------------------------------------------------------
Plan hash value: 2949544139

--------------------------------------------------------------------------------------
| Id  | Operation                   | Name   | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |        |     1 |    38 |     1   (0)| 00:00:01 |
|   1 |  TABLE ACCESS BY INDEX ROWID| EMP    |     1 |    38 |     1   (0)| 00:00:01 |
|*  2 |   INDEX UNIQUE SCAN         | PK_EMP |     1 |       |     0   (0)| 00:00:01 |
--------------------------------------------------------------------------------------

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

   2 - access("EMPNO"=7369)


統計資訊
----------------------------------------------------------
         69  recursive calls
          0  db block gets
         95  consistent gets
         21  physical reads
          0  redo size
        898  bytes sent via SQL*Net to client
        533  bytes received via SQL*Net from client
          1  SQL*Net roundtrips to/from client
          8  sorts (memory)
          0  sorts (disk)
          1  rows processed

SCOTT@PDBORCL>

View Code

image

從上述顯示內容可以看出,"select * from emp where empno=7369"的執行計劃走的是索引唯一性掃描

相關文章