[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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- requirements.txt 快速備份與安裝專案所需安裝包UIREM
- dbms_xplan 函式包函式
- [20210311]如何建立bbed安裝包.txt
- Python中列已安裝包和requirements.txt檔案PythonUIREM
- comfyui包的安裝UI
- mysql非安裝包安裝教程MySql
- 安裝pdksh包
- msys 包安裝
- Linux下怎麼安裝.deb格式的安裝包?Linux系統下.deb格式安裝包的安裝教程Linux
- Electron 如何打包生成exe安裝包,注意是安裝包。
- mysql安裝------RPM包安裝及解除安裝MySql
- NPM 安裝包遇到的坑!NPM
- runstats_pkg包的安裝
- 使用yum安裝oracle的包Oracle
- ubuntu透過安裝包安裝MongodbUbuntuMongoDB
- npm 包安裝位置NPM
- pycharm如何安裝包?PyCharm
- iOS安裝包瘦身iOS
- LAMPrpm包安裝LAMP
- linux 安裝ps需要先安裝的rpm包Linux
- RPM應用——查詢(已安裝包和未安裝包)
- mysql5.7tar包的安裝MySql
- 升級安裝包的製作
- 安裝aab包的兩種方式
- 安裝R包常見的方法
- mysql安裝-----二進位制包安裝及解除安裝MySql
- rpm包安裝升級與解除安裝
- postgresql下載安裝包如何解壓安裝SQL
- Postgresql Linux版本安裝——RPM包安裝SQLLinux
- .net core 常用安裝包
- anaconda如何安裝包
- 快速安裝python包Python
- 中文BetterMouse破解安裝包
- LNMP一鍵安裝包LNMP
- 1、ZabbixRPM包安裝
- Ubuntu 搜尋安裝包Ubuntu
- 安裝Python requests包Python
- pip 命令安裝模組包