码迷,mamicode.com
首页 > 数据库 > 详细

性能优化-查询最耗CPU的SESSION与SQL

时间:2016-05-11 23:16:33      阅读:286      评论:0      收藏:0      [点我收藏+]

标签:

在linux 系统中 用top命令查出CPU最高的SPID,

然后按下面

 

select SID,

       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 (‘24566‘));

 

select s.SID,

       s.serial#,

       s.username,

       s.osuser,

       s.machine,

       s.program,

       s.process,

       to_char(s.logon_time, ‘yyyy/mm/dd hh24:mi:ss‘) logon,

       p.spid

  from v$session s,v$process p

 where 1=1

 and s.PADDR=p.ADDR

 and s.SID=‘1050‘

;

 

          

select sql_text,a.SQL_ID

from v$sqltext  a

where a.HASH_VALUE=(select sql_hash_value

from v$session b

where b.SID=‘634‘)

 order by piece ASC;

 

select * from v$sqlarea q

where q.SQL_ID=‘akf0uyy10kgn9‘

;

 

 

 

---------------------

select *

  from (select q.SQL_ID,q.SQL_TEXT, q.SQL_FULLTEXT,s.SID,s.SERIAL#

          from v$sqlarea q,v$session s

          where q.SQL_ID=s.SQL_ID

          and LAST_ACTIVE_TIME>=to_date(‘2016-05-03 08:00:00‘,‘YYYY-MM-DD HH24:MI:SS‘)

          AND INSTR(PARSING_SCHEMA_NAME,‘SYS‘) <=0

         order by cpu_time desc)

 where rownum <= 15

 order by rownum asc;

 

 

 alter system kill session ‘634,40971‘;

性能优化-查询最耗CPU的SESSION与SQL

标签:

原文地址:http://www.cnblogs.com/HondaHsu/p/5483790.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!