1.cpu负载高的语句
2.磁盘IO高的语句
select b.sql_text,
a.buffer_gets,
a.executions,
a.buffer_gets/decode(a.executions , 0 , 1 , a.executions),
c.username
from V$sqlarea a,
v$sqltext_with_newlines b,
dba_users c
where a.parsing_user_id = c.user_id
and a.address = b.address
order by a.buffer_gets desc , b.piece
;
select distinct ss from (
select a.sql_text ss,
a.buffer_gets,
a.executions,
a.buffer_gets/decode(a.executions , 0 , 1 , a.executions),
c.username
from V$sqlarea a,
v$sqltext_with_newlines b,
dba_users c
where a.parsing_user_id = c.user_id
and a.address = b.address
and to_char(a.LAST_LOAD_TIME,'yyyy-MM-dd hh:mi:ss') > '2011-01-25 12:00:00'
order by a.disk_reads desc , b.piece )
select distinct ss from (
select a.sql_text ss
from V$sqlarea a,
v$sqltext_with_newlines b,
dba_users c
where a.parsing_user_id = c.user_id
and a.address = b.address
order by a.buffer_gets desc , b.piece );
2.磁盘IO高的语句
select b.sql_text,
a.disk_reads,
a.executions,
a.disk_reads/decode(a.executions , 0 , 1 , a.executions),
c.username
from v$sqlarea a,
v$sqltext_with_newlines b,
dba_users c
where a.parsing_user_id = c.user_id
and a.address = b.address
order by a.disk_reads desc , b.piece
;
SQL性能优化
本文提供了一系列SQL查询语句,用于诊断和优化Oracle数据库中CPU负载高及磁盘IO高的问题。通过这些查询,可以快速定位执行效率低下的SQL语句,并对其进行优化。

844

被折叠的 条评论
为什么被折叠?



