您好,登錄后才能下訂單哦!
這篇文章給大家分享的是有關Oracle如何查看歷史TOP SQL的內容。小編覺得挺實用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。
Oracle 查看歷史TOP SQL
歷史TOP SQL可以通過AWR直接查看,
但是有時AWR信息顯示不全,默認只顯示TOP 10,
可以通過dba_hist_sqltext,dba_hist_sqlstat等查看更詳細的信息;
---查看快照信息
---選擇2018-06-14全天的快照6504-6528;
---conn chenjch/chenjch
select SNAP_ID,
DBID,
to_char(BEGIN_INTERVAL_TIME, 'yyyy-mm-dd hh34:mi:ss'),
to_char(END_INTERVAL_TIME, 'yyyy-mm-dd hh34:mi:ss'),
FLUSH_ELAPSED,
SNAP_LEVEL
from dba_hist_snapshot order by 1;
---1 查看2018-06-14全天SQL ordered by Elapsed Time
---時間單位默認microseconds
select a.sql_id,
a.module,
a.elap,
a.exec,
decode(a.exec, 0, to_number(null), (a.elap / a.exec)) elap_one,
b.sql_text
from dba_hist_sqltext b,
(select sql_id,
max(module) module,
sum(elapsed_time_delta) / 1000000 elap,
sum(executions_delta) exec
from dba_hist_sqlstat
where dbid = 1000919065
and instance_number = 1
and 6504 < snap_id
and snap_id <= 6528
group by sql_id) a
where a.sql_id = b.sql_id
order by elap desc;
---2 查看2018-06-14全天SQL ordered by Gets
---時間單位默認microseconds
select a.sql_id,
a.module,
a.bget,
decode(a.exec, 0, to_number(null), a.bget / a.exec) get_per_exec,
a.exec,
(a.cput/1000000)/elap*100 CPU,
a.elap,
b.sql_text
from dba_hist_sqltext b,
(select sql_id,
max(module) module,
sum(buffer_gets_delta) bget,
sum(executions_delta) exec,
sum(cpu_time_delta) cput,
sum(elapsed_time_delta) / 1000000 elap
from dba_hist_sqlstat
where dbid = 1000919065
and instance_number = 1
and 6504 < snap_id
and snap_id <= 6528
group by sql_id) a
where a.sql_id = b.sql_id
order by bget desc;
---3 查看2018-06-14全天SQL ordered by Reads
---時間單位默認microseconds
select a.sql_id,
a.module,
a.diskread,
a.exec,
decode(a.exec, 0, to_number(null), a.diskread / a.exec) diskread_one,
(a.cput/1000000)/elap*100 CPU,
a.elap,
b.sql_text
from dba_hist_sqltext b,
(select sql_id,
max(module) module,
sum(disk_reads_delta) diskread,
sum(executions_delta) exec,
sum(cpu_time_delta) cput,
sum(elapsed_time_delta) / 1000000 elap
from dba_hist_sqlstat
where dbid = 1000919065
and instance_number = 1
and 6504 < snap_id
and snap_id <= 6528
group by sql_id) a
where a.sql_id = b.sql_id
order by diskread desc;
感謝各位的閱讀!關于“Oracle如何查看歷史TOP SQL”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,讓大家可以學到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。