热块及毛刺问题定位
  IE5LYMWlmdvL 2023年11月02日 53 0

1. 查看活动会话最高的时间点和SAMPLE_ID

select sample_id,sample_time,count(*)
  from v$active_session_history a
where sample_time between to_date('xxxxxxxxx','yyyymmddhh24miss') and to_date('xxxxxxxxx','yyyymmddhh24miss')
  group by sample_id,sample_time
  order by 3 desc;

2. 如果是xxxx库DEADLOCK问题使用以下脚本处理,不是DEADLOCK问题跳到3

select sql_id,event,count(*)
  from v$active_session_history a
where sample_id=xxxxxxxxx
  and event='buffer deadlock'
 group by sql_id,event
 order by 3 desc

2.1定位到执行计划慢在哪一行

select sql_id,sql_plan_hash_value,sql_plan_line_id,event,count(*)
  from v$active_session_history a
where sample_id=xxxxxxxxx
  and sql_id='5zzddv8mwnmpk'
  and event is not null
 group by sql_id,sql_plan_hash_value,sql_plan_line_id,event
 order by 5 desc;

2.2 登录平台查看SQL执行计划定位到热块的对象,比如说SQL_PLAN_LINE_ID=9

热块及毛刺问题定位_毛刺问题

3.使用SAMPLE_ID或者SAMPLE_TIME查看数据库TOP EVENT和TOP SQL

select event,count(*)
  from v$active_session_history a
where sample_id = xxxxxxxxx
 group by event
 order by 2 desc;

select sql_id,count(*)
  from v$active_session_history a
where sample_time between to_date('xxxxxxxxx','yyyymmddhh24miss') and to_date('xxxxxxxxx','yyyymmddhh24miss')
 group by sql_id
 order by 2 desc;

4. 关注SQL_EXEC_ID,如果长时间都是同一个,说明这个SQL执行了很久没有结束,可以结合SQL_EXEC_START判断出SQL执行时间

select sql_id,count(*),sample_time,sql_exec_start,sql_exec_id
  from v$active_session_history a
where sample_time between to_date('xxxxxxxxx','yyyymmddhh24miss') and to_date('xxxxxxxxx','yyyymmddhh24miss')
  and sql_id in ('xxxxxxxxx')
 group by sql_id,sample_time,sql_exec_start,sql_exec_id
 order by 3

5. 关注DURATION,SQL执行时间是否有变化

select sql_id,sample_time,sql_plan_hash_value, max(sample_time) - SQL_EXEC_START as duration,sql_exec_start,sql_exec_id,min(sql_exec_start)--machine,program,
  from v$active_session_history a
where sample_time between to_date('xxxxxxxxx','yyyymmddhh24miss') and to_date('xxxxxxxxx','yyyymmddhh24miss')
   and sql_id in ('xxxxxxxxx')
  group by sql_id,sql_exec_id,sql_plan_hash_value,sql_exec_start,sample_time--,machine,program
  order by 4 desc;
【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  xaeiTka4h8LY   2024年05月31日   53   0   0 MySQLSQL
  xaeiTka4h8LY   2024年05月17日   56   0   0 数据库JavaSQL
  xaeiTka4h8LY   2024年05月17日   54   0   0 数据库SQL
  Dk8XksB4KnJY   2023年12月23日   32   0   0 字段字段SQLSQL
IE5LYMWlmdvL