CPU Sessions usage
select * from (select * from
(
select username,sid,
round((cpu_usage/(
select sum(value) total_cpu_usage
from gv$sesstat t
inner join gv$session s on ( t.sid = s.sid )
inner join gv$statname n on ( t.statistic# = n.statistic# )
where n.name like '%CPU used by this session%'
and nvl(s.sql_exec_start, s.prev_exec_start) >= sysdate-1/24
))*100/16,2) cpu_usage_per_cent,
module_info,client_info,sql_id
from
(
select nvl(s.username,'Oracle Internal Proc.') username,s.sid,s.sql_id,t.value cpu_usage, nvl(s.module, s.program) module_info, decode(s.osuser,'oracle', s.client_info, s.osuser) client_info
from gv$sesstat t
inner join gv$session s on ( t.sid = s.sid )
inner join gv$statname n on ( t.statistic# = n.statistic# )
where n.name like '%CPU used by this session%'
and nvl(s.sql_exec_start, s.prev_exec_start) >= sysdate-1/24
) s1
)
order by cpu_usage_per_cent desc) where rownum < 10;
NON-RAC / Cloud RDS: Top 10 sessions from last 1 hour cpu usage
select * from (select * from
(
select username,sid,
round((cpu_usage/(
select sum(value) total_cpu_usage
from v$sesstat t
inner join v$session s on ( t.sid = s.sid )
inner join v$statname n on ( t.statistic# = n.statistic# )
where n.name like '%CPU used by this session%'
and nvl(s.sql_exec_start, s.prev_exec_start) >= sysdate-1/24
))*100/16,2) cpu_usage_per_cent,
module_info,client_info,sql_id
from
(
select nvl(s.username,'Oracle Internal Proc.') username,s.sid,s.sql_id,t.value cpu_usage, nvl(s.module, s.program) module_info, decode(s.osuser,'oracle', s.client_info, s.osuser) client_info
from v$sesstat t
inner join v$session s on ( t.sid = s.sid )
inner join v$statname n on ( t.statistic# = n.statistic# )
where n.name like '%CPU used by this session%'
and nvl(s.sql_exec_start, s.prev_exec_start) >= sysdate-1/24
) s1
)
order by cpu_usage_per_cent desc) where rownum < 10;
Comments
Post a Comment