Replication :: Oracle Materialized View / Deletion Of Records
Nov 13, 2009
One question reg Materialized views.
If as part of housekeeping of the Source database we delete some records (older records), will the materialized view also be updated with the deletion? I believe the answer is yes. In that case can we ensure that this delete does not happen?
Is there anyway we can prevent MView refresh from deleting the records that is once inserted even if we delete the same records in source DB?
We are using Oracle 10g rel 2. The replication is setup on 1 server which is in City A, and the snapshot server is in City B.
City A . Create materialized view log on table-a with primary key including new values.
City B database. Create user test_rep identified by test grant connect, resource, create any materialized view , table, view , procedure to test_rep.
Create materialized view city-A_db_MV refresh fast select * from cityA.Tablea@city-Adb
When i select from city-A_db_MV, it showed the complete table-A of city-A database.
Now if we make any changes to City-A table at the Master site, will it be propagated automatically to the MV site.
I guess we need to create jobs to push / or refresh fast .. isnt it. But exactly how to do it is a question.
Secondly if we make a replication group at Master site at city-A db, how do we refresh that Group and how to monitor whether it is refreshing on time or not? do we need to see the jobs every now and then.
but still a lot of questions unanswered, even though i had read the documents earlier.
1-The MView was created without identifying that after what interval it will be fast refreshed. 2- How to Manually refresh it. Does it support On Commit, I think it is not. 3- Where should be we make a group and then add the table to that group and refresh that group.
Should this group belongs to the Master Site or to MV site?
We have the task to create to Materialized view from oracle 10g to 8i. - Will we face any kind of issue after creation of Materialized view. check what the prerequisite need to be verified is.
I have created 5 materialize view with REFRESH FORCE option.
REFRESH is done with every 10 min. My destination database is MySQL. DBlink is created in ORACLE 10g Materialize view is created using DBLINK.
Since refresh materialize view done with every 15 min, my Redo generate gone on toss.System is generating 1 redo file for 1 min. The size for redo log is 500MB.Since materialize views are created base on mysql table, system is doing complete refresh every time which causing to generate more and more redo.
Is there any setting/option/or solution to reduce high redo generation.
i need to set up a central server with all the master tables and two other local database which will hold the updatable materialized view of the master table...the databases must be synchronized with central server..and user will work on the materialized view database...
I have attempted to set up the materialized view below to refresh complete at the time specified below. The problem is that it does not refresh and pick up the changes to one of the base tables.
Create Materialized View table_name Tablespace FG_Report Build Immediate Refresh Force Start with SYSDATE next SYSDATE+5/1440 As Select * from table_name@dblink;
after creating, i don't see indexes on the the materialized view created. where as in actual table we have indexes..
Can we replicate indexes along with Materialized views?
I have a Materialized View that gets refreshed everyday.While the DB running on oracle 9.2.0.7,It was taking around 50mins to refresh.I was using the following codes
dbms_mview.refresh('mvname','c');
After 10g upgradation the refresh process ran for more than 2 hr.So I used the following codes
It took 50mins to refresh. But what I found that the number of record count is same after each day refresh.Is there any problem with the option atomic_ refresh=>false.Why I used it -In Oracle 9.2.7.0 the 'c' option truncate the MVIEW then insert.But in Oracle 10.2.0.4.0 the 'c' option deletes the records and then insert .The option atomic_refresh=>false truncates.
Have some issue with Materialized view refresh. Have presented scenario which we have .
Schema1 : 1. Have base tables 2. Created MV logs on base tables
Schema2 : 1. Created sysnonyms for Schema1 base tables 2. created Materialized views 3. Created MV group , added views to the group
Executing the below command in schema2 : execute dbms_refresh.refresh('MV_grp');
Error : ORA-12048: error encountered while refreshing materialized view "Schema2"."Table1_MV" ORA-12018: following error encountered during code generation for "Schema2"."Table1_MV "ORA-00942: table or view does not exist ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2255 ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2461 ORA-06512: at "SYS.DBMS_IREFRESH", line 683 ORA-06512: at "SYS.DBMS_REFRESH", line 195 ORA-06512: at line 1
how much would be overhead of materialized view logs against DML on tables with few millions of records?
I need to convince my team lead before moving ahead with materialized view for few reports about overhead so is there any documentation by oracle on this issue?
How can i use refresh option as 1 hr in creation of materialized view, Can i use unoin all in the materialized view and other clause like CONNECT BY PRIOR .
I have to create a materialized view for a table which does not have index on any field.
While creating a Mview i am getting an error "TABLE DOES NOT HAVE THE PRIMARY KEY CONSTRAINT".
application developers do not want to create an index on the base table onto which MView is to be created.
is there any way to create a materialised view for the table without index, or is it necessary to have the index on the base table before creating MView on it.
How I can create a Materialized View without having any data in it.
For e.g.
I create a Materialialized View based on a View.
CREATE MATERIALIZED VIEW test_mv REFRESH FORCE ON DEMAND AS SELECT * FROM test_view
In the above case the data fetched by the view test_view gets stored in the Materialized View test_mv. Suppose I want materialized view test_mv to get created with all the columns of test_view but not the data. I will refresh the materialized view test_mv later for data as and when required.
What shall I do for immidiate formation of materialized view test_mv without data.
I inherited an existing database. I have a materialised view on a table that uses a materialised view log. I have been asked to see if it is possible to categorise the rows by change type (inserted, updated or deleted) and populate another materialised view or table accordingly. If this is possible then how can it be achieved.
1)I have a master site and local site. 2)Materialized view is refreshed at local site... and the results are stored in a cache which Java uses . 3)Any request for the mview data is retrieved from cache. 4)Now I am refreshing matview again using fast refresh.. i.e only records that are changed in the master is updated at the local site. 5) I have to flush the cache .. while flushing i have to flush only those records that are changed.... coz full flush is not good and i have to re cache the entire data if i do full flush
My Question is How to identify the records that changed....so that I can only flush those records from cache. I want to identify the changed records.
I created materialized view in Database B. The master table is in Database A. If i shutdown the database B and bring it up again, the next refresh time in dba_jobs tablein database A is coming as 01-jan-00. It is not getting refreshed automatically. The job_queue_process is 10. wat could be the reason, for the refresh failure.
i want to create "on update" database trigger on materialized view which is on replication schema.I would like to update rows in table when update occurs on materialized view on master side.I wrote some code and tried with this:
CREATE OR REPLACE TRIGGER a after update on A@dirfep.us.oracle.com FOR EACH ROW BEGIN
I am working on materialized view replication but i have an crucial issue. I have a refresh group which contain many MVs some are Read only and some are update but all are in Fast refresh mode (logs are created on both replication and MV sites on these objects) and are referentially integrated to each other i.e they have parent child relationship with each other as at replication site on base tables.
When refresh group job runs to refresh these MVs i got the errors
ORA-02292: integrity constraint (string.string) violated - child record found
After that job status has changed to break,but in the same time all the pending transactions at the MVs sites are pushed to Replication site i e ( Base tables at replication site and MVs of these tables are synchronized).In order to change the status of job to Normal, i have to disable some constraints(not all) on the MVs and manually run the job .After that job status will become Normal even i enable these constraints with validation.
What will be the reason ? Are there some MVs trying to complete refresh instead of Fast or increment refresh in this refresh group?If yes how i can trace out MVs and solve this problem?
Some other information , Replication site running with 10gR2 Enterprise Edition. Materialized View site running with 10gR2 Slandered Edition.
How does an oracle materialized view log host keep track of pulling oracle materialized view clients?By global service name or databaseid?
Case: Oracle database host A hosting table X with corresponding materialized view log MLOG$_X Oracle database host B creates a materialized view on A.X using fast refresh (pull) Oracle database host C creates a materialized view on A.X using fast refresh (pull)
How does Oracle database host A keeps track of host B and C in order to clean up MLOG$_X?
I created a Materialized view using joining of two tables with FAST REFRESH ON COMMIT option. These tables are the main tables of the DB and contains alot of data(about 15 millions of records). two master tables have index but mview doesn't have any indexes. I've thought the entire concept of the fast refresh is that it should be a relatively quick operation but the result showed that DB performance reduced, for example I could insert 900 records per minute thru application into master tables before but now I can just insert about 400 records per hour!.Also, It slows down the select operation, went from 0.11 seconds(with joining two tables) to 33 seconds (in mview)!.
First of all, I considered following possibilities and test them:
1) The most likely solution was that a complete refresh was happening. However, the materialized view refresh was confirmed to be a fast refresh by querying USER_MVIEWS.
2) I checked the query of the materialized view and confirmed that it was a simple select from the master tables without any aggregation or sorting.
3) DBMS_MVIEW.explain_mview was run on the materialized view. MV_CAPABILITIES_TABLE did not reveal any problems.
4) A query of dba_registered_snapshots showed that no other snapshots appeared to be using these logs. So, After each refresh, the records in mview logs were deleting.
As you see, it seems everything is ok, but what was causing this fast refresh to go so slow?
I use oracle 10.2 on Suse Linux enterprise server.
I am having two server A and B.B is the replica of A.I have to alter the materialized view of one of the table in server B,of which Master table is in both the servers .I do not have any Materialized view log on both the servers and want to convert the Refresh method from Complete to Fast refresh.One way of this altration is to create materialized view log on master table.
Firstly, I have created 3 mv log on 3 table(target,target extension,brand). Secondly, I created the first mv and its log. Lastly, I created the second mv from the first mv. This time I used the pivot function, but it cannot work now.
--1 create mv log
drop MATERIALIZED VIEW LOG ON target; drop MATERIALIZED VIEW LOG ON targetextension; drop MATERIALIZED VIEW LOG ON brand; CREATE MATERIALIZED VIEW LOG ON target with rowid, sequence(id); CREATE MATERIALIZED VIEW LOG ON targetextension with rowid, sequence(targetid,brandid,EmailPermission,NumberOfAllOrders); CREATE MATERIALIZED VIEW LOG ON brand with rowid, sequence(brandid, brandname);
--2 create the first mv and it's log
drop MATERIALIZED VIEW mv_target1; CREATE MATERIALIZED VIEW mv_target1 REFRESH FAST START WITH SYSDATE NEXT SYSDATE + 1/1440 AS select t1.rowid t1_rowid, t2.rowid t2_rowid, t3.rowid t3_rowid, t1.id targetid, t3.brandname, [code].....
--3 create the second mv drop MATERIALIZED VIEW mv_target2; CREATE MATERIALIZED VIEW mv_target2 REFRESH FAST START WITH SYSDATE NEXT SYSDATE + 1/1440 AS select * from mv_target1 pivot(max(EmailPermission) EmailPermission, max(NumberOfAllOrders) NumberOfAllOrders for brandName in ('XXX' XXX,'YYY' YYY ,'ZZZ' ZZZ));
Now, Here is a problem, it throws "ORA-12015: cannot create a fast refresh materialized view from a complex query". Then I used dbms_mview.explain_mview to see the reason, and it tell me the following
REFRESH_FAST_AFTER_INSERT "inline view or subquery in FROM list not supported for this type MV"
declare lv_sqltext varchar2(4000); begin execute immediate 'truncate table mv_capabilities_table'; lv_sqltext := 'select * from mv_target1 pivot(max(EmailPermission) EmailPermission, max(NumberOfAllOrders) NumberOfAllOrders for brandName in (''XXX'' XXX,''YYY'' YYY ,''ZZZ'' ZZZ))'; dbms_mview.explain_mview(lv_sqltext,'nested=>TRUE'); commit; end; /
I have a table testing_mview on 10g which do not have any primary key. I have created MV log for it:
CREATE MATERIALIZED VIEW LOG ON testing_mview WITH ROWID; Materialized view log created.
My requirement is 1) if there is an UPDATE/DELETE/INSERT on testing_mview, it should be writen to MATERIALIZED VIEW LOG (this has been achieved) 2) Materialized view testing_mview1 of 11g on server 10.1.4.32 should pull these changes on a scheduled basis ( I have created the database link ORCL10R2 here from 11g to 10 g)
On 11g: SQL> create database link ORCL10R2 connect to omig identified by pswd using '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.1.4.30)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ICS3) ) )';
Database link created
SQL> create materialized view testing_mview1 REFRESH FAST with rowid as select * from testing_mview@ORCL10R2; create materialized view testing_mview1 REFRESH FAST with rowid as select * from testing_mview@ORCL10R2 * ERROR at line 1: ORA-04052: error occurred when looking up remote object SYS.DBMS_SNAPSHOT@ORCL10R2 ORA-00604: error occurred at recursive SQL level 2 ORA-06544: PL/SQL: internal error, arguments: [55916], [], [], [], [], [], [], [] ORA-06553: PLS-801: internal error [55916] ORA-02063: preceding 2 lines from ORCL10R2
CREATE MATERIALIZED VIEW Matview1 NOLOGGING NOCACHE NOPARALLEL REFRESH COMPLETE ON DEMAND START WITH sysdate NEXT sysdate + 1 WITH ROWID ENABLE QUERY REWRITE AS select Query;
if i run select query it works fine .. also the user has create materialized view and query rewrite privs .. not sure why i am getting insufficient privileges error still ..
how to check the time taken for materialized view to execute at one time.
My materialized view is a complete refresh which automatically executes at 3:00.
a) I have queried dba_jobs and dba_mview_refresh_times, and matched the last_date and last_refresh to find the total time. How can I be know that JOB 80 corresponds to my view MVIEW_UNION in a much easier way?
SQL> select job,last_date,total_time from dba_jobs order by last_date; JOB LAST_DATE TOTAL_TIME ---------- ----------------- ---------- 80 05/05/10 03:00:02 5255
SQL>select name,last_refresh from dba_mview_refresh_times where owner NAME LAST_REFRESH ------------------------------ ----------------- MVIEW_UNION 05/05/10 03:00:02
b) Also is total_time the time it took the query to execute today at 3:00, i.e it started at 3:00 and ended at around 4:45(3+5255 msec) or is it the overall time it has taken since the day it was scheduled in dba_jobs( i.e 1 week back)
c) Also my source table dosent contain any indexes and I have created indexes on materialized view, i want to know if the complete refresh will recreate the indxes.