SAP BC ORACLE 12C Cleanup ILM_EXECUTION$, ILM_RESULTS$

SAP EHP7 on oracle 12 C  IO高,经过bc老师的检测,建议用2773463 - Bad performance due to high number of entries in ILM_RESULT$ get not purged - SAP ONE Support Launchpad对应的SQL为

cleanup_ilmtasks.sql

-- Cleanup ILM_EXECUTION$, ILM_RESULTS$
-- Oracle Development Support@SAP
-- Bernhard Baumann
-- 27.03.2019
-- 
-- How To:
--  execute this script with a first inital run to remove the overdated records
--  it will remove COMPLETED tasks and STOPPED tasks, when retention time is over.
--  Its runtime may be slow due to each delete will be commited, but its safe regarding
--  UNDO usage. In same cases script need to be restarted after errors and overall initial run 
--  can need some days until all records are purged.
--  
--  sqlplus /nolog @cleanup_ilm_tasks
--  
--  after an error it can be restarted.
--  see the logfile for operation results
--  
-- Recommendation:
--  define a CRON job for execute the script once per day
--  

conn / as sysdba
spool cleanup_ilmtasks.log append

select systimestamp "BEGIN CLEANUP" from DUAL;

set serveroutput on
declare
cnt number :=0;
ntk number :=0;
rtm number;
begin

    select value into rtm from dba_ilmparameters where name = 'RETENTION TIME';

    dbms_output.put_line('Retention time for ILM task: '|| to_char(rtm) ||' days');           

    Select count(*) into ntk from SYS.ILM_EXECUTION$
              WHERE COMPLETION_TIME IS NULL 
              AND START_TIME < (SYSDATE - rtm)
              AND EXECUTION_STATE = 3;

    dbms_output.put_line('Number of obsolete ILM task seen: '|| to_char(ntk));           

 FOR r in ( Select execution_id from SYS.ILM_EXECUTION$
              WHERE COMPLETION_TIME IS NULL 
              AND START_TIME < (SYSDATE - rtm)
              AND EXECUTION_STATE = 3)   
    LOOP
    		DELETE SYS.ILM_EXECUTION$
    		WHERE EXECUTION_ID = r.execution_id;
    		
    		-- also deletes referenced records on ILM_RESULTS$ due to
    		--	foreign key (execution_id)
    		--	references  ilm_execution$(execution_id)
    		-- 	on delete cascade

		-- due to high number of records affected in ILM_RESULTS$
		-- commit is done per execution_id
		COMMIT;
		cnt := cnt+1;
    END LOOP;	
    
    
    COMMIT;
    dbms_output.put_line('Number of obsolete ILM tasks cleaned up: ' || to_char(cnt));

    exception
       when others then
	  ROLLBACK;   
	  dbms_output.put_line('Cleanup job aborted after removing '|| to_char(cnt)||' tasks');
end;
/
select systimestamp "END CLEANUP" from DUAL;
exit
-- end cleanup_ilmtask.sql

放到服务器上去执行的经过  

上传服务器 linux 的制定目录  chmod 给权限 

在sqlplus / as sysdba  下

@ 目录/cleanup_ilmtasks.sql

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

gavin_gxh

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值