首页 > 代码库 > 查询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;
4.查看当前数据库执行次数最多的SQL,例如,查询执行最频繁的TOP 15的SQL语句
SELECT SQL_TEXT, EXECUTIONS FROM (SELECT SQL_TEXT, EXECUTIONS, RANK() OVER(ORDER BY EXECUTIONS DESC) EXEC_RANK FROM V$SQLAREA) WHERE EXEC_RANK <= 15;
查询oracle 数据库 SQL语句执行情况