AWR TOP SQL實現
1 按解析次數排序
select a.*, to_char(substr(b.sql_text,1,4000)) from (select dhs.sql_id, sum(parse_calls_delta) parse, sum(executions_delta) exec_nums, dhs.MODULE from dba_hist_sqlstat dhs where snap_id > 22438 and snap_id <= 22440 group by dhs.sql_id,MODULE) a, dba_hist_sqltext b where a.sql_id=b.sql_id order by a.parse desc;
2 按執行時間排序
select a.*, to_char(substr(b.sql_text,1,4000)) from (select dhs.sql_id, round(sum(elapsed_time_delta)/1000/1000,2) "elapsed_time(s)", sum(executions_delta) execs, round(sum(elapsed_time_delta)/1000/1000/sum(executions_delta),2) elapsed_time_per, dhs.MODULE from dba_hist_sqlstat dhs where snap_id > 22438 and snap_id <= 22440 group by dhs.sql_id,MODULE) a, dba_hist_sqltext b where a.sql_id=b.sql_id order by a."elapsed_time(s)" desc;
3 按CPU時間排序
select a.*, to_char(substr(b.sql_text,1,4000)) from (select dhs.sql_id, round(sum(cpu_time_delta)/1000/1000,2) "cpu_time", sum(executions_delta) execs, round(sum(cpu_time_delta)/1000/1000/sum(executions_delta),2) cpu_time_per, round(sum(elapsed_time_delta)/1000/1000,2) "elapsed_time(s)", dhs.MODULE from dba_hist_sqlstat dhs where snap_id > 22438 and snap_id <= 22440 group by dhs.sql_id,MODULE) a, dba_hist_sqltext b where a.sql_id=b.sql_id order by a."cpu_time" desc;
4 按User I/O wait排序
select a.*, to_char(substr(b.sql_text,1,4000)) from (select dhs.sql_id, round(sum(iowait_delta)/1000/1000,2) "iowait_time(s)", sum(executions_delta) execs, round(sum(iowait_delta)/1000/1000/sum(executions_delta),2) iowait_time_per, round(sum(elapsed_time_delta)/1000/1000,2) "elapsed_time(s)", dhs.MODULE from dba_hist_sqlstat dhs where snap_id > 22438 and snap_id <= 22440 group by dhs.sql_id,MODULE) a, dba_hist_sqltext b where a.sql_id=b.sql_id order by a."iowait_time(s)" desc;
5 按邏輯讀(gets)排序
select a.*, to_char(substr(b.sql_text,1,4000)) from (select dhs.sql_id, round(sum(buffer_gets_delta),2) "buffer_ges", sum(executions_delta) execs, round(sum(buffer_gets_delta)/sum(executions_delta),2) iowait_time_per, round(sum(elapsed_time_delta)/1000/1000,2) "elapsed_time(s)", dhs.MODULE from dba_hist_sqlstat dhs where snap_id > 22438 and snap_id <= 22440 group by dhs.sql_id,MODULE) a, dba_hist_sqltext b where a.sql_id=b.sql_id order by a."buffer_ges" desc;
7 按物理讀(physical read)排序
select a.*, to_char(substr(b.sql_text,1,4000)) from (select dhs.sql_id, round(sum(DISK_READS_DELTA),2) "physical_read", sum(executions_delta) execs, round(sum(DISK_READS_DELTA)/sum(executions_delta),2) iowait_time_per, round(sum(elapsed_time_delta)/1000/1000,2) "elapsed_time(s)", dhs.MODULE from dba_hist_sqlstat dhs where snap_id > 22438 and snap_id <= 22440 group by dhs.sql_id,MODULE) a, dba_hist_sqltext b where a.sql_id=b.sql_id order by a."physical_read" desc;
8 按執行次數排序
select a.*, to_char(substr(b.sql_text,1,4000)) from (select dhs.sql_id, round(sum(executions_delta),2) "exec_num", sum(ROWS_PROCESSED_DELTA) row_process, round(sum(ROWS_PROCESSED_DELTA)/sum(executions_delta),2) rows_per_exec, round(sum(elapsed_time_delta)/1000/1000,2) "elapsed_time(s)", dhs.MODULE from dba_hist_sqlstat dhs where snap_id > 22438 and snap_id <= 22440 group by dhs.sql_id,MODULE) a, dba_hist_sqltext b where a.sql_id=b.sql_id order by a."exec_num" desc;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28572479/viewspace-2649803/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle AWR Top SQL sectionOracleSQL
- awr的top sql分析SQL
- AWR 中 top sql 的資訊獲取 - 分析SQL
- AWR中的SQL StatisticsSQL
- AWR--Top 5 Timed Foreground Events
- ORACLE TOP SQLOracleSQL
- Top 20 SqlSQL
- SQL生成AWR中的SQL ordered by Elapsed TimeSQL
- AWR報告,頻頻出現熱點SYS_IOT_TOP_8872,請高手指教
- shell指令碼實現自動生成awr報告指令碼
- [Oracle Script] Top sqlOracleSQL
- trace top sql sessionSQLSession
- 各種TOP SQLSQL
- SQL TOP 例項SQL
- _awr_sql_child_limit是否能控制awr記錄sql執行次數的問題SQLMIT
- Oracle AWR報告分析之–SQL ordered byOracleSQL
- awr 中單個SQL 效能檢視SQL
- Retrieve SQL and Execution Plan from AWR SnapshotsSQL
- Subject: "class slave wait" is the top wait event on AWR snapshotAI
- Oracle 10g,AWR,AWR,ADDM最佳實踐Oracle 10g
- 基於AWR實現STATSPACK報告(4-等待事件)事件
- 基於AWR實現STATSPACK報告(5-TOPSQL)SQL
- 基於AWR實現STATSPACK報告(7-TOPSEGMENT)
- 【AWR】通過AWR報告中記錄的 SQL Id獲得SQL語句的執行計劃SQL
- postgresql定位top cpu sqlSQL
- Oracle檢視TOP SQLOracleSQL
- Oracle TOP SQL&&HITOracleSQL
- TOP N 查詢 SQLSQL
- top sql capture script.SQLAPT
- awr報表中用到的幾個SQLSQL
- Script to generate AWR report from remote sql clientREMSQLclient
- 基於AWR實現STATSPACK報告(2-系統效率)
- 基於AWR實現STATSPACK報告(3-RAC統計)
- 基於AWR實現STATSPACK報告(6-例項元件)元件
- wait等待事件及其處理方法 awr top5 報告AI事件
- [20130803]ORACLE 12C TOP N SQL實現分頁功能.txtOracleSQL
- 12C SQL-TOPSQL
- 基於AWR實現STATSPACK報告(1-系統負載)負載