Monday, July 18, 2011

What is running in my database?

Have you ever wondered what is running in the database at any given time and how to find it?

Simply run the below SQL command on your Oracle Database. It will give tell who is running what. Yes, this is RAC friendly. You may need to format the output. This is very handy to have for a DBA to see the snapshot of what is running in the database. It is a good first step to diagnose any Performance issue.

select  s.inst_id "Inst",s.sid||','||s.serial# sidserial,osuser,username,
   sql_id sql_id,
   module,
   substr(s.event,1,27) event,
   s.last_call_et "Wait", s.machine
from gv$session s
where status = 'ACTIVE'
and event not like 'Streams AQ: waiting%'
and event not like 'Streams AQ:%idle%'
and s.event not like 'LNS%'
and (s.event not like '%idle wait%')
and  s.event not in ('PL/SQL lock timer','SQL*Net message from client','queue messages',
'rdbms ipc message','Streams AQ: waiting for messages in the queue','smon timer','wakeup time manager','async disk IO',
'pipe get','pmon timer','gcs remote message','ges remote message','log file sync','jobq slave wait','slave wait')
order by module,sql_hash_value

No comments:

Post a Comment