10g和9i執行計劃差異

jss001發表於2009-02-17

在oracle9i中執行計劃如下分析:

SQL> select ename,dname  from emp, dept  where emp.deptno=dept.deptno   and dept.dname in ('ACCOUNTING','RESEARCH','SALES','OPERATIONS');
  
  Execution Plan
  ----------------------------------------------------------
  0   SELECT STATEMENT Optimizer=CHOOSE
  1  0  NESTED LOOPS
  2  1   TABLE ACCESS (FULL) OF 'EMP'
  3  1   TABLE ACCESS (BY INDEX ROWID) OF 'DEPT'
  4  3    INDEX (UNIQUE SCAN) OF 'PK_DEPT' (UNIQUE)
  
  關於前面的兩個數字,第一個是狀態ID,第二個是父ID。
  
  就是如下所示:0--&gt1--&gt2
             |
             |--&gt3--&gt4
  在上圖裡,0的執行依靠1,1的執行又依賴2和3,2是沒有子ID的,所以2最先執行,然後是4,在然後是3;然後2和3的結果傳回1。

在oracle10g中執行計劃的顯示結果發生了改變:

SQL> set linesize 200
SQL> select count(*) from site_connect_detail;

COUNT(*)
----------
16250151


執行計劃

----------------------------------------------------------
Plan hash value: 2918895406

----------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time | Pstart| Pstop |
----------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 15290 (4)| 00:03:04 | | |
| 1 | SORT AGGREGATE | | 1 | | | | |
| 2 | PARTITION RANGE ALL| | 14M| 15290 (4)| 00:03:04 | 1 | 44 |
| 3 | TABLE ACCESS FULL | SITE_CONNECT_DETAIL | 14M| 15290 (4)| 00:03:04 | 1 | 44 |
----------------------------------------------------------------------------------------------------


統計資訊
----------------------------------------------------------
0 recursive calls
0 db block gets
74696 consistent gets
74052 physical reads
0 redo size
411 bytes sent via SQL*Net to client
385 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed

我們可以按照the rightmost-uppermost(最右最上) operation of an explain 規則來分析執行計劃。

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/18921899/viewspace-1017473/,如需轉載,請註明出處,否則將追究法律責任。

相關文章