Tip

Saving time on nightly table rebuilds

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

    Requires Free Membership to View

(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

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.