如何查询占CPU高的oracle进程

前端之家收集整理的这篇文章主要介绍了如何查询占CPU高的oracle进程前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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
<div class="codetitle"><a style="CURSOR: pointer" data="43978" class="copybut" id="copybut43978" onclick="doCopy('code43978')"> 代码如下:

<div class="codebody" id="code43978">
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字段可以查询当前正在等待的锁的相关信息:
<div class="codetitle"><a style="CURSOR: pointer" data="35692" class="copybut" id="copybut35692" onclick="doCopy('code35692')"> 代码如下:
<div class="codebody" id="code35692">
select
from v$lock where kaddr in (select lockwait from v$session where sid= $sid);
(sql_address,sql_hashvalue),(prevsql_addr,prev_hash_value) 根据这两组字段,可以查询到当前session正在执行的或最近一次执行的sql语句的详细信息:
select * from v$sqltext where address = &sql_address and hash_value = &sql_hash_value;

根据PID查sql相关信息:
<div class="codetitle"><a style="CURSOR: pointer" data="13666" class="copybut" id="copybut13666" onclick="doCopy('code13666')"> 代码如下:
<div class="codebody" id="code13666">
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语句
<div class="codetitle"><a style="CURSOR: pointer" data="53187" class="copybut" id="copybut53187" onclick="doCopy('code53187')"> 代码如下:
<div class="codebody" id="code53187">
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号:
<div class="codetitle"><a style="CURSOR: pointer" data="13666" class="copybut" id="copybut13666" onclick="doCopy('code13666')"> 代码如下:<div class="codebody" id="code13666">
select id,'yyyy/mm/dd hh24:mi:ss') logon from v$session where paddr in ( select addr from v$process where spid in('&pid'));

得到session的sqltext语句:
<div class="codetitle"><a style="CURSOR: pointer" data="16870" class="copybut" id="copybut16870" onclick="doCopy('code16870')"> 代码如下:<div class="codebody" id="code16870">
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;

原文链接:https://www.f2er.com/oracle/65663.html
oracleoracle查进程

猜你在找的Oracle相关文章