Home >Database >Mysql Tutorial >如何找出消耗cup的进程信息和执行的语句_MySQL

如何找出消耗cup的进程信息和执行的语句_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 14:05:411223browse

要找出最耗资源的sql,我们可以首先使用top等工具,找到最好资源的进程(记住进程号),例如,操作系统进程号为1217,然后根据这个进程号(v$process.spid)在v$process中找到进程地址(v$process.addr),然后根据这个地址在v$session中找到相应的sid(v$session.sid),然后根据这个sid找到相应的hash alue(v$session. sql_hash_value),然后根据这个hash alue在v$sqltext,$sql,v$sqlarea等视图中找到对应的sql语句(sql_text)。

例如:

oracle@cs_db02:/arch1/lunar/tools > whoistopsql.sh 6799
Connected.

SID SERIAL# USERNAME OSUSER MACHINE PROGRAM PROCESS TO_CHAR(LOGON_TIME,
---------- ---------- ------------------------------ ------------------------------ ------------------------------ ---------------------------------------- ------------ -------------------
483 1224 PORTAL www16 bj_wap03 JDBC Thin Client 2004/09/22 02:21:03


SQL_TEXT
----------------------------------------------------------------
SELECT * FROM SPINFO where spID = :1

oracle@cs_db02:/arch1/lunar/tools >

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn