oracle佔用cpu過高怎麼處理,本文將介紹有關oracle進程CPU佔用率過高的問題,需要瞭解跟多的朋友可以參考下
1:首先使用TOP命令傳到佔用CPU高的SPID號
PID USERNAME THR PRI NICE SIZE RES STATE TIME CPU COMMAND
3575 oracle 1 12 0 0K 0K run 748.6H 24.98% oracle
3571 oracle 1 22 0 0K 0K sleep 706.2H 22.84% oracle
2:使用DBA賬戶登入資料庫,使用以下SQL語句查詢:
SELECT * FROM V$PROCESS WHERE spid=3575;查詢到SQL相關資訊
3:根據以上查詢到的資訊使用以下SQL查詢:
SELECT sid, program FROM V$SESSION S WHERE EXISTS(SELECT 1 FROM V$PROCESS WHERE spid=3575 AND ADDR = S.PADDR);
可以查詢到具體那個用戶端查詢一直在不斷佔用ORACLE資源!
最後對這個查詢進行處理!
4.根據SID查得SQLITPUB 複製代碼 代碼如下:select sql_textITPUB
from v$sqltext
where a.hashvalue=(select sql_hash_value
from v$session b
where b.SID='&sid')
0order by piece ASC;
根據lockwait欄位可以查詢當前正在等待的鎖的相關資訊: 複製代碼 代碼如下:select * from v$lock where kaddr in (select lockwait from v$session where sid= $sid);
(sql_address,sql_hash_value),(prev_sql_addr,prev_hash_value) 根據這兩組欄位, 可以查詢到當前session正在執行的或最近一次執行的sql語句的詳細資料:
select * from v$sqltext where address = &sql_address and hash_value = &sql_hash_value;
根據PID查SQL相關資訊: 複製代碼 代碼如下:select id,serial# ,username,osuser,machine,program,process,to_char(logon_time,'yyyy/mm/dd hh24:mi:ss') logon from v$session where paddr in ( select addr from v$process where spid in('&pid'));
根據PID查SQL語句 複製代碼 代碼如下:SELECT a.username,a.machine,a.program,a.sid,a.serial#,a.status,c.piece,c.sql_text FROM v$session a,v$process b,v$sqltext c WHERE b.spid='&spid' AND b.addr=a.paddr AND a.sql_address=c.address(+) ORDER BY c.piece;
得到進程的sid號: 複製代碼 代碼如下:select id,serial# ,username,osuser,machine,program,process,to_char(logon_time,'yyyy/mm/dd hh24:mi:ss') logon from v$session where paddr in ( select addr from v$process where spid in('&pid'));
得到session的sqltext語句: 複製代碼 代碼如下:select sql_text from v$sqltext_with_newlines where hash_value in (select SQL_HASH_VALUE from v$session where paddr in (select addr from v$process where spid= '&pid')) order by piece;