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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20230203]完善awr.sql指令碼.txtSQL指令碼
- [20221208]完善bind_cap_awr.sql指令碼.txtSQL指令碼
- postgresql定位top cpu sqlSQL
- Oracle檢視歷史TOP SQLOracleSQL
- Lumen 實現 SQL 監聽SQL
- 用pandas實現SQL功能SQL
- ORACLE AWROracle
- 【AWR】Oracle資料庫建立awr基線Oracle資料庫
- 【AWR】Oracle批量生成awr報告指令碼Oracle指令碼
- 位運算與SQL實現SQL
- 講講AWR
- 實現MyBatisPlus自定義sql注入器MyBatisSQL
- mybatis實現變數定義,實現sql業務程式碼MyBatis變數SQL
- 【AWR】Oracle awr相關檢視及體系介紹Oracle
- 【最佳化】AWR
- oracle工具 awr formatOracleORM
- monaco-editor 實現SQL編輯器SQL
- SQL Azure使用Excel實現BI功能:PowerPivotTWSQLExcel
- Spark Streaming + Spark SQL 實現配置化ETSparkSQL
- Oracle 11.2.0.3.0中執行awrrpt.sql生成awr報告報ora-06502錯誤OracleSQL
- 3 條 sql 是實現知乎評論,7 條 sql 實現點贊 + 評論,且可擴充套件SQL套件
- SQL如何實現查詢節點依賴SQL
- Flink SQL 如何實現資料流的 Join?SQL
- SQL 如何實現動態的行列轉置SQL
- 【轉】【SQL】 實現左單一匹配SQL
- Cobar SQL審計的設計與實現SQL
- Flink sql實現原理及Apache Calcite介紹SQLApache
- ASH可以生成指定的session或sql_id的報告,ASH和AWR的區別SessionSQL
- awr-----一份經典的負載很高的awr報告負載
- 論文復現丨基於ModelArts實現Text2SQLSQL
- Spark SQL:實現日誌離線批處理SparkSQL
- MyBatis標籤實現的動態SQL語句MyBatisSQL
- Lumen XSS 防禦 和 SQL 注入怎樣實現SQL
- java-Mybatis 註解方式實現sql語句JavaMyBatisSQL
- sql?server?累計求和實現程式碼簏攔SQLServer
- SQL Server2005使用CTE實現遞迴QCSQLServer遞迴
- flyway實現java 自動升級SQL指令碼JavaSQL指令碼
- statspack、awr、addm,ash影片分享