prompt Top 30 Average CPU Time SQL (> 10 seconds)
column AverageCpuTime format 9999.9 heading 'Ave CPU|Time (S)'
column CpuTime format 999999.9 heading 'CPU|Time (S)'
column ElapsedTime format 999999.9 heading 'Elapsed|Time (S)'
column Executions format 99999 heading 'Exec|Times'
column SQLText format a64 heading 'SQL Text'
column Address noprint
break on Address skip 1 on AverageCpuTime on CpuTime on ElapsedTime on Executions
select a.address Address,
b.cpu_time / 1000000 / b.executions AverageCpuTime,
b.cpu_time / 1000000 CpuTime,
b.elapsed_time / 1000000 ElapsedTime,
b.executions Executions,
a.sql_text SQLText
from v$sqltext a,
v$sqlarea b
where a.address = b.address and
a.hash_value = b.hash_value and
b.executions > 0 and
(b.address, b.hash_value) in (select address, hash_value
from (select address, hash_value
from v$sqlarea
where executions > 0 and
cpu_time / 1000000 > 10 * executions
order by cpu_time desc)
where rownum < 31)
group by a.address,
a.sql_text,
a.piece,
b.cpu_time,
b.elapsed_time,
b.executions
order by AverageCpuTime desc,
a.address,
a.piece;