程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> OracleCPU使用情況查詢

OracleCPU使用情況查詢

編輯:Oracle教程

OracleCPU使用情況查詢


--發現那些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;

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved