oracle 即時查詢最耗CPU資源的SQL語句

來源:互聯網
上載者:User

 

1. 先通過top命令查看產用資源較多的spid號

 

2.查詢當前耗時的會話ID,使用者名稱,sqlID等:
select sid,serial#,machine,username,program,sql_hash_value,sql_id,
       to_char(logon_time,'yyyy/mm/dd hh24:mi:ss') as login_time from v$session
where paddr in (select addr from v$process where spid in ('5648612','256523'));

3. 如果上一步sql_id或者 hash_value不為空白,則可用v$sqlarea查出當前正在使用的sql
select sql_text
  from v$sqltext_with_newlines
  where hash_value = &hash_value
order by piece;

select * from v$sql where sql_id=''

 

 

 

---CSDN 網友提供的----

 

SELECT sql_text
  FROM v$sqltext a
WHERE (a.hash_value, a.address) IN
       (SELECT DECODE(sql_hash_value, 0, prev_hash_value, sql_hash_value),
               DECODE(sql_hash_value, 0, prev_sql_addr, sql_address)
          FROM v$session b
         WHERE b.paddr = (SELECT addr FROM v$process c WHERE c.spid = '&pid'))
ORDER BY piece ASC

 

 

 

------------------------------------------------------------------------------
Blog: http://blog.csdn.net/tianlesoftware
網上資源: http://tianlesoftware.download.csdn.net
相關視頻:http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx
DBA1 群:62697716(滿); DBA2 群:62697977

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.