Pages

Friday, July 11, 2014

Oracle Long operation monitoring


Lock session

select v$session.username,
           v$lock.sid,
               id1, id2,
           lmode,
               request, block, v$lock.type , v$session.osuser , v$session.machine , v$session.process , v$process.pid
    from v$lock, v$session , v$process
    where v$lock.sid = v$session.sid
    and v$lock.type = 'TX'
    and v$process.addr = v$session.paddr
  order by username

active long operation

select username||'('||sid||','||serial#||') ospid = '|| process ||
    ' program = ' || program username,
    to_char(LOGON_TIME,' Day HH24:MI') logon_time,
    to_char(sysdate,' Day HH24:MI') current_time,
    sql_address,
    sql_hash_value , a.osuser ,a.machine  ,a.last_call_et   
   from v$session a
   where status = 'ACTIVE'
   and rawtohex(sql_address) <> '00'
   and username is not null
   order by last_call_et desc

Long opseration details

 select  distinct x.sid , a.machine  , x.opname , a.program  , x.target , x.sofar ,x.totalwork , x.start_time , x.last_update_time ,x.time_remaining , x.elapsed_seconds , context , message,
           sql_text
  from v$session_longops x , gv$sqlarea y , v$session a
  where x.username = 'SYS'
  and x.sql_hash_value = y.HASH_VALUE
  and a.sid = x.sid
  and a.status = 'ACTIVE'
  order by TIME_REMAINING desc

No comments:

Post a Comment