Oracle Real-time query of SQL statements that consume the most CPU resources

Source: Internet
Author: User
Tags session id

1. Use the top command to see the SPID numbers with the most productive resources first

2. Query the current time-consuming session ID, user name, Sqlid, etc.: 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. If the previous step sql_id or Hash_value is not empty, V$sqlarea can be used to isolate the SQL select Sql_text from V$sqltext_with_newlines where Hash_value is currently in use = &hash_value order by piece;
SELECT * from V$sql where sql_id= '

---the----provided by CSDN netizens

SELECTSql_textFromV$sqltext a WHERE(A.hash_value, a.address)In (SELECTDECODE (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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.