Oracle查找消耗CPU资源Oracle认证考试
文章作者 100test 发表时间 2009:08:07 17:16:52
来源 100Test.Com百考试题网
"tbbnc">
很多时候我们的服务器可能会经历CPU消耗100%的性能问题。
排除系统的异常,这类问题通常都是因为系统中存在性能低下甚至存在错误的SQL语句, 消耗了大量的CPU所致。
使用top监控数据库进程
top - 14:27:12 up 58 days, 13:26, 4 users, load average: 0.27, 0.35, 0.36
Tasks: 262 total, 1 running, 261 sleeping, 0 stopped, 0 zombie
Cpu(s): 1.5% us, 0.4% sy, 0.0% ni, 98.0% id, 0.1% wa, 0.0% hi, 0.0% si
Mem: 32906904k total, 11103516k used, 21803388k free, 272816k buffers
Swap: 24579408k total, 0k used, 24579408k free, 9181336k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME COMMAND
26117 oracle 15 0 5757m 2.9g 2.9g S 49 9.2 40:20.73 oracle
26115 oracle 16 0 5757m 3.9g 3.9g S 2 12.4 70:31.67 oracle
7760 root 16 0 532m 19m 9436 S 0 0.1 39:13.60 crsd.bin
21172 oracle 16 0 5797m 71m 37m S 0 0.2 4:50.59 oracle
25853 oracle 16 0 5753m 174m 168m S 0 0.5 0:39.75 oracle
13424 oracle 15 0 5751m 403m 400m S 0 1.3 0:04.43 oracle
6901 oracle 16 0 36192 2104 1496 S 0 0.0 0:00.61 sshd
寻找CPU使用过量的session ,找出高CPU利用率的SQL:
SQL>.SELECT /* ORDERED */
sql_text
FROM v$sqltext a
WHERE (a.hash_value, a.address) IN
(SELECT decode(sql_hash_value, 0, prev_hash_value, sql_hash_value), decode(sql_hash_value, 0, prev_sql_addr, sql_address)
FROM v$session b
WHERE b.paddr = (SELECT addr
FROM v$process c
WHERE c.spid = &.pid