当前位置:主页 > 查看内容

分享两个实用SQL--查看故障时间等待事件、问题sql及会话访问次数

发布时间:2021-07-14 00:00| 位朋友查看

简介:分享两个SQL,这两个SQL只是基础原型,大家自己自定义条件去做一些调整。主要是在前面讲过的dba_hist_active_sess_history相关sql上总结出来的比较实用的sql。 DBA_HIST_ACTIVE_SESS_HISTORY DBA_HIST_ACTIVE_SESS_HISTORY displays the history of the cont……

分享两个SQL,这两个SQL只是基础原型,大家自己自定义条件去做一些调整。主要是在前面讲过的dba_hist_active_sess_history相关sql上总结出来的比较实用的sql。

DBA_HIST_ACTIVE_SESS_HISTORY

DBA_HIST_ACTIVE_SESS_HISTORY displays the history of the contents of the in-memory active session history of recent system activity. This view contains snapshots of V$ACTIVE_SESSION_HISTORY. See "V$ACTIVE_SESSION_HISTORY" for further interpretation details for many of these columns (except SNAP_ID, DBID, and INSTANCE_NUMBER).

分享两个实用SQL--查看故障时间等待事件、问题sql及会话访问次数

分享两个实用SQL--查看故障时间等待事件、问题sql及会话访问次数

分享两个实用SQL--查看故障时间等待事件、问题sql及会话访问次数

分享两个实用SQL--查看故障时间等待事件、问题sql及会话访问次数

分享两个实用SQL--查看故障时间等待事件、问题sql及会话访问次数

查看故障时间段等待事件、问题sql id及会话访问次数

  1. --alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss'
  2. select trunc(sample_time, 'mi') tm, sql_id, nvl(event,'CPU'),count(distinct session_id) cnt 
  3.  from dba_hist_active_sess_history 
  4.  where sample_time between to_date('2019-08-22 14:00:00') and 
  5.  to_date('2019-08-22 14:30:00') 
  6.  group by trunc(sample_time, 'mi'), sql_id,nvl(event,'CPU') 
  7.  order by cnt desc; 

分享两个实用SQL--查看故障时间等待事件、问题sql及会话访问次数

查看该sql相关的等待事件及对应的会话访问次数

  1. select sql_id, nvl(event, 'CPU'), count(distinct session_id) sz 
  2.  from dba_hist_active_sess_history a, dba_hist_snapshot b 
  3.  where sample_time between to_date('2019-08-22 14:00:00') and 
  4.  to_date('2019-08-22 15:00:00') 
  5.  and sql_id = '4ksvn2rgjnhcm' 
  6.  and a.snap_id = b.snap_id 
  7.  and a.instance_number = b.instance_number 
  8.  group by sql_id, nvl(event, 'CPU') 
  9.  order by sz desc; 

分享两个实用SQL--查看故障时间等待事件、问题sql及会话访问次数


本文转载自网络,原文链接:https://www.toutiao.com/i6728367035710964238/
本站部分内容转载于网络,版权归原作者所有,转载之目的在于传播更多优秀技术内容,如有侵权请联系QQ/微信:153890879删除,谢谢!

推荐图文


随机推荐