Use the top tool to identify processes that consume more CPU

Source: Internet
Author: User

1. Use the top tool to identify processes that consume more CPU

[email protected] ~]$ Top

Top-10:48:27 up 23:15, 4 users, Load average:1.09, 0.43, 0.15

tasks:161 Total, 3 running, 158 sleeping, 0 stopped, 0 zombie

Cpu (s): 74.3%us, 23.7%sy, 0.0%ni, 0.0%id, 2.0%wa, 0.0%hi, 0.0%si, 0.0%st

mem:900096k Total, 894948k used, 5148k free, 6436k buffers

swap:2097144k Total, 24692k used, 2072452k free, 666588k cached

  PID user      pr  ni  virt  res  SHR S%cpu%mem     time+  command                                                                                                                                       

10306 oracle    25   0  326m 171m 168m R 93.4 19.5   1:51.53 oracle                                                                                                                                        

 3258 oracle    16   0  338m  32m  29m s  3.3  3.7    1:31.02 oracle                                                                                                                                       

3256 Oracle 0 347m 191m 175m S 1.3 21.8 0:04.65 Oracle

You can see that the user Oracle process is pid=10306 CPU-intensive 93.4

2. Based on the PID you just found, find information about the process in the database

SYS @ prod >select pid,spid,addr from v$process where spid=10306;

PID SPID ADDR

---------- ------------ --------

10306 2e61b254

3. Find V$session related session information based on the PID found

SYS @ prod >select sid,saddr,paddr from v$session where paddr= ' 2e61b254 ';

SID saddr paddr

---------- -------- --------

146 2e6fc134 2e61da40

147 2e6fd3e8 2e61c370

2E700C04 2e61b254

4. Based on the SID found, find the sql_hash_value of the session

SYS @ prod >select Sid,sql_hash_value from v$session where sid=150;

SID Sql_hash_value

---------- --------------

3514920902

5. Based on the Sql_hash_value found, find the corresponding SQL statement

SYS @ prod >select Sql_text from V$sqltext where hash_value= ' 3514920902 ';

Sql_text

----------------------------------------------------------------

declare begin for I in 1..10000000 loop insert into test values (i); end loop; End;

Use the top tool to identify processes that consume more CPU

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.