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

在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)