[20120112]xplan包的安裝.txt
使用xplan包可以更好的檢視執行計劃,它提供兩種使用方式,1.單獨呼叫執行.2.透過包呼叫.
使用包安裝過程如下:
1.下載安裝檔案並解壓:
http://www.oracle-developer.net/content/utilities/xplan.zip?p=1.2
2.我選擇sys使用者來安裝:
其它使用者需要這些許可權:
-- Required: 1) PLAN_TABLE of at least 10.1 format
--
-- 2) Either:
-- SELECT ANY DICTIONARY
-- Or:
-- SELECT on V$DATABASE
-- SELECT on V$SQL_PLAN
-- SELECT on V$SESSION
-- SELECT on V$MYSTAT
-- SELECT on DBA_HIST_SQL_PLAN
-- Or:
-- SELECT_CATALOG_ROLE
--
-- 3) CREATE TYPE, CREATE PROCEDURE
$ sqlplus sys as sysdba
SQL> @ xplan.package.sql
SQL> CREATE PUBLIC SYNONYM XPLAN FOR SYS.XPLAN;
SQL> grant execute on sys.xplan to public;
3.例子:
SQL> var a number;
SQL> exec :a :=10;
SQL> select /*+ gather_plan_statistics */ * from dept where deptno=:a;
SQL> select * from table(xplan.display_cursor(NULL,NULL,'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID atqyqkjm2a7ts, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ * from dept where deptno=:a
Plan hash value: 2852011669
---------------------------------------------------------------------------------------------------------------
| Id | PID | Order | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
---------------------------------------------------------------------------------------------------------------
| 0 | | 3 | SELECT STATEMENT | | 1 | | 1 |00:00:00.01 | 2 |
| 1 | 0 | 2 | TABLE ACCESS BY INDEX ROWID| DEPT | 1 | 1 | 1 |00:00:00.01 | 2 |
|* 2 | 1 | 1 | INDEX UNIQUE SCAN | PK_DEPT | 1 | 1 | 1 |00:00:00.01 | 1 |
---------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
-----------------------------------------------------------------
2 - access("DEPTNO"=:A)
About
-----
- XPlan v1.2 by Adrian Billington (http://www.oracle-developer.net)
20 rows selected.
4.對比dbms_xplan.display_cursor的顯示:
SQL> select /*+ gather_plan_statistics */ * from dept where deptno=:a;
SQL> select * from table(dbms_xplan.display_cursor(NULL,NULL,'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID atqyqkjm2a7ts, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ * from dept where deptno=:a
Plan hash value: 2852011669
-------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
-------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 1 |00:00:00.01 | 2 |
| 1 | TABLE ACCESS BY INDEX ROWID| DEPT | 1 | 1 | 1 |00:00:00.01 | 2 |
|* 2 | INDEX UNIQUE SCAN | PK_DEPT | 1 | 1 | 1 |00:00:00.01 | 1 |
-------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("DEPTNO"=:A)
19 rows selected.
5.如果你不習慣安裝包的方式,也可以採用直接呼叫的方式.
對應檔案就是一個readme,自己看看就知道如何執行了.
SQL> @ /home/oracle/sqllaji/xplan.display_cursor.sql atqyqkjm2a7ts "" "allstats last peeked_binds"
PLAN_TABLE_OUTPUT
--------------------------------------
SQL_ID atqyqkjm2a7ts, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ * from dept where deptno=:a
Plan hash value: 2852011669
-------------------------------------------------------------------------------------------------------------
| Id | Pid | Ord | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
-------------------------------------------------------------------------------------------------------------
| 0 | | 3 | SELECT STATEMENT | | 1 | | 1 |00:00:00.01 | 2 |
| 1 | 0 | 2 | TABLE ACCESS BY INDEX ROWID| DEPT | 1 | 1 | 1 |00:00:00.01 | 2 |
|* 2 | 1 | 1 | INDEX UNIQUE SCAN | PK_DEPT | 1 | 1 | 1 |00:00:00.01 | 1 |
-------------------------------------------------------------------------------------------------------------
Peeked Binds (identified by position):
--------------------------------------
1 - (NUMBER): 10
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("DEPTNO"=:A)
About
------
- XPlan v1.2 by Adrian Billington (http://www.oracle-developer.net)
24 rows selected.
使用包安裝過程如下:
1.下載安裝檔案並解壓:
http://www.oracle-developer.net/content/utilities/xplan.zip?p=1.2
2.我選擇sys使用者來安裝:
其它使用者需要這些許可權:
-- Required: 1) PLAN_TABLE of at least 10.1 format
--
-- 2) Either:
-- SELECT ANY DICTIONARY
-- Or:
-- SELECT on V$DATABASE
-- SELECT on V$SQL_PLAN
-- SELECT on V$SESSION
-- SELECT on V$MYSTAT
-- SELECT on DBA_HIST_SQL_PLAN
-- Or:
-- SELECT_CATALOG_ROLE
--
-- 3) CREATE TYPE, CREATE PROCEDURE
$ sqlplus sys as sysdba
SQL> @ xplan.package.sql
SQL> CREATE PUBLIC SYNONYM XPLAN FOR SYS.XPLAN;
SQL> grant execute on sys.xplan to public;
3.例子:
SQL> var a number;
SQL> exec :a :=10;
SQL> select /*+ gather_plan_statistics */ * from dept where deptno=:a;
SQL> select * from table(xplan.display_cursor(NULL,NULL,'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID atqyqkjm2a7ts, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ * from dept where deptno=:a
Plan hash value: 2852011669
---------------------------------------------------------------------------------------------------------------
| Id | PID | Order | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
---------------------------------------------------------------------------------------------------------------
| 0 | | 3 | SELECT STATEMENT | | 1 | | 1 |00:00:00.01 | 2 |
| 1 | 0 | 2 | TABLE ACCESS BY INDEX ROWID| DEPT | 1 | 1 | 1 |00:00:00.01 | 2 |
|* 2 | 1 | 1 | INDEX UNIQUE SCAN | PK_DEPT | 1 | 1 | 1 |00:00:00.01 | 1 |
---------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
-----------------------------------------------------------------
2 - access("DEPTNO"=:A)
About
-----
- XPlan v1.2 by Adrian Billington (http://www.oracle-developer.net)
20 rows selected.
4.對比dbms_xplan.display_cursor的顯示:
SQL> select /*+ gather_plan_statistics */ * from dept where deptno=:a;
SQL> select * from table(dbms_xplan.display_cursor(NULL,NULL,'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID atqyqkjm2a7ts, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ * from dept where deptno=:a
Plan hash value: 2852011669
-------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
-------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 1 |00:00:00.01 | 2 |
| 1 | TABLE ACCESS BY INDEX ROWID| DEPT | 1 | 1 | 1 |00:00:00.01 | 2 |
|* 2 | INDEX UNIQUE SCAN | PK_DEPT | 1 | 1 | 1 |00:00:00.01 | 1 |
-------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("DEPTNO"=:A)
19 rows selected.
5.如果你不習慣安裝包的方式,也可以採用直接呼叫的方式.
對應檔案就是一個readme,自己看看就知道如何執行了.
SQL> @ /home/oracle/sqllaji/xplan.display_cursor.sql atqyqkjm2a7ts "" "allstats last peeked_binds"
PLAN_TABLE_OUTPUT
--------------------------------------
SQL_ID atqyqkjm2a7ts, child number 0
-------------------------------------
select /*+ gather_plan_statistics */ * from dept where deptno=:a
Plan hash value: 2852011669
-------------------------------------------------------------------------------------------------------------
| Id | Pid | Ord | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
-------------------------------------------------------------------------------------------------------------
| 0 | | 3 | SELECT STATEMENT | | 1 | | 1 |00:00:00.01 | 2 |
| 1 | 0 | 2 | TABLE ACCESS BY INDEX ROWID| DEPT | 1 | 1 | 1 |00:00:00.01 | 2 |
|* 2 | 1 | 1 | INDEX UNIQUE SCAN | PK_DEPT | 1 | 1 | 1 |00:00:00.01 | 1 |
-------------------------------------------------------------------------------------------------------------
Peeked Binds (identified by position):
--------------------------------------
1 - (NUMBER): 10
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("DEPTNO"=:A)
About
------
- XPlan v1.2 by Adrian Billington (http://www.oracle-developer.net)
24 rows selected.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-714778/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20210311]如何建立bbed安裝包.txt
- requirements.txt 快速備份與安裝專案所需安裝包UIREM
- [20231017]使用dbms_xplan.display_awr查詢遇到的問題.txt
- Python中列已安裝包和requirements.txt檔案PythonUIREM
- comfyui包的安裝UI
- Linux下怎麼安裝.deb格式的安裝包?Linux系統下.deb格式安裝包的安裝教程Linux
- msys 包安裝
- [20201119]安裝cygwin.txt
- Electron 如何打包生成exe安裝包,注意是安裝包。
- NPM 安裝包遇到的坑!NPM
- ubuntu透過安裝包安裝MongodbUbuntuMongoDB
- yum如何解除安裝已安裝的rpm並安裝本地rpm包
- npm 包安裝位置NPM
- iOS安裝包瘦身iOS
- anaconda如何安裝包
- pycharm如何安裝包?PyCharm
- 快速安裝python包Python
- [20180923]安裝Wireshark for windows.txtWindows
- rpm包安裝升級與解除安裝
- solidworks2021安裝教程及安裝包Solid
- kali2022安裝教程(附安裝包)
- 一鍵安裝yum-utils安裝包
- mysql5.7tar包的安裝MySql
- RPM包的安裝與升級
- 安裝aab包的兩種方式
- 安裝R包常見的方法
- Eclipse 2020-06 漢化補丁包(附安裝教程+安裝包)Eclipse
- postgresql下載安裝包如何解壓安裝SQL
- [20200825]手工安裝HR schema.txt
- 中文BetterMouse破解安裝包
- .net core 常用安裝包
- python 包安裝筆記Python筆記
- VS 預設安裝包
- 安裝的 Linux 軟體包有多少?Linux
- conda可安裝的軟體包列表
- Debian安裝包的簡單製作
- npm安裝全域性包的問題NPM
- mysql8.0.30的RPM包安裝方法MySql
- Photoshop 2021超詳細安裝教程(附安裝包+安裝教程福利)