標籤:color tab exec style 情況 level ice access exp
Prediceate(謂詞):一個查詢中的WHERE限制條件。
在查看執行計畫的資訊中,經常會看到兩個謂詞filter和access
,它們的區別是什麼,理解了這個兩個詞對我們解讀Oracle的執行計畫資訊會有所協助。
簡單地說,執行計畫如果顯示是access,就表示這個謂詞條件的值將會影響資料的訪問路徑(表還是索引),而filter表示謂詞條件的值並不會影響資料
訪問路徑,只起到過濾的作用。
二、舉例說明:
----建立一張表echo---- 1 SQL> create table echo as select * from dba_objects; 2 3 Table created. 4 5 SQL> set autotrace trace exp; 6 SQL> set linesize 150; 7 SQL> select * from echo where object_id=1000; 8 9 Execution Plan10 ----------------------------------------------------------11 Plan hash value: 64265775612 13 --------------------------------------------------------------------------14 | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |15 --------------------------------------------------------------------------16 | 0 | SELECT STATEMENT | | 12 | 2484 | 289 (1)| 00:00:04 |17 |* 1 | TABLE ACCESS FULL| ECHO | 12 | 2484 | 289 (1)| 00:00:04 |18 --------------------------------------------------------------------------19 20 Predicate Information (identified by operation id):21 ---------------------------------------------------22 23 1 - filter("OBJECT_ID"=1000) ----因為表echo沒有建立索引,執行計畫沒有選擇資料訪問路徑的餘地,謂詞條件在這裡只是起到資料過濾的作用,所以使用了filter。24 25 Note26 -----27 - dynamic sampling used for this statement (level=2)28 ----建立索引的情況----29 SQL> create index echo_ind on echo(object_id);30 31 Index created.32 33 SQL> select * from echo where object_id=1000;34 35 Execution Plan36 ----------------------------------------------------------37 Plan hash value: 134515912638 39 ----------------------------------------------------------------------------------------40 | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |41 ----------------------------------------------------------------------------------------42 | 0 | SELECT STATEMENT | | 1 | 207 | 2 (0)| 00:00:01 |43 | 1 | TABLE ACCESS BY INDEX ROWID| ECHO | 1 | 207 | 2 (0)| 00:00:01 |44 |* 2 | INDEX RANGE SCAN | ECHO_IND | 1 | | 1 (0)| 00:00:01 |45 ----------------------------------------------------------------------------------------46 47 Predicate Information (identified by operation id):48 ---------------------------------------------------49 50 2 - access("OBJECT_ID"=1000) ----謂詞條件影響到資料訪問的路徑,選擇了索引,所以用access。51 52 Note53 -----54 - dynamic sampling used for this statement (level=2)
Oracle執行計畫裡的 access和filter有什麼區別