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

发布时间:2025-05-25 01:15:53 作者:益华网络 来源:undefined 浏览量(1) 点赞(1)
摘要:分享两个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 se

分享两个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 id及会话访问次数

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

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

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

二维码

扫一扫,关注我们

声明:本文由【益华网络】编辑上传发布,转载此文章须经作者同意,并请附上出处【益华网络】及本页链接。如内容、图片有任何版权问题,请联系我们进行处理。

感兴趣吗?

欢迎联系我们,我们愿意为您解答任何有关网站疑难问题!

您身边的【网站建设专家】

搜索千万次不如咨询1次

主营项目:网站建设,手机网站,响应式网站,SEO优化,小程序开发,公众号系统,软件开发等

立即咨询 15368564009
在线客服
嘿,我来帮您!