分享两个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;

【编辑保举】
- 深入浅出MySQL索引的那些事儿
- MySQL数据库目次下面的db.opt是干什么用的?
- 同事用这2个小能力,让SQL语句服从晋升了1000倍
- MySQL导入导出呼吁-mysqldump
- 怎样删除MySQL用户帐户
【责任编辑:赵宁宁 TEL:(010)68476606】
点赞 0 (编辑:湖南网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|