查找消耗CPU较大的sql语句
一、使用unix系统命令查看资源
http://www.gaodaima.com/34470.html查找消耗CPU较大的sql语句_sqlserver
#sar 1 9
12:15:27 73 27 0 012:15:28 70 30 0 012:15:29 80 20 0 012:15:30 84 16 0 012:15:31 21 5 1 73
#top
TTY PID USERNAME PRI NI SIZE RES STATE TIME %WCPU %CPU COMMAND ? 23093 oracle 154 20 29748K 3112K run 20:53 4.59 4.58 oraclebv ? 23087 oracle 154 20 29636K 3016K run 24:18 0.93 0.93 oraclebv
二、使用oracle数据字典查找sql
SQL>set line 240SQL>set verify offSQL>column sid format 999SQL>column pid format 999 SQL>column S_# format 999SQL>column username format A9 heading "ORA User"SQL>column program format a29SQL>column SQL format a60SQL>COLUMN OSname format a9 Heading "OS User"SQL>SELECT P.pid pid,S.sid sid,P.spid spid,S.username username,S.osuser osname,P.serial# S_#,P.terminal,P.program program,P.background,S.status,a.sql_text SQLFROM v$process P, v$session S,v$sqlarea A WHERE P.addr = s.paddrAND S.sql_address = a.address (+) AND P.spid LIKE '%&1%';
Enter value for 1: 23209(系统消耗较大进程id)
找到结果:
select * from cc_por where status=1 and deleted=0
使用autotrace分析语句。
sql>set timing on
sql>set autotrace on
sql>select * from cc_por where status=1 and deleted=0;
根据结果进行分析和改进。
欢迎大家阅读《查找消耗CPU较大的sql语句_sqlserver》,跪求各位点评,若觉得好的话请收藏本文,by 搞代码
微信 赏一包辣条吧~
支付宝 赏一听可乐吧~