Saving time on nightly table rebuilds

The following tip explains how to gather nightly stats and analyze them at week's end.

We have several large tables that are rebuilt each evening into a new database. The size does not vary dramatically week to week, so we use the dbms_stats package to import and export the statistics on these tables each night, and only gather the statistics once per week. The code below does the weekly analyze; reset_table_stats is used as a customer deletes and gathers statistics using dbms_stats package. This script was tested on Oracle 8.1.7.4.
spool /oemmaint/qa_out/fcra_analyze.out2
delete from analyzedb.stat_table where statid in
('ASSN_FCRA','ESLL_FCRA','ESLC_FCRA','ASSN_LOA_FCRA');
commit;
exec analyzedb.reset_table_stats('APPTMGR','ASSOCIATION_LOA')
exec analyzedb.reset_table_stats('APPTMGR','ASSOCIATION')
exec analyzedb.reset_table_stats('LICMGR','ENTITY_STATE_LICENSE_LOA')
exec analyzedb.reset_table_stats('LICMGR','ENTITY_STATE_LICENSE_CLASS')
exec
dbms_stats.export_table_stats('APPTMGR','ASSOCIATION',NULL,'STAT_TABLE',
'ASSN_FCRA',TRUE,'ANALYZEDB');
exec
dbms_stats.export_table_stats('LICMGR','ENTITY_STATE_LICENSE_LOA',NULL,'
STAT_TABLE','ESLL_FCRA',TRUE,'ANALYZEDB');
exec
dbms_stats.export_table_stats('LICMGR','ENTITY_STATE_LICENSE_CLASS',NULL
,'STAT_TABLE','ESLC_FCRA',TRUE,'ANALYZEDB');
exec
dbms_stats.export_table_stats('APPTMGR','ASSOCIATION_LOA',NULL,'STAT_TAB
LE','ASSN_LOA_FCRA',TRUE,'ANALYZEDB');
delete from analyzedb.stat_table@&DESTDB where statid in
('ASSN_FCRA','ESLL_FCRA','ESLC_FCRA','ASSN_LOA_FCRA');
commit;
insert into analyzedb.stat_table@&DESTDB (select * from
analyzedb.stat_table where statid in (
'ASSN_FCRA','ESLL_FCRA','ESLC_FCRA','ASSN_LOA_FCRA'));
commit;
exit

This was first published in July 2004

Dig deeper on Oracle database backup and recovery

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close