91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

oracle查看執行計劃之DBMS_XPLAN

發布時間:2020-08-17 10:35:32 來源:網絡 閱讀:867 作者:llc018198 欄目:關系型數據庫

    使用DBMS_XPLAN包中的方法是在oracle數據庫中得到目標SQL的執行計劃的另一種方法。針對不同的應用場景嗎,你可以選擇如下四種方法中的一種:

    select * from table(dbms_xplan.display)

    select * from table(dbms_xplan.display_cursor(null,null,'advenced'));

    select * from table(dbms_xplan.display_cursor('sql_id/hash_value',child_cursor_number,'advanced'));

    select * from table(dbms_xplan.display_awr('sql_id'));

    方法1是執行select * from table(dbms_xplan.display),這需要與explain plan命令配合使用,它用于查看使用explain plan命令后得到的執行計劃。

     方法2是執行select * from table(dbms_xplan.display_cursor(null,null,'advenced'));它用于查看剛剛執行過的sql的執行計劃,這里針對dbms_xplan.display_cursor所傳入的第一個和第二參數的值均為null,第三參數的值是“advanced”,第三個輸入參數的值也可以是“all”,只不過用“advanced”后的顯示結果會比用“all”的顯示結果更詳細些。    

SQL> conn scott/scott;

Connected.

SQL> set linesize 800

SQL> set pagesize 900

SQL> col plan_table_output for a200

SQL> select empno,ename,dname from emp,dept where emp.deptno=dept.deptno;

     EMPNO ENAME      DNAME

---------- ---------- --------------

      7782 CLARK      ACCOUNTING

      7839 KING       ACCOUNTING14 rows selected.

SQL> select * from table(dbms_xplan.display_cursor(null,null,'advanced'));

PLAN_TABLE_OUTPUT

-------------------------------------------------------------------------------------------

SQL_ID 7ww0fhpbqqt0n, child number 0

-------------------------------------

select empno,ename,dname from emp,dept where emp.deptno=dept.deptno

Plan hash value: 844388907

----------------------------------------------------------------------------------------

| Id  | Operation     | Name    | Rows  | Bytes | Cost (%CPU)| Time     |

----------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT     |       |       |       |     6 (100)|       |

|   1 |  MERGE JOIN     |       |    14 |   364 |     6 (17)| 00:00:01 |

|   2 |   TABLE ACCESS BY INDEX ROWID| DEPT    |     4 |    52 |     2 (0)| 00:00:01 |

|   3 |    INDEX FULL SCAN     | PK_DEPT |     4 |       |     1 (0)| 00:00:01 |

|*  4 |   SORT JOIN     |       |    14 |   182 |     4 (25)| 00:00:01 |

|   5 |    TABLE ACCESS FULL     | EMP     |    14 |   182 |     3 (0)| 00:00:01 |

----------------------------------------------------------------------------------------

Query Block Name / Object Alias (identified by operation id):

-------------------------------------------------------------

   1 - SEL$1

   2 - SEL$1 / DEPT@SEL$1

   3 - SEL$1 / DEPT@SEL$1

   5 - SEL$1 / EMP@SEL$1

Outline Data

-------------

  /*+

      BEGIN_OUTLINE_DATA

      IGNORE_OPTIM_EMBEDDED_HINTS

      OPTIMIZER_FEATURES_ENABLE('11.2.0.4')

      DB_VERSION('11.2.0.4')

      ALL_ROWS

      OUTLINE_LEAF(@"SEL$1")

      INDEX(@"SEL$1" "DEPT"@"SEL$1" ("DEPT"."DEPTNO"))

      FULL(@"SEL$1" "EMP"@"SEL$1")

      LEADING(@"SEL$1" "DEPT"@"SEL$1" "EMP"@"SEL$1")

      USE_MERGE(@"SEL$1" "EMP"@"SEL$1")

      END_OUTLINE_DATA

  */

Predicate Information (identified by operation id):

---------------------------------------------------

   4 - access("EMP"."DEPTNO"="DEPT"."DEPTNO")

       filter("EMP"."DEPTNO"="DEPT"."DEPTNO")

Column Projection Information (identified by operation id):

