Thursday, January 5, 2012

Query to calculate CPU utilisation in a database.

http://www.stechno.net/sap-notes.html?view=sapnote&id=712624
===================================

select
ss.username,
se.SID,
VALUE/100 cpu_usage_seconds
from
v$session ss,
v$sesstat se,
v$statname sn
where
se.STATISTIC# = sn.STATISTIC#
and
NAME like '%CPU used by this session%'
and
se.SID = ss.SID
and
ss.status='ACTIVE'
and
ss.username is not null
order by VALUE desc;

----------------------------------------


Select sql_text from v$sql where address=(select sql_address from v$session where paddr=(select addr from v$process where spid= &spid));

Select sql_text from v$sql where address in (select sql_address from v$session where paddr in (select addr from v$process where spid=622666));

Select sql_text from v$sqltext where hash_value=(select sql_hash_value from v$session where paddr=(select addr from v$process where spid=1929696));

Select sql_text from v$sqltext where hash_value in (select sql_hash_value from v$session where paddr in (select addr from v$process where spid=1138912));

select username from v$session where paddr=(select addr from v$process where spid=1138912);

-----------------------------------------------------------

No comments:

Post a Comment