分享更有价值
被信任是一种快乐

Oracle如何查看历史TOP SQL

文章页正文上

这篇文章给大家分享的是有关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 and snap_id 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 and snap_id 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.cp免费主机域名ut/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 and snap_id group by sql_id) a
where a.sql_id = b.sql_id
order by diskread desc;
感谢各位的阅读!关于“Oracle如何查看历史TOP SQL”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

相关推荐: MySQL如何实现Apache用户认证

这篇文章主要介绍MySQL如何实现Apache用户认证,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!apache要求DSO方式编译安装,假定apache安装在/usr/local/apache目录下,mysql假设安装在了/usr/lo…

文章页内容下
赞(0) 打赏
版权声明:本站采用知识共享、学习交流,不允许用于商业用途;文章由发布者自行承担一切责任,与本站无关。
文章页正文下
文章页评论上

云服务器、web空间可免费试用

宝塔面板主机、支持php,mysql等,SSL部署;安全高速企业专供99.999%稳定,另有高防主机、不限制内容等类型,具体可咨询QQ:360163164,Tel同微信:18905205712

主机选购导航云服务器试用

登录

找回密码

注册