Note: Find PL/SQL statements with high CPU usage

Source: Internet
Author: User
Tags high cpu usage
In the afternoon, a colleague said that a Linux testing server was very slow and seriously affected the work.
Log on to the server and use the top command to check whether the Oracle process accounts for 100% of the CPU.
The following steps are used to find out the SQL statements that cause performance problems:
1. Use the TOP command to find that the PID of the Oracle process that occupies CPU 1234% is;
2. Open PL/SQL Dev and query the process information: Select * from V $ process where spid = 1234;

3. Find the session information of the process: Select Sid, program from V $ session s
Where exists (select 1 from V $ process where spid = 1234 and ADDR = S. paddr );

4. From the above, I already know which client is causing the program. Continue:
Find the sqlselect SQL _text of these sessions
From v $ session a left Outer Join v $ sqltext B on A. SQL _address = B. Address
Where exists (select 1 from V $ process where spid = 17518 and ADDR = A. paddr)
Order by A. Serial #, B. Piece

5. This statement is better. Select B. SQL _text is sorted according to CPU usage.
From v $ session a left Outer Join v $ sqlarea B on A. SQL _address = B. Address
Where exists (select 1 from V $ process where spid = 1234 and ADDR = A. paddr)
Order by B. cpu_time DESC

 

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.