4
2

More than 5 years have passed since last update.

AWRから指定した期間のload profileをcsv形式で取得する方法

Last updated at Posted at 2016-04-08

AWRのload profileをcsv形式で出力するためのスクリプト例です。

get_load_profile.sql

set termout off
set pagesize 0
set linesize 10000
set trimspool on
set heading off

spool load_profile.log
prompt begin_snapid,yyyy,mm,dd,hh,end_snapid,instance_num,name,value

select                                         '"' ||
    bsn.SNAP_ID                           || '","' ||
    to_char(bsn.END_INTERVAL_TIME,'yyyy') || '","' ||
    to_char(bsn.END_INTERVAL_TIME,'mm')   || '","' ||
    to_char(bsn.END_INTERVAL_TIME,'dd')   || '","' ||
    to_char(bsn.END_INTERVAL_TIME,'hh24') || '","' ||
    esn.SNAP_ID                           || '","' ||
    bsn.INSTANCE_NUMBER                   || '","' ||
    bsy.STAT_NAME                         || '","' ||
    (esy.VALUE - bsy.VALUE)               || '"'
from
    DBA_HIST_SNAPSHOT bsn,
    DBA_HIST_SNAPSHOT esn,
    DBA_HIST_SYSSTAT  bsy,
    DBA_HIST_SYSSTAT  esy
where 
        bsn.DBID = esn.DBID
    and bsn.INSTANCE_NUMBER = esn.INSTANCE_NUMBER
    and bsn.END_INTERVAL_TIME = esn.BEGIN_INTERVAL_TIME
    and bsn.STARTUP_TIME = esn.STARTUP_TIME
    and bsn.DBID = bsy.DBID
    and bsn.INSTANCE_NUMBER = bsy.INSTANCE_NUMBER
    and bsn.SNAP_ID = bsy.SNAP_ID
    and esn.DBID = esy.DBID
    and esn.INSTANCE_NUMBER = esy.INSTANCE_NUMBER
    and esn.SNAP_ID = esy.SNAP_ID
    and bsy.STAT_NAME = esy.STAT_NAME
    and bsy.STAT_NAME in ('execute count','parse count (hard)','consistent gets',
                          'physical reads','redo size')
    and bsn.END_INTERVAL_TIME >= to_date('2016/04/05 09:50','yyyy/mm/dd hh24:mi')
    and esn.END_INTERVAL_TIME <= to_date('2016/04/08 13:10','yyyy/mm/dd hh24:mi')
order by bsn.SNAP_ID;
spool off
/

出力されたデータをexcelに取り込み、
ピボットグラフを活用することで容易に可視化できます。

カラムをカンマで分割
excel.png

ピボットグラフを選択
pivot.png

軸、列を指定し整形
graph.png

グラフ化することで複数期間にわたる傾向分析が容易にできます。
(SQLはDB12.1.0.2にて試行)

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2