Restoring Previous Table Statistics on Oracle Database

If you suspect that a recent update of table statistics has caused performance problems, you may want to restore the previous statistics.
Check the statistics history to confirm if there was indeed a change in table stats:
select stats_update_time from user_tab_stats_history where table_name = 'MSEG';
Take a backup of current statistics, in case you anticipate a restore:
Create a temporary stat table to hold the current statistics:
exec dbms_stats.create_stat_table ('SAPR3', 'MSEG_NEW_STAT');
Export the current table stats to the temporary stat table:
dbms_stats.export_table_stats('SAPR3', ‘MSEG’, NULL, ‘MSEG_NEW_STAT’, NULL, true, 'SAPR3');
Restore the old stats (by time):
execute dbms_stats.restore_table_stats ('SAPR3','MSEG','19-SEP-10 10.34.27.831098 PM +08:00');

If you have been facing problems every time there is a stat update, you can disable update using the following command:

exec dbms_stats.lock_table_stats('SAPR3', 'MSEG');

If you wish to undo the restore to older statistics:
dbms_stats.import_table_stats('SAPR3', ‘MSEG’, NULL, ‘MSEG_NEW_STAT’, NULL, true, 'SAPR3');

Comments

Popular posts from this blog

OS/DB Migration - CMD. STR, TOC, EXT, R3load, DDLDBS.TPL and more

Fixing Inconsistent Table - Table activation fails due to inconsistency between DD and DB

301 Redirect Using SAP Web Dispatcher