惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
The GitHub Blog
The GitHub Blog
小众软件
小众软件
美团技术团队
博客园 - 司徒正美
G
Google Developers Blog
Blog — PlanetScale
Blog — PlanetScale
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
大猫的无限游戏
大猫的无限游戏
罗磊的独立博客
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Docker
J
Java Code Geeks
Last Week in AI
Last Week in AI
V
Visual Studio Blog
Microsoft Azure Blog
Microsoft Azure Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Proofpoint News Feed
V
V2EX
C
Check Point Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MyScale Blog
MyScale Blog

博客园 - Oracle

JS key大全 JS事件 ORACLE中搜索任意字符串 Oracle's Query Transformer Oracle的几个优化模式 Linux中sar命令 Oracle 复制 oracle 中grouping函数的应用 DUMP块的分析 enqueue_stats.sql enqueue_locks.sql latch_sleeps.sql latch_spin.sql latch_get.sql latch_types.sql session_waits.sql resource_waits.sql routine_waits.sql hidden_parameters.sql all_parameters.sql
trace_waits.sql
Oracle · 2009-03-11 · via 博客园 - Oracle

This script is one of our favorites. It finds the top N sessions that have been affected by a particular type of resource wait, and enables event 10046, level 8 in those sessions for the specified period. This event captures every wait event and its wait parameters, and writes the information to the process trace file together with the normal sql_trace output. The wait parameters can then be analyzed to understand exactly what is causing the performance problem. 

declare
  type sid_type is table of number index by binary_integer;
  type serial_type is table of number index by binary_integer;
  cursor waiters is
    select
      e.sid,
      s.serial#
    from
      sys.v_$session_event  e,
      sys.v_$session  s
    where
      e.event = '&Wait' and
      s.sid = e.sid
    order by
      total_waits desc;
  sid sid_type;
  serial serial_type;
  n binary_integer := 0;
begin
  open waiters;
  loop
    n := n + 1;
    exit when n = &Sessions + 1;
    fetch waiters into sid(n), serial(n);
    exit when waiters%notfound;  
    sys.dbms_system.set_ev(sid(n), serial(n), 10046, 8, '');
  end loop;
  if n > 1 then
    sys.dbms_lock.sleep(&Sleep);
    loop
      n := n - 1;
      exit when n = 0;
      sys.dbms_system.set_ev(sid(n), serial(n), 10046, 0, '');
    end loop;
  else
    sys.dbms_output.put_line('No sessions to trace.');
  end if;
end;