Check Active Sessions History Jp
アクティブセッション履歴の確認
オラクルのアクティブセッションはサーバの処理負荷に深く関わりがあります。
アクティブセッションの履歴を確認する必要があります。
しかし、v$active_session_historyにある情報は非常に細かく、
直接確認・監視することは容易ではないんです。
下記のSQLは
・前日の履歴を対象
・秒ごと最大アクティブセッションが15以上到達
・分の時間帯ごとに
時間を洗い出す。
select to_date(substr(st, 1, 12), 'yyyymmddhh24mi') sample_mi, max(cnt) from (select to_char(sample_time, 'yyyymmddhh24miss') st, count(*) cnt from v$active_session_history ash where sample_time between trunc(sysdate) - 1 and trunc(sysdate) group by to_char(sample_time, 'yyyymmddhh24miss') having count(*) > 20) ash group by to_date(substr(st, 1, 12), 'yyyymmddhh24mi') order by sample_mi;
下記のコードは上記の分単位の時間帯のアクティブセッションの情報を抽出する。
分単位で少し多く情報を取得するようになるが、コンテクストも抽出するので、より問題を判別しやすくなる。
結合に非効率の方法を利用しているが、メモリ上のビューだから、一万件ほどのレコードはサーバにとっては問題ならない。
select ash.* from v$active_session_history ash, (select to_date(substr(st, 1, 12), 'yyyymmddhh24mi') sample_mi_begin, to_date(substr(st, 1, 12), 'yyyymmddhh24mi') + 1/24/60 sample_mi_end, max(cnt) from (select to_char(sample_time, 'yyyymmddhh24miss') st, count(*) cnt from v$active_session_history ash where sample_time between trunc(sysdate) - 1 and trunc(sysdate) group by to_char(sample_time, 'yyyymmddhh24miss') having count(*) > 20) ash group by to_date(substr(st, 1, 12), 'yyyymmddhh24mi') order by 1) mi where trunc(ash.sample_time, 'mi') = mi.sample_mi_begin