In some cases we may find that gathering fresh statistics has led to the optimizer executing sub-optimal execution plans and we would like to restore the statistics as of a date when we had good performance.
REMEMBER – we gather statistics to ensure that the optimizer chooses the optimal execution plans, but gathering statistics invalidates the parsed representation of the SQL statement and reparsing the statement post gather stats can make the optimizer choose an execution plan which is different (and less optimised) than the original plan.
In Oracle 10g and above, we can also restore table statistics to a previous point in the past by using the DBMS_STATS.RESTORE_TABLE_STATS package.
Note: we can also export and import the statistics using the DBMS_STATS.CREATE_STATS_TABLE to create a statistics table which we can use to export and import statistics using the DBMS_STATS.EXPORT_*_STATS and DBMS_STATS.IMPORT_*_STATS procedures.
We can check how far back in time we can go to
Continue reading Restoring Optimizer Statistics


Popular Posts