Tuesday 21 May 2019

Find out CPU usage for each session

Below query will be useful to find out CPU usage for each session.

select nvl(ss.USERNAME,'ORACLE USER') username, se.SID, VALUE cpu_usage
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
order by VALUE desc;



Sample output:

SQL> select nvl(ss.USERNAME,'ORACLE USER') username, se.SID, VALUE cpu_usage
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
order by VALUE desc;  2    3    4    5    6

USERNAME                              SID  CPU_USAGE
------------------------------ ---------- ----------
ORACLE USER                           234      13270
ORACLE USER                           305       9523
APPS                                  721       7309
APPS                                  114       4497
APPS                                  300       3482
APPS                                  817       2820
APPS                                  873       2784
APPS                                  849       2515
APPS                                  545       2130
APPS                                  482       1792
ORACLE USER                           297       1655
APPS                                  985       1459
APPS                                  738       1458
APPS                                  682       1433
APPS                                  609       1160
APPS                                  251       1148
APPS                                  409       1016
APPS                                  154        864
APPS                                  801        863
APPS                                   27        827
APPS                                  178        789

APPS                                  164        754


Here;

USERNAME - Name of the user
SID - Session id
CPU Usage - CPU centi-seconds used by this session (divide by 100 to get real CPU seconds)

No comments:

Post a Comment