...
分类: Oracle
2012-07-17 20:35:50
1. cpu性能
$ sar -u 10 5
$ ps -ef | grep oracle
识别高CPU用户
SQL>select n.username, s.sid, s.value from v$sesstat s, v$statname t, v$session n
where s.statistic# = t.statistic# and n.sid = s.sid and t.name ='CPU used by this session'
order by s.value desc
会话级CPU使用情况
SQL>select sid, s.value "Total CPU Used by this Session" from v$sesstat s
where s.statistic# =12 order by s.value desc
总CPU使用的分解
SQL>select name, value from v$sysstat
where name in ('CPU used by this session','recursive cpu usage','parse time cpu');
CPU等待
SQL> select metric_name, value from v$sysmetric
where metric_name in ('Database CPU Time Ratio', 'Database Wait Time Ratio')
and intsize_csec = (select max(intsize_csec) from v$sysmetric);
2. 内存
3. 磁盘I/O
$ sar -d 10 5
SQL>select d.name, f.phyrds reads, f.phywrts wrts,
(f.readtim/decode(f.phyrds, 0, -1, f.phyrds)) readtime,
(f.writetim/decode(f.phywrts, 0, -1, f.phywrts)) writetime
from v$datafile d, v$filestat f where d.file# = f.file# order by d.name;
4. 系统性能
SQL> select * from v$osstat
5. 长时间事务
SQL> select hash_value, executions, round(elapsed_time/1000000, 2) total_time,
round(cpu_time/1000000, 2) cpu_seconds
from (select * from v$sql order by elapsed_time desc);