このブログを検索

2011年3月2日水曜日

長時間実行しているセッションを調べる

何かしらの待機により残ったままのセッションおよびそのSQLを調べます。
新規、かつ、実行途中のSQLexecutions=0のままなので、除算エラーにならないようにしています。
set time on
set pages 10000
set lines 100
set long 20000
col program for a50
col username for a20
col status for a10
col sql_fulltext for a100
alter session set nls_date_format='yyyy/mm/dd hh24:mi:ss';
select s.sid,s.serial#,s.username,s.logon_time,s.status,
  q.sharable_mem,q.elapsed_time/nvl(nullif(executions,0),1)/1000/1000 as executions,
  s.program,
  replace(replace(replace(q.sql_fulltext,chr(9),''),chr(10),' '),'  ',' ') as sql
from v$session s,v$sqlstats q
where s.sql_id=q.sql_id and username<>'SYS'
order by s.logon_time desc
;
実行結果は次の通り。
SID    SERIAL# USERNAME             LOGON_TIME          STATUS     SHARABLE_MEM EXECUTIONS
------ ---------- -------------------- ------------------- ---------- ------------ ----------
PROGRAM
--------------------------------------------------
SQL
--------------------------------------------------------------------------------
   476       9190 SSS01DBIUSER         2011/03/02 17:33:06 INACTIVE          16408 .001146854
httpd@sssweb24.sss.co.jp (TNS V1-V3)
select user_id,item_id,item_count,to_char( update_dt, 'yyyy/mm/dd hh24:mi:ss')
 as update_dt from TBL_StartAvatar1 where item_id=:i
tem_id1 and user_id=:user_id2 and item_count>:item_c
ount3 order by update_dt desc

0 件のコメント:

コメントを投稿