1. 程式人生 > >檢視Oracle效能差的SQL

檢視Oracle效能差的SQL

1.檢視總消耗時間最多的前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.elapsed_time desc) elapsed_rank
          from v$sql v) a
 where elapsed_rank <= 10;
2.檢視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;
3.檢視消耗磁碟讀取最多的前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;
轉自: http://www.tuicool.com/articles/v2Mfii