--1、创建日志分析结果表
create table MONITORINDEX
(
INDEX_NAME VARCHAR2(50),
DEL_LF_ROWS NUMBER,
LF_ROWS NUMBER,
RATE NUMBER(4,2),
MONITORDATE DATE default sysdate not null
);
2、日志分析过程
create or replace procedure analyzeindex is
v_sql varchar2(100);
begin
delete from monitorindex where trunc(MONITORDATE)=trunc(sysdate);
commit;
for a in (select index_name from all_indexes where wner = 'AAA') loop
v_sql:='validate index '||a.index_name;
-- v_sql := ' analyze index ' || a.index_name || ' validate structure';
execute immediate v_sql;
insert into monitorindex
(index_name, del_lf_rows, lf_rows, rate)
select name,
del_lf_rows,
lf_rows,
round(del_lf_rows * 100 / (lf_rows + del_lf_rows+0.00000000001), 2)
from index_stats;
commit;
end loop;
end analyzeindex;
/
注:该分析最好安排在业务操作低的时候处理,否则中途可能会报错退出。
也尽量不要让分析跨凌晨0点。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/38006/viewspace-623208/ ,如需转载,请注明出处,否则将追究法律责任。