-----------------------------------------------------------

   1 - "DNAME"[VARCHAR2,14], "EMPNO"[NUMBER,22], "ENAME"[VARCHAR2,10]

   2 - "DEPT"."DEPTNO"[NUMBER,22], "DNAME"[VARCHAR2,14]

   3 - "DEPT".ROWID[ROWID,10], "DEPT"."DEPTNO"[NUMBER,22]

   4 - (#keys=1) "EMP"."DEPTNO"[NUMBER,22], "EMPNO"[NUMBER,22],

       "ENAME"[VARCHAR2,10]

   5 - "EMPNO"[NUMBER,22], "ENAME"[VARCHAR2,10], "EMP"."DEPTNO"[NUMBER,22]

58 rows selected.

SQL> select * from table(dbms_xplan.display_cursor(null,null,'all'));

PLAN_TABLE_OUTPUT

-------------------------------------------------------------------------------------------

SQL_ID 7ww0fhpbqqt0n, child number 0

-------------------------------------

select empno,ename,dname from emp,dept where emp.deptno=dept.deptno

Plan hash value: 844388907

----------------------------------------------------------------------------------------

| Id  | Operation     | Name    | Rows  | Bytes | Cost (%CPU)| Time     |

----------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT     |       |       |       |     6 (100)|       |

|   1 |  MERGE JOIN     |       |    14 |   364 |     6 (17)| 00:00:01 |

|   2 |   TABLE ACCESS BY INDEX ROWID| DEPT    |     4 |    52 |     2 (0)| 00:00:01 |

|   3 |    INDEX FULL SCAN     | PK_DEPT |     4 |       |     1 (0)| 00:00:01 |

|*  4 |   SORT JOIN     |       |    14 |   182 |     4 (25)| 00:00:01 |

|   5 |    TABLE ACCESS FULL     | EMP     |    14 |   182 |     3 (0)| 00:00:01 |

----------------------------------------------------------------------------------------

Query Block Name / Object Alias (identified by operation id):

-------------------------------------------------------------

   1 - SEL$1

   2 - SEL$1 / DEPT@SEL$1

   3 - SEL$1 / DEPT@SEL$1

   5 - SEL$1 / EMP@SEL$1

Predicate Information (identified by operation id):

---------------------------------------------------

   4 - access("EMP"."DEPTNO"="DEPT"."DEPTNO")

       filter("EMP"."DEPTNO"="DEPT"."DEPTNO")

Column Projection Information (identified by operation id):

-----------------------------------------------------------

   1 - "DNAME"[VARCHAR2,14], "EMPNO"[NUMBER,22], "ENAME"[VARCHAR2,10]

   2 - "DEPT"."DEPTNO"[NUMBER,22], "DNAME"[VARCHAR2,14]

   3 - "DEPT".ROWID[ROWID,10], "DEPT"."DEPTNO"[NUMBER,22]

   4 - (#keys=1) "EMP"."DEPTNO"[NUMBER,22], "EMPNO"[NUMBER,22],

       "ENAME"[VARCHAR2,10]

   5 - "EMPNO"[NUMBER,22], "ENAME"[VARCHAR2,10], "EMP"."DEPTNO"[NUMBER,22]

41 rows selected.

當參數傳入all,顯示結果中了“Qutline Data”部分的內容:

    方法3是執行    select * from table(dbms_xplan.display_cursor('sql_id/hash_value',child_cursor_number,'advanced'));它用于查看指定sql的執行計劃。這里針對方法dbms_xplan.display_cursor所傳人的第一個參數的值是指定sql的sql_id或者sql hash value,第二參數的值是要看執行計劃所在的child cursor number,第三個參數是advcanced或者all

    

SQL> select sql_text,sql_id,hash_value,child_number from v$sql where sql_text like 'select empno,ename,dname%';

SQL_TEXT

select empno,ename,dname from emp,dept where emp.deptno=dept.deptno

SQL_ID      HASH_VALUE CHILD_NUMBER

------------- ---------- ------------

7ww0fhpbqqt0n 1466655764    0

    只要目標sql的執行計劃所在的child cursor還沒有被page out出shared pool,就可以使用方法3查看該sql的執行計劃:   

SQL> select * from table(dbms_xplan.display_cursor('2qm0f3qgsqqyc',0,'advanced'));

PLAN_TABLE_OUTPUT

-------------------------------------------------------------------------------------------

SQL_ID 2qm0f3qgsqqyc, child number 0

-------------------------------------

select empno,ename,dname from scott.emp,scott.dept where

scott.emp.deptno=scott.dept.deptno

Plan hash value: 844388907

----------------------------------------------------------------------------------------

| Id  | Operation     | Name    | Rows  | Bytes | Cost (%CPU)| Time     |

----------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT     |       |       |       |     6 (100)|       |

|   1 |  MERGE JOIN     |       |    14 |   364 |     6 (17)| 00:00:01 |

|   2 |   TABLE ACCESS BY INDEX ROWID| DEPT    |     4 |    52 |     2 (0)| 00:00:01 |

|   3 |    INDEX FULL SCAN     | PK_DEPT |     4 |       |     1 (0)| 00:00:01 |

|*  4 |   SORT JOIN     |       |    14 |   182 |     4 (25)| 00:00:01 |

|   5 |    TABLE ACCESS FULL     | EMP     |    14 |   182 |     3 (0)| 00:00:01 |

----------------------------------------------------------------------------------------

Query Block Name / Object Alias (identified by operation id):

-------------------------------------------------------------

   1 - SEL$1

   2 - SEL$1 / DEPT@SEL$1

   3 - SEL$1 / DEPT@SEL$1

   5 - SEL$1 / EMP@SEL$1

Outline Data

-------------

  /*+

      BEGIN_OUTLINE_DATA

      IGNORE_OPTIM_EMBEDDED_HINTS

      OPTIMIZER_FEATURES_ENABLE('11.2.0.4')

      DB_VERSION('11.2.0.4')

      ALL_ROWS

      OUTLINE_LEAF(@"SEL$1")

      INDEX(@"SEL$1" "DEPT"@"SEL$1" ("DEPT"."DEPTNO"))

      FULL(@"SEL$1" "EMP"@"SEL$1")

      LEADING(@"SEL$1" "DEPT"@"SEL$1" "EMP"@"SEL$1")

      USE_MERGE(@"SEL$1" "EMP"@"SEL$1")

      END_OUTLINE_DATA

  */

Predicate Information (identified by operation id):

---------------------------------------------------

   4 - access("EMP"."DEPTNO"="DEPT"."DEPTNO")

       filter("EMP"."DEPTNO"="DEPT"."DEPTNO")

Column Projection Information (identified by operation id):

-----------------------------------------------------------

   1 - "DNAME"[VARCHAR2,14], "EMPNO"[NUMBER,22], "ENAME"[VARCHAR2,10]

   2 - "DEPT"."DEPTNO"[NUMBER,22], "DNAME"[VARCHAR2,14]

   3 - "DEPT".ROWID[ROWID,10], "DEPT"."DEPTNO"[NUMBER,22]

   4 - (#keys=1) "EMP"."DEPTNO"[NUMBER,22], "EMPNO"[NUMBER,22],

       "ENAME"[VARCHAR2,10]

   5 - "EMPNO"[NUMBER,22], "ENAME"[VARCHAR2,10], "EMP"."DEPTNO"[NUMBER,22]

59 rows selected.

    我們可以通過dbms_xplan.display_awr來得到該sql的所有歷史執行計劃:

SQL> set lines 100

SQL> select * from table(dbms_xplan.display_awr('cy097a90nu4fk'));

PLAN_TABLE_OUTPUT

SQL_ID cy097a90nu4fk

--------------------

Plan hash value: 1999179007

-------------------------------------------------------------------------------------------

| Id  | Operation                        | Name           | Rows  | Bytes | Cost (%CPU)| Time     |

Inst   |IN-OUT|

-------------------------------------------------------------------------------------------

|   0 | SELECT STATEMENT                 |                |       |       |    11 (100)|          |

       |      |

|   1 |  HASH GROUP BY                   |                |     1 |   101 |    11  (19)| 00:00:01 |

       |      |

|   2 |   VIEW                           |                |     1 |   101 |    10  (10)| 00:00:01 |

       |      |

|   3 |    HASH GROUP BY                 |                |     1 |   261 |    10  (10)| 00:00:01 |

       |      |

|   4 |     FILTER                       |                |       |       |            |          |

       |      |

|   5 |      NESTED LOOPS                |                |       |       |            |          |

       |      |

|   6 |       NESTED LOOPS               |                |     1 |   261 |     9   (0)| 00:00:01 |

       |      |

|   7 |        REMOTE                    |                |     1 |   176 |     5   (0)| 00:00:01 |

DBLK_~ | R->S |

|   8 |        INDEX RANGE SCAN          | PRODUCTSPEC_PK |     1 |       |     1   (0)| 00:00:01 |

       |      |

|   9 |       TABLE ACCESS BY INDEX ROWID| PRODUCTSPEC    |     1 |    41 |     2   (0)| 00:00:01 |

       |      |

-------------------------------------------------------------------------------------------

Remote SQL Information (identified by operation id):

----------------------------------------------------

   7 - SELECT "A1"."EVENTTIMEKEY","A1"."EVENTID","A1"."EVENTTIME","A1"."FOLLOTID","A1"."PRODUCTSPECI

D","A1"

       ."PROCESSFLOWID","A1"."OLDOPERATIONID","A1"."QUANTITY","A1"."EQUIPMENTID","A2"."PROCESSFLOWID

","A2"."REWORK

       TYPE" FROM "LOTHISTORY" "A1","PROCESSFLOW" "A2" WHERE "A2"."REWORKTYPE"='Normal' AND

       "A1"."PROCESSFLOWID"="A2"."PROCESSFLOWID" AND "A1"."EVENTID"='TrackIn' AND "A1"."OLDOPERATION

ID"='BFOP001'

       AND (SUBSTR("A1"."FOLLOTID",1,1)='V' OR SUBSTR("A1"."FOLLOTID",1,1)='P') AND

       "A1"."EVENTTIME">=TO_DATE('20140918080001','YYYY-MM-DD HH24:MI:SS') AND

       "A1"."EVENTTIME"<=TO_DATE('20140919080000','YYYY-MM-DD HH24:MI:SS') (accessing 'DBLK_RPT_EOL_

PRD' )

55 rows selected.

    不過此方法顯示執行計劃中看不到執行步驟對應的謂詞條件。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

靖远县| 南溪县| 云龙县| 信阳市| 团风县| 金山区| 九江县| 乾安县| 安徽省| 阿拉善右旗| 高要市| 霍邱县| 错那县| 湖北省| 和田市| 安图县| 浪卡子县| 泗阳县| 石渠县| 隆子县| 鄂伦春自治旗| 河北省| 武义县| 高青县| 剑阁县| 嘉禾县| 龙州县| 安阳县| 临安市| 海城市| 无极县| 临夏市| 岳池县| 太康县| 乌拉特中旗| 富阳市| 江口县| 金寨县| 万盛区| 辽宁省| 茶陵县|