oracle 12.2.0.1 单机,监控提示30g的temp表空间每日使用率很高。
-
--检查最近5天谁用temp比较多
-
-
select *
-
from (select instance_number, sql_id, max(temp_sum_mb) temp_max
-
from (select instance_number, sample_time, sql_id, round(sum(nvl(temp_space_allocated, 0))/1024/1024) temp_sum_mb
-
from dba_hist_active_sess_history
-
where sample_time between sysdate-5 and sysdate
-
group by instance_number, sample_time, sql_id)
-
group by instance_number, sql_id
-
order by temp_max desc)
-
where rownum <= 10;
发现一个sql(这是个固定的sql_id)
0az7czjdw8z7j
-
declare
-
lbrec dbms_rcvman.lbrec_t;
-
lbcursor dbms_rcvman.lbcursor_t;
-
first boolean := false;
-
ret boolean;
-
begin
-
if (:first > 0) then
-
first := true;
-
end if;
-
<<next_row>>
-
ret := dbms_rcvman.listbackup(lbrecout => lbrec,
-
firstcall => first,
-
only_obsolete => true,
-
re dundancy => :redundancy,
-
piped_call => false,
-
lbcursor => lbcurso r,
-
lbstate => dbms_rcvman.lbstat epck,
-
extrlkeepscn => null);
-
if (not ret) then
-
raise no_data_found;
-
elsif (lbrec.pkey is not null and lbrec.is_rdf = 'yes') then
-
:backup_type := lbrec.backup_type;
-
:file_ type := lbrec.file_type;
-
:key := lbrec. pkey;
-
else
-
first := false;
-
goto next_row;
-
end if;
-
end;
看来是在检索备份信息
-
--检查sql执行情况
-
-
set long 1000000
-
set longchunksize 1000000
-
set lin 300 pages 1000
-
set trim on
-
set trimspool on
-
set echo off
-
set feedback off
-
select dbms_sqltune.report_sql_monitor(sql_id=>'&sqlid',type=>'text',report_level=>'all') mon_rpt from dual;
执行了11秒后失败,且读写超过30g!
看看历史执行情况
-
col username for a8
-
col sql_id for a13
-
col max_sample_time for a22
-
select (select username from dba_users b where b.user_id = a.user_id) username,
-
user_id, sql_id, session_id, session_serial# serial#, sql_exec_id, sql_exec_start, count(0),
-
to_char(max(sample_time), 'yyyymmdd hh24:mi:ss') max_sample_time,
-
(to_date(to_char(max(sample_time), 'yyyymmdd hh24:mi:ss'),
-
'yyyymmdd hh24:mi:ss') - sql_exec_start) * 24 * 3600 exec_seconds
-
from dba_hist_active_sess_history a
-
where sql_id = '0az7czjdw8z7j'
-
and to_char(sample_time, 'yyyymmdd hh24:mi') between '20221003 19:00' and '20221009 21:00'
-
group by user_id, sql_id, session_id, session_serial#, sql_exec_id, sql_exec_start
-
order by sql_exec_start;
为什么别的库没事?
-
[oracle@db01-[orcl]-/home/oracle]$ opatch lspatches
-
31219919;ojvm release update: 12.2.0.1.200714 (31219919)
-
31312468;database jul 2020 release update : 12.2.0.1.200714 (31312468)
-
31309299;ocw jul 2020 release update 12.2.0.1.200714 (31309299)
是bug吗?
先不要这样想
看看备份信息实际情况
很久的都没清理
基于目前策略不应该
同样的备份软件系统,同样的配置,别的库都没事(极有可能是bug)
搭建测试环境,恢复一份全库来分析
问题复现
搜索一顿mos
-
set timing on
-
-
alter database datafile 1,2 autoextend on next 128m;
-
-
exec dbms_stats.gather_table_stats('sys','x$kccor')
-
exec dbms_stats.gather_table_stats('sys','x$krbppbctx')
-
exec dbms_stats.gather_table_stats('sys','x$kccfe')
-
exec dbms_stats.gather_table_stats('sys','x$kccdc')
-
exec dbms_stats.gather_table_stats('sys','x$kccbf')
-
exec dbms_stats.gather_table_stats('sys','x$kccbs')
-
--exec dbms_stats.gather_table_stats('sys','x$kccbp')
-
exec dbms_stats.gather_table_stats('sys','x$kccpd')
-
exec dbms_stats.gather_fixed_objects_stats;
-
begin
-
dbms_stats.gather_table_stats(
-
ownname =>'sys',
-
tabname => 'x$kccbp',
-
no_invalidate => false,
-
degree=>2,
-
method_opt=>'for all columns size auto',
-
cascade => true
-
);
-
end;
-
/
再执行report 就不再报错了
原因应该是:
备份信息太多(可能是bug)导致内部检索备份信息时生成了错误的执行计划,消耗过多的temp,收集部分固定表和全部固定表(没错),再过期一下sql area,让优化器产生正确的执行计划。
在带库的备份脚本中增加
-
delete noprompt backup completed before 'sysdate-30';
先这样。
阅读(545) | 评论(0) | 转发(0) |