SQL语句:
(较高的磁盘读取(disk_reads消耗I/O)和较高的逻辑读取(buffer_gets消耗CPU)被用作衡量标准)
select sql_text from
(select sql_text,executions,buffer_gets,disk_reads
from v$sql
where buffer_gets > 100000
or disk_reads > 100000
order by buffer_gets + 100*disk_reads DESC)
where rownum <= 5;
2、查找使用CPU最多的SQL语句:
(较高的逻辑读取(buffer_gets消耗CPU)被用作衡量标准)
select sql_text from
(select sql_text,executions,buffer_gets,disk_reads
from v$sql
where buffer_gets > 100000
order by buffer_gets desc)
where rownum <= 5;
或者
(直接使用v$sql里的cpu_time)
select sql_text,
round(cpu_time/1000000, 2) cpu_seconds from
(select * from v$sql order by cpu_time desc)
where rownum <= 5;
3、查找使用磁盘I/O最多的SQL语句:
(较高的磁盘读取(disk_reads消耗I/O)被用作衡量标准)
select sql_text from
(select sql_text,executions,buffer_gets,disk_reads
from v$sql
where disk_reads > 100000
order by disk_reads desc)
where rownum <= 5;
4、查找占用数据库时间最多的SQL语句:
select sql_text,round(elapsed_time/1000000, 2) elapsed_seconds,executions from
(select * from v$sql order by elapsed_time desc)
where rownum <= 5;
5、查找执行次数(executions)最多的SQL语句:
select sql_text, executions from
(select * from v$sql
where executions > 1000
order by executions desc)
where rownum <= 5;
6、查找解析调用最多的SQL语句:
select sql_text,parse_calls from
(select * from v$sql
where parse_calls > 1000
order by parse_calls desc)
where rownum <= 5;
7、查找使用共享内存最多的SQL语句:
(使用共享内存大于1048576(bytes)的SQL语句会显示)
select sql_text,sharable_mem from
(select * from v$sql
where sharable_mem > 1048576
order by sharable_mem desc)
where rownum <= 5;
--转自