基於AWR對特定的SQL_ID檢視詳細的歷史執行情況
set verify on lines 200 pages 9999
undefine sqlid
accept level char DEFAULT 'ADVANCED' PROMPT "Explain Plan level (BASIC, TYPICAL, ALL, ADVANCED) (Default : ADVANCED) : "
col cpu_exe format 9999.9999
col ela_exe format 9999.9999
col prds_exe format 9999.9999
col bg_exe format 99999999
col rows_exe format 999999
col snap_time format a14
col inst format 999
col sql_id new_value sqlid noprint
break on plan_hash_value skip 1
select
sql_id,
plan_hash_value,
s.instance_number inst,
s.snap_id,
to_char(s.begin_interval_time,'YYYYMMDD:HH24:MI') snap_time,
executions_delta delta_exe,
cpu_time_delta/1000000 delta_cpu_sec,
(case when executions_delta>0 then ((cpu_time_delta/1000000)/executions_delta) else 0 end) cpu_exe,
(case when executions_delta>0 then ((elapsed_time_delta/1000000)/executions_delta) else 0 end) ela_exe,
(case when executions_delta>0 then (buffer_gets_delta/executions_delta) else 0 end) bg_exe,
(case when executions_delta>0 then (disk_reads_delta/executions_delta) else 0 end) prd_exe,
(case when executions_delta>0 then (rows_processed_delta/executions_delta) else 0 end) rows_exe
from
dba_hist_sqlstat b,
dba_hist_snapshot s
where
b.sql_id = '&sqlid'
and b.snap_id = s.snap_id
and s.begin_interval_time >= sysdate-&days_back
and s.instance_number = b.instance_number
order by
2,3,4
;
select * from table(dbms_xplan.display_awr('&sqlid','','','&level'))
;
undefine sqlid
clear columns
clear breaks
undefine sqlid
accept level char DEFAULT 'ADVANCED' PROMPT "Explain Plan level (BASIC, TYPICAL, ALL, ADVANCED) (Default : ADVANCED) : "
col cpu_exe format 9999.9999
col ela_exe format 9999.9999
col prds_exe format 9999.9999
col bg_exe format 99999999
col rows_exe format 999999
col snap_time format a14
col inst format 999
col sql_id new_value sqlid noprint
break on plan_hash_value skip 1
select
sql_id,
plan_hash_value,
s.instance_number inst,
s.snap_id,
to_char(s.begin_interval_time,'YYYYMMDD:HH24:MI') snap_time,
executions_delta delta_exe,
cpu_time_delta/1000000 delta_cpu_sec,
(case when executions_delta>0 then ((cpu_time_delta/1000000)/executions_delta) else 0 end) cpu_exe,
(case when executions_delta>0 then ((elapsed_time_delta/1000000)/executions_delta) else 0 end) ela_exe,
(case when executions_delta>0 then (buffer_gets_delta/executions_delta) else 0 end) bg_exe,
(case when executions_delta>0 then (disk_reads_delta/executions_delta) else 0 end) prd_exe,
(case when executions_delta>0 then (rows_processed_delta/executions_delta) else 0 end) rows_exe
from
dba_hist_sqlstat b,
dba_hist_snapshot s
where
b.sql_id = '&sqlid'
and b.snap_id = s.snap_id
and s.begin_interval_time >= sysdate-&days_back
and s.instance_number = b.instance_number
order by
2,3,4
;
select * from table(dbms_xplan.display_awr('&sqlid','','','&level'))
;
undefine sqlid
clear columns
clear breaks
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29446986/viewspace-1431525/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle檢視sql_id 的歷史執行計劃OracleSQL
- 【AWR】DBA_HIST檢視檢視儲存在AWR中的歷史資料
- OushuDB 檢視查詢執行情況
- win10 檢視 特定網路 詳細資訊Win10
- git檢視提交歷史Git
- Git(7)-- 檢視提交歷史(git log 命令詳解)Git
- Oracle檢視歷史TOP SQLOracleSQL
- 在Linux中,如何檢視磁碟詳細使用情況?Linux
- Oracle錶的歷史統計資訊檢視Oracle
- 依靠dba_hist_tbspc_space_usage檢視獲得表空間的歷史使用情況
- Git檢視某個歷史版本的最佳實踐Git
- Linux檢視歷史記錄小技巧Linux
- git log檢視提交歷史記錄Git
- git簡略形式檢視提交歷史Git
- 檢視temp表空間的消耗明細情況
- 來回修改的文件,怎麼檢視、管理歷史版本?
- Git新手教程-檢視倉庫的歷史記錄(四)Git
- [20180322]檢視統計資訊的儲存歷史.txt
- 檢視Spark任務的詳細資訊Spark
- prepareStatement和Statement執行批處理的執行情況REST
- win10怎樣看歷史記錄_win10檢視歷史記錄的方法Win10
- oracle 歷史檢視檢視,看這一篇就夠了Oracle
- 【第八篇】- Git 檢視提交歷史Git
- Mac上的Safari瀏覽器如何檢視歷史記錄?Mac瀏覽器
- PostgreSQL如何檢視page、index的詳細資訊SQLIndex
- 工作流中的流程追溯!詳細解析Activiti框架中的歷史元件框架元件
- 【AWR】Oracle awr相關檢視及體系介紹Oracle
- 檢視提交歷史 —— Git 學習筆記 11Git筆記
- 04-drf檢視層詳細
- 『現學現忘』Git基礎 — 24、Git中檢視歷史版本記錄Git
- WGCLOUD部署筆記 配置監測redis的執行情況GCCloud筆記Redis
- 基於Git rebase修改歷史提交資訊Git
- ASH可以生成指定的session或sql_id的報告,ASH和AWR的區別SessionSQL
- 基於ROWID更新的物化檢視測試
- ash報告中無sql_id的情況SQL
- Logback詳細整理,基於springboot的日誌配置Spring Boot
- 執行緒池如何觀測?這個方案讓你對執行緒池的執行情況瞭如指掌!執行緒
- Linux下快速執行歷史命令的方法Linux
- Pycharm 如何檢視程式碼修改歷史|回滾程式碼PyCharm