Sunday, August 16, 2015

Oracle : Script which gives the CPU Performance Information

select 'recursive cpu:'||chr(9)||trunc(rcpu.value/tcpu.value*100,2)||'%' "METRIC"
from v$sysstat rcpu, v$statname vn1, v$sysstat tcpu, v$statname vn2
where vn1.name = 'recursive cpu usage' and vn1.statistic# = rcpu.statistic#
and vn2.name = 'CPU used by this session' and vn2.statistic# = tcpu.statistic#
union all
select 'parse cpu:'||chr(9)||trunc(pcpu.value/tcpu.value*100,2)||'%'
from v$sysstat pcpu, v$statname vn1, v$sysstat tcpu, v$statname vn2
where vn1.name = 'parse time cpu' and vn1.statistic# = pcpu.statistic#
and vn2.name = 'CPU used by this session' and vn2.statistic# = tcpu.statistic#
union all
select 'other cpu:'||chr(9)||trunc((tcpu.value-rcpu.value-pcpu.value)/tcpu.value*100,2)||'%'
from v$sysstat rcpu, v$statname vn1, v$sysstat pcpu, v$statname vn2, v$sysstat tcpu, v$statname vn3
where vn1.name = 'recursive cpu usage' and vn1.statistic# = rcpu.statistic#
and vn2.name = 'parse time cpu' and vn2.statistic# = pcpu.statistic#
and vn3.name = 'CPU used by this session' and vn3.statistic# = tcpu.statistic#
union all
select 'cpu/execute:'||chr(9)||trunc(tcpu.value/exct.value,2)||' hsecs'
from v$sysstat exct, v$statname vn1, v$sysstat tcpu, v$statname vn2
where vn1.name = 'execute count' and vn1.statistic# = exct.statistic#
and vn2.name = 'CPU used by this session' and vn2.statistic# = tcpu.statistic#
union all
select 'cpu/call:'||chr(9)||trunc(tcpu.value/ucals.value,2)||' hsecs'
from v$sysstat ucals, v$statname vn1, v$sysstat tcpu, v$statname vn2
where vn1.name = 'user calls' and vn1.statistic# = ucals.statistic#
and vn2.name = 'CPU used by this session' and vn2.statistic# = tcpu.statistic#
union all
select 'cpu/commit:'||chr(9)||trunc(tcpu.value/ucmts.value,2)||' hsecs'
from v$sysstat ucmts, v$statname vn1, v$sysstat tcpu, v$statname vn2
where vn1.name = 'user commits' and vn1.statistic# = ucmts.statistic#
and vn2.name = 'CPU used by this session' and vn2.statistic# = tcpu.statistic#
/

No comments:

Post a Comment