当前位置:网站首页>[dream database] add the task of automatically collecting statistical information

[dream database] add the task of automatically collecting statistical information

2022-07-07 03:17:00 E-cology

Damon database has a weakness , When the amount of query data is large , The query speed becomes very slow , Engineers usually update statistical information , But users cannot operate manually from time to time , So I did a regular homework , Let the system do it regularly .
— Add a task to automatically collect statistics ( Every Saturday 1 Click to collect the statistics of the whole database ), stay SYSDBA Execute under the user

SP_INIT_JOB_SYS(1);        ---- If this statement reports an error , object [SYSMAILINFO] Already exists   Just wait for the information to be ignored , It indicates that the system operation has been started and will not affect 
call SP_CREATE_JOB('statistics',1,0,'',0,0,'',0,'');
call SP_JOB_CONFIG_START('statistics');
call SP_ADD_JOB_STEP('statistics', 'statistics1', 0, 'begin for rs in (select ''sf_set_SESSION_para_value(''''HAGR_HASH_SIZE'''',(select cast( case when max(table_rowcount(owner,table_name))<=(select max_value from v$dm_ini where para_Name=''''HAGR_HASH_SIZE'''') and max(table_rowcount(owner,table_name))>=( select min_value from v$dm_ini where para_Name=''''HAGR_HASH_SIZE'''') then max(table_rowcount(owner,table_name)) when max(table_rowcount(owner,table_name))<( select min_value from v$dm_ini where para_Name=''''HAGR_HASH_SIZE'''') then (select min_value from v$dm_ini where para_Name=''''HAGR_HASH_SIZE'''') else (select max_value from v$dm_ini where para_Name=''''HAGR_HASH_SIZE'''') end as bigint) from dba_tables where owner=''''''||NAME||''''''));'' sql1,''DBMS_STATS.GATHER_SCHEMA_STATS(''''''||NAME||'''''',100,TRUE,''''FOR ALL COLUMNS SIZE AUTO'''');'' sql2 from SYS.SYSOBJECTS where TYPE$=''SCH'' ) loop execute immediate rs.sql1; execute immediate rs.sql2; end loop; end;', 0, 0, 0, 0, NULL, 0);
call SP_ADD_JOB_SCHEDULE('statistics', 'statistics1', 1, 2, 1, 64, 0, '01:00:00', NULL, '2021-11-08 14:54:37', NULL, '');
call SP_JOB_CONFIG_COMMIT('statistics');
原网站

版权声明
本文为[E-cology]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207061954409725.html