Monday, October 14, 2013

Use DBMS_STATS.FLUSH_DATABASE_MONITORING_INFO to flush monitoring data


Problem description:
Oracle automatic stats collection job did not collect stats on a high modified table

Cause:

The monitoring data did not get flushed.


"PL/SQL Packages and Types Reference":
===================================
"GATHER STALE: Gathers statistics on stale objects as
determined by looking at the *_tab_modifications views.
Also, return a list of objects found to be stale."

"Oracle Database Reference"
==============================
"DBA_TAB_MODIFICATIONS describes modifications to all tables in the database that
have been modified since the last time statistics were gathered on the tables."
"Note: This view is populated only for tables with the MONITORING
attribute. It is intended for statistics collection over a long period of
time. For performance reasons, the Oracle Database does not populate
this view immediately when the actual modifications occur. Run the
FLUSH_DATABASE_MONITORING_INFO procedure in the DBMS_
STATS PL/SQL package to populate this view with the latest
information. The ANALYZE_ANY system privilege is required to run
this procedure."

Solution:

Schedule a job to execute FLUSH_DATABASE_MONITORING_INFO procedure before automatic stats collection job start.