重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2399|回复: 0
打印 上一主题 下一主题

Oracle 表空间的I/O统计

[复制链接]
跳转到指定楼层
楼主
发表于 2014-11-11 21:08:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
查询过去2小时的表空间IO统计

select e.tsname tsname, 
       sum(e.phyrds - nvl(b.phyrds, 0)) reads, 
       sum(e.phyrds - nvl(b.phyrds, 0)) / 
       (SELECT EXTRACT(DAY FROM E.END_INTERVAL_TIME - B.END_INTERVAL_TIME) * 
               86400 + 
               EXTRACT(HOUR FROM E.END_INTERVAL_TIME - B.END_INTERVAL_TIME) * 3600 + 
               EXTRACT(MINUTE FROM E.END_INTERVAL_TIME - B.END_INTERVAL_TIME) * 60 + 
               EXTRACT(SECOND FROM E.END_INTERVAL_TIME - B.END_INTERVAL_TIME) 
          FROM DBA_HIST_SNAPSHOT B, DBA_HIST_SNAPSHOT E 
         WHERE B.SNAP_ID = (select snap_id from DBA_HIST_SNAPSHOT where end_interval_time >sysdate-3/24 and end_interval_time <sysdate-2/24 and rownum<2) 
           AND E.SNAP_ID = (select snap_id from DBA_HIST_SNAPSHOT where end_interval_time > sysdate-1/24 and rownum<2) 
           AND B.STARTUP_TIME = E.STARTUP_TIME 
           AND B.END_INTERVAL_TIME < E.END_INTERVAL_TIME) rps, 
       decode(sum(e.phyrds - nvl(b.phyrds, 0)), 
              0, 
              0, 
              10 * (sum(e.readtim - nvl(b.readtim, 0)) / 
              sum(e.phyrds - nvl(b.phyrds, 0)))) atpr, 
       decode(sum(e.phyrds - nvl(b.phyrds, 0)), 
              0, 
              0, 
              sum(e.phyblkrd - nvl(b.phyblkrd, 0)) / 
              sum(e.phyrds - nvl(b.phyrds, 0))) bpr, 
       sum(e.phywrts - nvl(b.phywrts, 0)) writes, 
       sum(e.phywrts - nvl(b.phywrts, 0)) / 
       (SELECT EXTRACT(DAY FROM E.END_INTERVAL_TIME - B.END_INTERVAL_TIME) * 
               86400 + 
               EXTRACT(HOUR FROM E.END_INTERVAL_TIME - B.END_INTERVAL_TIME) * 3600 + 
               EXTRACT(MINUTE FROM E.END_INTERVAL_TIME - B.END_INTERVAL_TIME) * 60 + 
               EXTRACT(SECOND FROM E.END_INTERVAL_TIME - B.END_INTERVAL_TIME) 
          FROM DBA_HIST_SNAPSHOT B, DBA_HIST_SNAPSHOT E 
         WHERE B.SNAP_ID = (select snap_id from DBA_HIST_SNAPSHOT where end_interval_time >sysdate-3/24 and end_interval_time <sysdate-2/24 and rownum<2) 
           AND E.SNAP_ID = (select snap_id from DBA_HIST_SNAPSHOT where end_interval_time > sysdate-1/24 and rownum<2) 
           AND B.STARTUP_TIME = E.STARTUP_TIME 
           AND B.END_INTERVAL_TIME < E.END_INTERVAL_TIME) wps, 
       sum(e.wait_count - nvl(b.wait_count, 0)) waits, 
       decode(sum(e.wait_count - nvl(b.wait_count, 0)), 
              0, 
              0, 
              10 * (sum(e.time - nvl(b.time, 0)) / 
              sum(e.wait_count - nvl(b.wait_count, 0)))) atpwt, 
       sum(e.phyrds - nvl(b.phyrds, 0)) + 
       sum(e.phywrts - nvl(b.phywrts, 0)) ios 
  from dba_hist_filestatxs e, dba_hist_filestatxs b 
where b.snap_id = (select snap_id from DBA_HIST_SNAPSHOT where end_interval_time >sysdate-3/24 and end_interval_time <sysdate-2/24 and rownum<2) 
   and e.snap_id = (select snap_id from DBA_HIST_SNAPSHOT where end_interval_time > sysdate-1/24 and rownum<2) 
   and b.dbid = e.dbid 
   and b.instance_number = e.instance_number 
   and b.tsname = e.tsname 
   and b.file# = e.file# 
   and b.creation_change# = e.creation_change# 
   and ((e.phyrds - nvl(b.phyrds, 0)) + (e.phywrts - nvl(b.phywrts, 0))) > 0 
