Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3583245
  • 博文数量: 715
  • 博客积分: 1860
  • 博客等级: 上尉
  • 技术积分: 7745
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-07 08:51
个人简介

偶尔有空上来看看

文章分类

全部博文(715)

文章存档

2023年(75)

2022年(134)

2021年(238)

2020年(115)

2019年(11)

2018年(9)

2017年(9)

2016年(17)

2015年(7)

2014年(4)

2013年(1)

2012年(11)

2011年(27)

2010年(35)

2009年(11)

2008年(11)

最近访客

分类: Oracle

2022-10-11 18:17:28

oracle 12.2.0.1 单机,监控提示30G的temp表空间每日使用率很高。

  1. --检查最近5天谁用temp比较多

  2. select *
  3. from (select instance_number, sql_id, max(temp_sum_mb) temp_max
  4.         from (select instance_number, sample_time, sql_id, round(sum(nvl(temp_space_allocated, 0))/1024/1024) temp_sum_mb
  5.                 from dba_hist_active_sess_history
  6.                where sample_time between sysdate-5 and sysdate
  7.             group by instance_number, sample_time, sql_id)
  8.        group by instance_number, sql_id
  9.        order by temp_max desc)
  10. where rownum <= 10;

发现一个sql(这是个固定的sql_id)
0az7czjdw8z7j

  1. declare
  2.   lbRec dbms_rcvman.lbRec_t;
  3.   lbCursor dbms_rcvman.lbCursor_t;
  4.   first boolean := FALSE;
  5.   ret boolean;
  6. begin
  7.   if (:first > 0) then
  8.     first := TRUE;
  9.   end if;
  10.   <<next_row>>
  11.   ret := dbms_rcvman.listBackup(lbRecOut => lbRec,
  12.                                  firstCall => first,
  13.                                  only_obsolete => TRUE,
  14.                                  re dundancy => :redundancy,
  15.                                  piped_call => FALSE,
  16.                                  lbCursor => lbCurso r,
  17.                                  lbState => dbms_rcvman.lbStat ePck,
  18.                                  extRlKeepSCN => NULL);
  19.   if (not ret) then
  20.     raise no_data_found;
  21.   elsif (lbRec.pkey is not null and lbRec.is_rdf = 'YES') then
  22.     :backup_type := lbRec.backup_type;
  23.     :file_ type := lbRec.file_type;
  24.     :key := lbRec. pkey;
  25.   else
  26.     first := FALSE;
  27.     goto next_row;
  28.   end if;
  29. end;

看来是在检索备份信息

  1. --检查sql执行情况

  2. set long 1000000
  3. set longchunksize 1000000
  4. set lin 300 pages 1000
  5. set trim on
  6. set trimspool on
  7. set echo off
  8. set feedback off
  9. select dbms_sqltune.report_sql_monitor(sql_id=>'&sqlid',type=>'TEXT',report_level=>'ALL') mon_rpt from dual;

执行了11秒后失败,且读写超过30G!

看看历史执行情况

  1. col username for a8
  2. col SQL_ID for a13
  3. col max_sample_time for a22
  4. select (select username from dba_users b where b.user_id = a.user_id) username,
  5.        user_id, sql_id, session_id, session_serial# serial#, sql_exec_id, sql_exec_start, count(0),
  6.        to_char(max(sample_time), 'yyyymmdd hh24:mi:ss') max_sample_time,
  7.        (to_date(to_char(max(sample_time), 'yyyymmdd hh24:mi:ss'),
  8.                 'yyyymmdd hh24:mi:ss') - sql_exec_start) * 24 * 3600 exec_seconds
  9.   from dba_hist_active_sess_history a
  10.  where sql_id = '0az7czjdw8z7j'
  11.    and to_char(sample_time, 'yyyymmdd hh24:mi') between '20221003 19:00' and '20221009 21:00'
  12.  group by user_id, sql_id, session_id, session_serial#, sql_exec_id, sql_exec_start
  13.  order by sql_exec_start;



为什么别的库没事?
  1. [oracle@db01-[orcl]-/home/oracle]$ opatch lspatches
  2. 31219919;OJVM RELEASE UPDATE: 12.2.0.1.200714 (31219919)
  3. 31312468;Database Jul 2020 Release Update : 12.2.0.1.200714 (31312468)
  4. 31309299;OCW JUL 2020 RELEASE UPDATE 12.2.0.1.200714 (31309299)
是bug吗?

先不要这样想

看看备份信息实际情况
很久的都没清理

基于目前策略不应该
同样的备份软件系统,同样的配置,别的库都没事(极有可能是bug)

搭建测试环境,恢复一份全库来分析
问题复现
搜索一顿MOS

  1. set timing on

  2. alter database datafile 1,2 autoextend on next 128m;

  3. exec dbms_stats.gather_table_stats('SYS','X$KCCOR')
  4. exec dbms_stats.gather_table_stats('SYS','X$KRBPPBCTX')
  5. exec dbms_stats.gather_table_stats('SYS','X$KCCFE')
  6. exec dbms_stats.gather_table_stats('SYS','X$KCCDC')
  7. exec dbms_stats.gather_table_stats('SYS','X$KCCBF')
  8. exec dbms_stats.gather_table_stats('SYS','X$KCCBS')
  9. --exec dbms_stats.gather_table_stats('SYS','X$KCCBP')
  10. exec dbms_stats.gather_table_stats('SYS','X$KCCPD')
  11. exec dbms_stats.gather_fixed_objects_stats;
  12. begin
  13. dbms_stats.gather_table_stats(
  14.   ownname =>'SYS',
  15.   tabname => 'X$KCCBP',
  16.   no_invalidate => false,
  17.   degree=>2,
  18.   method_opt=>'for all columns size auto',
  19.   cascade => true
  20. );
  21. end;
  22. /
再执行report 就不再报错了

原因应该是:
备份信息太多(可能是bug)导致内部检索备份信息时生成了错误的执行计划,消耗过多的temp,收集部分固定表和全部固定表(没错),再过期一下sql area,让优化器产生正确的执行计划。

在带库的备份脚本中增加
  1. delete noprompt backup completed before 'sysdate-30';

先这样。
阅读(667) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~