• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Techgoeasy

Techgoeasy

Learn Oracle, PHP, HTML,CSS,Perl,UNIX shell scripts

  • Home
  • Oracle
    • Oracle database
    • Oracle Ebusiness Suite
    • Oracle weblogic
    • Oracle Performance Tuning
    • Oracle Hyperion
    • Oracle Cloud Tutorials
  • SQL
  • interview questions
  • Linux
  • PHP and HTML
  • Downloads
  • General
Home » Oracle » How to monitor the progress of refresh of Materialized views

How to monitor the progress of refresh of Materialized views

August 30, 2014 by techgoeasy Leave a Comment

What is materialized view

A materialized view in Oracle is a database object that contains the results of a query. They are local copies of data located remotely, or are used to create summary tables based on aggregations of a table’s data. Materialized views, which store data based on remote tables are also, know as snapshots.
We have already explained how to create materialized view and materialized view log
Oracle materialized view and materialized view log

Suppose  it is already created in the database and you want to query the defination.
The below sql  will help in that

set long 2000;
select query from user_mviews where mview_name='MV_TEST'; or select query from user_mviews where mview_name='MV_TEST';
monitor  Materialized views refresh

How to monitor the progress of refresh of Materialized views:

Many times it happens that materialized view is not refreshing from the master table(s) or the refresh is just not able to keep up with the changes occurring on the master table(s).

In these cases, we should look at below  things

(1)The job that is scheduled to run the materialized view.
(2) The materialized view log in case of fast refresh
(3) The Source table
(4) The target materialized view

First  we will need to check at the job which is scheduled to run the materialized view

  1. It could be done using refresh group
  2. It could be manually refresh using some cronjob or some other scheduling

For refresh group

The below queries gives the information about group

select * from dba_refresh;select * from dba_refresh_children;
select * from sys.v_$mvrefresh;
Then below query to find the status of job.

SELECT  /*+ RULE */
A.JOB JOB#,
SCHEMA_USER MVIEW_OWNER,
DECODE(SUBSTR(WHAT,INSTR(WHAT,’.’,1,2)+2,INSTR(WHAT,’”‘,1,4)-4-INSTR(WHAT,’.’,1,2)+2),NULL,SUBSTR(WHAT,1,40), SUBSTR(WHAT,INSTR(WHAT,’.’,1,2)+2,INSTR(WHAT,’”‘,1,4)-4-INSTR(WHAT,’.’,1,2)+2)) MVIEW_NAME,
LAST_DATE LAST_RUN_DATE,
NEXT_DATE NEXT_SCHED_RUN_DATE,
DECODE(BROKEN,’Y’,’YES’,’N’,’NO’,’ ‘) IS_BROKEN,
FAILURES,
RUNNING IS_RUNNING,
B.SID SID
FROM DBA_JOBS A
LEFT OUTER JOIN (SELECT /*+ RULE */
JOB,’YES’ RUNNING,SID
FROM DBA_JOBS_RUNNING ) B
ON A.JOB = B.JOB
ORDER BY SCHEMA_USER, MVIEW_NAME;

We can find out if the job is broken. How much time last refresh took.All those detail can be find out

We also have to check if job-queue_processes parameter is adequately setup.

sqlplus / as sysdba
show parameter job_queue_processes
alter system set job_queue_processes=20 scope=both;

The next thing to check the MVlog table in the source database. We need to check how many changes happening/every hour

select
(select count(*) from <owner>.MLOG$_<MASTER TABLE NAME> WHERE DMLTYPE$$ = ‘U’) UPDATES,
(select count(*) from <owner>.MLOG$_<MASTER TABLE NAME> WHERE DMLTYPE$$ = ‘I’) INSERTS,
(select count(*) from <owner>.MLOG$_<MASTER TABLE NAME> WHERE DMLTYPE$$ = ‘D’) DELETES,
(select count(*) from <owner>.MLOG$_<MASTER TABLE NAME>) TOTAL
from dual

If the changes are high, the refresh will take time. It may be required to increase the frequency of the refresh so as to have less changes in a refresh

The other thing to check the master table. If many changes happening  and many queries running on master table  simultaneously with refresh time,then again it will slow down  the materialized view refresh

The performance of source and target database and network utlization should also be checked

If the materialized view is being refreshed currently, you can check the progress using

sqlplus / as sysdba
SELECT * FROM V$SESSION_LONGOPS;

If the materialized view refresh is taking time, we can enable trace and find out the explain plan for the execution using below useful articles

how to enable trace in oracle
Oracle Explain Plan

Filed Under: Oracle, Oracle Database Tagged With: How to monitor the progress of refresh of Materialized views

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar



Subscribe to our mailing list

Enter your email address to subscribe to this blog and receive notifications of new posts by email

Recent Posts

  • How to generate sql monitor report in Oracle
  • How to find the long running (longops session) in Oracle
  • How to find concurrent request id from Sid or spid
  • how to check recycle bin in oracle: Purge, enable/disable
  • how to check fra size in oracle: Location, usage, change size

Copyright © 2023 : TechGoEasy

  • Hire me
  • Privacy Policy
  • Contact Us
  • New? Start Here
  • About Us