码迷,mamicode.com
首页 > 数据库 > 详细

OracleCPU使用情况查询

时间:2017-12-10 17:00:42      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:语句   使用   efi   contain   sel   suse   count   大量   roc   

 

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
--发现那些SQL运行了大量的PARSE
select sql_text, parse_calls, executions
  from v$sqlarea
 order by parse_calls desc;
 
--SYS的总的PARSE情况
select name, value from v$sysstat where name like ‘parse count%‘;
 
--CPU空间及繁忙情况
select * from v$osstat;
 
--查看每个Session的CPU利用情况:
select ss.sid, se.command, ss.value CPU, se.username, se.program
  from v$sesstat ss, v$session se
 where ss.statistic# in
       (select statistic#
          from v$statname
         where name = ‘CPU used by this session‘)
   and se.sid = ss.sid
   and ss.sid > 6
 order by CPU desc;
 
--比较一下哪个session的CPU使用时间最多,然后查看该Session的具体情况:
select s.sid, s.event, s.MACHINE, s.OSUSER, s.wait_time, w.seq#, q.sql_text
  from v$session_wait w, v$session s, v$process p, v$sqlarea q
 where s.paddr = p.addr
   and s.sid = &p
   and s.sql_address = q.address;
 
--占用CPU最高的10个Session及其SQL语句
select s.sid,
       w.wait_time,
       w.seconds_in_wait,
       w.state,
       w.wait_time_micro,
       w.time_remaining_micro,
       w.time_since_last_wait_micro,
       p.USERNAME,
       status,
       server,
       schemaname,
       osuser,
       machine,
       p.terminal,
       p.program,
       logon_time,
       w.event,
       w.wait_class,
       tracefile,
       sql_text,
       last_active_time
  from v$session_wait w, v$session s, v$process p, v$sqlarea q
 where s.paddr = p.addr
   and s.sid in (select sid
                   from (select ss.sid
                           from v$sesstat ss, v$session se
                          where ss.statistic# in
                                (select statistic#
                                   from v$statname
                                  where name = ‘CPU used by this session‘)
                            and se.sid = ss.sid
                            and ss.sid > 6
                          order by ss.value desc)
                  where rownum < 11)
   and s.sql_address = q.address;

OracleCPU使用情况查询

标签:语句   使用   efi   contain   sel   suse   count   大量   roc   

原文地址:http://www.cnblogs.com/lcword/p/8017071.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!