I have a data mart mastered from our OLTP Oracle database using basic Materialized Views with on demand fast refresh capability. Refresh is working fine. What I am interested in adding are some statistics about the refresh of each Materialized View, such as the number of inserts, updates, and deletes that were applied to the master table since the last refresh like that data I can find in user_tab_modifications. Is this possible for Materialized Views?
I have a data mart mastered from our OLTP Oracle database using basic Materialized
Share
Prior to doing the refresh, you could query the materialized view log to see what sort of change vectors it stores. Those will be the change vectors that need to be applied to the materialized view during the refresh process (assuming that there is just one materialized view that depends on this materialized view log).
For example, if I create my table, my materialized view log, and my materialized view.
Now, I refresh the materialized view and verify that the table and the materialized view are in sync
Since the two objects are in sync, the materialized view log is empty (the materialized view log will be named
MLOG$_<<table name>>Now, if I insert a new row into the table, I’ll see a row in the materialized view log with a
DMLTYPE$$ofIindicating anINSERTSo you could do something like this to get the number of pending inserts, updates, and deletes.
Once you refresh the materialized view log, however, this information is gone.
On the other hand,
USER_TAB_MODIFICATIONSshould track the approximate number of changes that have been made to the materialized view since the last time that statistics were gathered on it just as it would track the information for a table. You’ll almost certainly need to callDBMS_STATS.FLUSH_DATABASE_MONITORING_INFOto force the data to be made visible if you want to capture the data before and after the refresh of the materialized view.