SQL生成AWR中的SQL ordered by Elapsed Time
--提取&beg_snap 、&end_snap
select * from dba_hist_snapshot x ;
--提取&dbid
select * from v$database;
--提取$inst_num
select * from v$instance;
執行的時候輸入上面的值(如果需要輸入多次,那麼輸入同樣值即可)
select *
from (select round(nvl((sqt.elap / 1000000), to_number(null)),2) "Elapsed Time (s)",
round( nvl((sqt.cput / 1000000), to_number(null)),2) "CPU Time (s)",
sqt.exec, round(decode(sqt.exec, 0, to_number(null),
(sqt.elap / sqt.exec / 1000000)),2) "Elap per Exec (s)",
round((100 * (sqt.elap / (select sum(e.value) - sum(b.value)
from dba_hist_sys_time_model b,
dba_hist_sys_time_model e
where b.snap_id = &beg_snap and
e.snap_id = &end_snap and
b.dbid = &dbid and
e.dbid = &dbid and
b.instance_number = &inst_num and
e.instance_number = &inst_num and
e.stat_name = 'DB time' and
b.stat_name = 'DB time'))) ,2) norm_val ,
sqt.sql_id,
decode(sqt.module, null, null, 'Module: ' || sqt.module) SqlModule,
nvl(to_nchar(SUBSTR(st.sql_text,1,2000)) , (' ** SQL Text Not Available ** ')) SqlText
from ( select sql_id,
max(module) module,
sum(elapsed_time_delta) elap,
sum(cpu_time_delta) cput,
sum(executions_delta) exec
from dba_hist_sqlstat
where dbid = &dbid and
instance_number = &inst_num and
&beg_snap < snap_id and
snap_id <= &end_snap
group by sql_id ) sqt,
dba_hist_sqltext st
where st.sql_id(+) = sqt.sql_id and
st.dbid(+) = &dbid
order by nvl(sqt.elap, -1) desc,
sqt.sql_id)
where rownum < 65 and
(rownum <= 10 or norm_val > 1);
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/35489/viewspace-768609/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle透過AWR的SQL ordered by Gets和SQL ordered by Reads診斷問題OracleSQL
- Oracle AWR報告分析之–SQL ordered byOracleSQL
- AWR中的SQL StatisticsSQL
- AWR 中 top sql 的資訊獲取 - 分析SQL
- awr的top sql分析SQL
- Bad SQL 優化加提示 /*+ordered */SQL優化
- awr 中單個SQL 效能檢視SQL
- 【AWR】通過AWR報告中記錄的 SQL Id獲得SQL語句的執行計劃SQL
- AWR TOP SQL實現SQL
- Oracle AWR Top SQL sectionOracleSQL
- SQL Server中快速生成大量記錄的SQL指令碼SQLServer指令碼
- 學用ORACLE AWR和ASH特性(4)-生成指定SQL的統計報表OracleSQL
- SQL Server中timestamp(時間戳)SQLServer時間戳
- 一個SQL Server中的FormatDatetime函式SQLServerORM函式
- _awr_sql_child_limit是否能控制awr記錄sql執行次數的問題SQLMIT
- 使用sql生成sql指令碼SQL指令碼
- awr報表中用到的幾個SQLSQL
- Oracle優化案例-復現SQL ordered by Parse Calls(三十二)Oracle優化SQL
- Excel 生成SQLExcelSQL
- 通過shell指令碼抓取awr報告中的問題sql指令碼SQL
- 透過shell指令碼抓取awr報告中的問題sql指令碼SQL
- ASH可以生成指定的session或sql_id的報告,ASH和AWR的區別SessionSQL
- oracle實用sql(9)--批量生成一天的ash報告或awr報告OracleSQL
- Java中如何解析SQL語句、格式化SQL語句、生成SQL語句?JavaSQL
- Timeout expired. The timeout period elapsed prior to completion of the operation or the server is noServer
- oracle 10g awr 報告中內容所對應的sqlOracle 10gSQL
- Retrieve SQL and Execution Plan from AWR SnapshotsSQL
- Oracle Real Time SQL MonitorOracleSQL
- Oracle 11.2.0.3.0中執行awrrpt.sql生成awr報告報ora-06502錯誤OracleSQL
- SQL生成日曆SQL
- 【SQL】SQL中if條件的使用SQL
- Oracle AWR中常用到的幾個SQL語句OracleSQL
- 在Oracle 11.2.0.3.0中執行awrrpt.sql生成awr報告報ora-06502錯誤OracleSQL
- 自動生成Sql--基於Mybatis的單表SqlSQLMyBatis
- SQL Server中datetimeset轉換datetime型別問題淺析SQLServer型別
- Script to generate AWR report from remote sql clientREMSQLclient
- SQL Server的datetime儲存格式SQLServer
- 批量生成AWR