查看总消耗时间最多的前100条SQL语句
select * from ( select v.sql_id,v.child_number, v.sql_text,last_load_time,v.PARSING_USER_ID, ROUND(v.ELAPSED_TIME / 1000000 / (CASE WHEN (EXECUTIONS = 0 OR NVL(EXECUTIONS, 1 ) = 1) THEN 1 ELSE EXECUTIONS END), 2) "执行时间'S'", v.SQL_FULLTEXT,v.cpu_time,v.disk_reads, rank() over(order by v.elapsed_time desc) elapsed_rank from v$sql v ) a where elapsed_rank <= 100 and last_load_time > to_char(sysdate - 1/24, 'YYYY-MM-DD/HH:MI:SS') order by "执行时间'S'" desc
查询最近一小时内最慢的SQL
select executions, cpu_time/1e6 as cpu_sec, elapsed_time/1e6 as elapsed_sec, round(elapsed_time/sqrt(executions)) as important, v.* from v$sql v where executions > 10 and last_load_time > to_char(sysdate - 1/24, 'YYYY-MM-DD/HH:MI:SS') order by important desc
查看CPU消耗时间最多的前10条SQL语句
select * from ( select v.sql_id,v.child_number,v.sql_text,v.elapsed_time,v.cpu_time,v.disk_reads,rank() over(order by v.cpu_time desc) elapsed_rank from v$sql v ) a where elapsed_rank <= 10
查看消耗磁盘读取最多的前10条SQL语句
select * from ( select v.sql_id,v.child_number,v.sql_text,v.elapsed_time,v.cpu_time,v.disk_reads,rank() over(order by v.disk_reads desc) elapsed_rank from v$sql v ) a where elapsed_rank <= 10
标签:脚本,sql,rank,elapsed,排查,time,Oracle,cpu,select From: https://www.cnblogs.com/oioele/p/17443242.html