1、 根据占用CPU高的进程号来查询这个进程执行的SQL语句:
CPU过高的进程号:
#首先找到CPU过高的进程号 # top -bn1 是静态找到占用最高的进程 [[email protected] ~]# top -bn1 | awk ‘{print $1}‘ | grep -A2 PID
SQL语句:
SELECT 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‘)) ORDER BY piece ASC; ####### ex: SELECT 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 = ‘31968‘)) ORDER BY piece ASC;
时间: 2024-11-07 07:02:09