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

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

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

 

责任编辑:赵宁宁 来源: 今日头条
相关推荐

2019-09-05 08:25:15

Oraclesidsql

2017-10-16 10:59:15

系统存储SQL Serve

2019-10-31 08:22:39

shell脚本Linux

2019-08-26 10:15:29

脚本索引数据库

2010-04-15 13:09:41

无线网卡故障问题

2020-08-31 11:40:54

VimLinux字符

2010-07-21 11:32:35

SQL Server日

2010-05-27 09:50:18

MySQL导入sql脚

2022-05-31 09:01:13

GitHub工具安全

2010-09-09 13:43:48

SQL函数NEWID

2010-09-09 15:23:16

SQL更新数据

2011-09-20 15:19:15

Python

2010-12-07 16:17:40

SQL Server

2020-12-24 09:18:51

SQL数据库函数

2010-12-16 09:05:50

SQL Server

2010-09-06 13:17:19

SQL Server语句

2011-05-11 09:49:32

线程等待SQL Server

2010-07-06 12:34:28

SQL Server数

2010-09-06 10:52:27

sql server语句

2021-11-29 10:40:41

Linux运维命令
点赞
收藏

51CTO技术栈公众号