效能最佳化-查詢最耗CPU的SESSION與SQL

來源:互聯網
上載者:User

標籤:

在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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.