group by e.tsname 
union all
select e.tsname tsname, 
       sum(e.phyrds - nvl(b.phyrds, 0)) reads, 
       sum(e.phyrds - nvl(b.phyrds, 0)) / 
       (SELECT EXTRACT(DAY FROM E.END_INTERVAL_TIME - B.END_INTERVAL_TIME) * 
               86400 + 
               EXTRACT(HOUR FROM E.END_INTERVAL_TIME - B.END_INTERVAL_TIME) * 3600 + 
               EXTRACT(MINUTE FROM E.END_INTERVAL_TIME - B.END_INTERVAL_TIME) * 60 + 
               EXTRACT(SECOND FROM E.END_INTERVAL_TIME - B.END_INTERVAL_TIME) 
          FROM DBA_HIST_SNAPSHOT B, DBA_HIST_SNAPSHOT E 
         WHERE B.SNAP_ID = (select snap_id from DBA_HIST_SNAPSHOT where end_interval_time >sysdate-3/24 and end_interval_time <sysdate-2/24 and rownum<2) 
           AND E.SNAP_ID = ( select snap_id from DBA_HIST_SNAPSHOT where end_interval_time > sysdate-1/24 and rownum<2) 
           AND B.END_INTERVAL_TIME < E.END_INTERVAL_TIME) rps, 
       decode(sum(e.phyrds - nvl(b.phyrds, 0)), 
              0, 
              0, 
              (sum(e.readtim - nvl(b.readtim, 0)) / 
              sum(e.phyrds - nvl(b.phyrds, 0))) * 10) atpr, 
       decode(sum(e.phyrds - nvl(b.phyrds, 0)), 
              0, 
              to_number(NULL), 
              sum(e.phyblkrd - nvl(b.phyblkrd, 0)) / 
              sum(e.phyrds - nvl(b.phyrds, 0))) bpr, 
       sum(e.phywrts - nvl(b.phywrts, 0)) writes, 
       sum(e.phywrts - nvl(b.phywrts, 0)) / 
       (SELECT EXTRACT(DAY FROM E.END_INTERVAL_TIME - B.END_INTERVAL_TIME) * 
               86400 + 
               EXTRACT(HOUR FROM E.END_INTERVAL_TIME - B.END_INTERVAL_TIME) * 3600 + 
               EXTRACT(MINUTE FROM E.END_INTERVAL_TIME - B.END_INTERVAL_TIME) * 60 + 
               EXTRACT(SECOND FROM E.END_INTERVAL_TIME - B.END_INTERVAL_TIME) 
          FROM DBA_HIST_SNAPSHOT B, DBA_HIST_SNAPSHOT E 
         WHERE B.SNAP_ID = (select snap_id from DBA_HIST_SNAPSHOT where end_interval_time >sysdate-3/24 and end_interval_time <sysdate-2/24 and rownum<2) 
           AND E.SNAP_ID = (select snap_id from DBA_HIST_SNAPSHOT where end_interval_time > sysdate-1/24 and rownum<2) 
           AND B.STARTUP_TIME = E.STARTUP_TIME 
           AND B.END_INTERVAL_TIME < E.END_INTERVAL_TIME) wps, 
       sum(e.wait_count - nvl(b.wait_count, 0)) waits, 
       decode(sum(e.wait_count - nvl(b.wait_count, 0)), 
              0, 
              0, 
              (sum(e.time - nvl(b.time, 0)) / 
              sum(e.wait_count - nvl(b.wait_count, 0))) * 10) atpwt, 
       sum(e.phyrds - nvl(b.phyrds, 0)) + 
       sum(e.phywrts - nvl(b.phywrts, 0)) ios 
  from dba_hist_tempstatxs e, dba_hist_tempstatxs b 
where b.snap_id = (select snap_id from DBA_HIST_SNAPSHOT where end_interval_time >sysdate-3/24 and end_interval_time <sysdate-2/24 and rownum<2) 
   and e.snap_id = (select snap_id from DBA_HIST_SNAPSHOT where end_interval_time > sysdate-1/24 and rownum<2) 
   and b.dbid = e.dbid 
   and b.instance_number = e.instance_number 
   and b.tsname = e.tsname 
   and b.file# = e.file# 
   and b.creation_change# = e.creation_change# 
   and ((e.phyrds - nvl(b.phyrds, 0)) + (e.phywrts - nvl(b.phywrts, 0))) > 0 
group by e.tsname 
order by ios desc, tsname;
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-11-25 08:16 , Processed in 0.135916 second(s), 21 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表