快速定位抓取系統繁忙的AWR

lovehewenyu發表於2013-08-05

快速定位抓取系統繁忙的AWR
本文屬於讀《循序漸進ORACLE》後有感,記錄eygle大師的指令碼。以備以後使用!
select i.db_name db_name, 
       s.snap_id snap_id, 
       to_char(s.startup_time, 'mm/dd/yyyy HH24:MI:SS') startup_time, 
       to_char(s.begin_interval_time, 'mm/dd/yyyy HH24:MI:SS') begin_interval_time, 
       to_char(s.end_interval_time, 'mm/dd/yyyy HH24:MI:SS') end_interval_time, 
       round(extract(day from s.end_interval_time - s.begin_interval_time) * 1440 + 
             extract(hour from s.end_interval_time - s.begin_interval_time) * 60 + 
             extract(minute from 
                     s.end_interval_time - s.begin_interval_time) + 
             extract(second from 
                     s.end_interval_time - s.begin_interval_time) / 60, 
             2) elapsed_time, 
       round((e.value - b.value) / 1000000 / 60, 2) db_time, 
       round(((((e.value - b.value) / 1000000 / 60) / 
             (extract(day from 
                        s.end_interval_time - s.begin_interval_time) * 1440 + 
             extract(hour from 
                        s.end_interval_time - s.begin_interval_time) * 60 + 
             extract(minute from 
                        s.end_interval_time - s.begin_interval_time) + 
             extract(second from 
                        s.end_interval_time - s.begin_interval_time) / 60)) * 100),  2 ) pct_db_time 
  from wrm$_snapshot s, 
       (select distinct dbid, db_name 
          from wrm$_database_instance 
         where db_name = 'ORCL') i, 
       dba_hist_sys_time_model e, 
       dba_hist_sys_time_model b 
 where i.dbid = s.dbid 
   and s.dbid = b.dbid 
   and b.dbid = e.dbid 
   and e.snap_id = s.snap_id 
   and b.snap_id = s.snap_id - 1 
   and e.stat_id = b.stat_id 
   and e.stat_name = 'DB time' 
 order by i.db_name, s.snap_id

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26442936/viewspace-767826/,如需轉載,請註明出處,否則將追究法律責任。

相關文章