查询DB time:

SELECT INSTANCE_NUMBER, SAMPLE_TIME, DELTA DB_TIME

  FROM (SELECT T1.SNAP_ID,

               T1.INSTANCE_NUMBER,

               TO_CHAR(T2.END_INTERVAL_TIME, 'YYYYMMDD HH24:MI:SS') AS SAMPLE_TIME,

               T1.STAT_NAME,

               T1.VALUE - LAG(T1.VALUE, 1) OVER(ORDER BY T1.SNAP_ID ASC) AS DELTA

          FROM DBA_HIST_SYS_TIME_MODEL T1, DBA_HIST_SNAPSHOT T2

         WHERE T1.INSTANCE_NUMBER = T2.INSTANCE_NUMBER

           AND T1.INSTANCE_NUMBER = 1

           AND T1.SNAP_ID = T2.SNAP_ID

           AND T1.STAT_NAME = 'DB time'

           AND T2.END_INTERVAL_TIME > SYSDATE - 30)

 WHERE DELTA > 0

 ORDER BY SNAP_ID ASC

IOPS:

SELECT snap_id,

       intervalseconds,

       t_begin,

       t_end,

       round(sum(delta) / intervalseconds) as iops

  FROM (select t1.snap_id,

               t1.instance_number,

               extract(day from intervala) * 86400 +

               extract(hour from intervala) * 3600 +

               extract(minute from intervala) * 60 +

               extract(second from intervala) as intervalseconds,

               to_char(t2.begin_interval_time, 'YYYY-MM-DD HH24:MI:SS') AS T_BEGIN,

               TO_CHAR(T2.END_INTERVAL_TIME, 'YYYY-MM-DD HH24:MI:SS') AS T_END,

               T1.stat_NAME,

               T1.value - LAG(T1.VALUE, 1) OVER(PARTITION BY T1.INSTANCE_nUMBER, t1.stat_name ORDER BY T1.SNAP_ID ASC) AS DELTA

          from dba_hist_sysstat t1,

               (select snap_id,

                       begin_interval_time,

                       end_interval_time,

                       instance_number,

                       (end_interval_time - begin_interval_time) as intervala

                  from dba_hist_snapshot

                 where instance_number = 1) t2

         where t1.snap_id = t2.snap_id

           and t1.STAT_NAME in

               ('physical read total IO requests',

                'physical write total IO requests')

              --and t1.instance_number = t2.instance_number                

              --and t1.instance_number = 3                

           and t2.begin_interval_time > sysdate - 30)

 WHERE DELTA > 0

 group by snap_id, intervalseconds, t_begin, t_end

 order by snap_id asc;


log file sync:

with t as

 (select s.snap_id,

         s.instance_number,

         s.end_interval_time,

         total_waits - lag(total_waits, 1) over(partition by s.instance_number order by s.snap_id) waits,

         (time_waited_micro - lag(time_waited_micro, 1)

          over(partition by s.instance_number order by s.snap_id)) / 1000 twt

    from dba_hist_system_event ev, dba_hist_snapshot s

   where ev.instance_number = s.instance_number

     and ev.instance_number = 1

     and ev.snap_id = s.snap_id

     and event_name = 'log file sync'

     and s.end_interval_time > sysdate - 30)

select instance_number,

       to_char(end_interval_time, 'YYYYMMDD HH24:MI') as sample_TIME,

       sum(twt) waittime,

       sum(waits) waitcount,

       round(sum(twt) / sum(waits), 2) logfilesyncavgms

  from t

 where instance_number = 1

   and waits > 0

 group by to_char(end_interval_time, 'YYYYMMDD HH24:MI'), instance_number

 order by 2, instance_number;