Materialized view takes long to refresh
On Oracle 11g2, I created a materialized view fast refresh on commit CREATE MATERIALIZED VIEW mv_case
PARALLEL BUILD IMMEDIATE REFRESH FAST ON COMMIT ENABLE QUERY REWRITE AS
SELECT p.jperson_id,offense_id,CASE_SENTENCE_DATE,court_ref,CASE_COURT_ORI,
c.CASE_VERDICT_DATE,CASE_DOCKET,c.CASE_EXPUNGED,c.jcase_id,cc.CYCLEID_ID,
p.rowid p_rowid,xc.rowid xc_rowid,c.rowid c_rowid,cxo.rowid cxo_rowid,cc.rowid cc_row_id
FROM jperson p,jperson_x_jcase xc,jcase c,jcase_x_offense cxo,jcase_x_cycleid cc
where p.jperson_id = xc.jperson_id(+) and xc.jcase_id = c.jcase_id(+)
and c.jcase_id = cxo.jcase_id(+) and c.jcase_id=cc.jcase_id;
create index idx_mv_case_pid on mv_case(jperson_id);
ALTER TABLE mv_case ADD (CONSTRAINT PK_MV_CASE PRIMARY KEY(jcase_id,offense_id)) ;
create index idx_mv_case_p_rowid on mv_case(p_rowid);
create index idx_mv_case_xc_rowid on mv_case(xc_rowid);
create index idx_mv_case_c_rowid on mv_case(c_rowid);
create index idx_mv_case_cxo_rowid on mv_case(cxo_rowid);
create index idx_mv_case_cc_rowid on mv_case(cc_row_id); I inserted one single row into one of the master table
insert into jcase_x_offense (offense_id,jcase_id) values ('test_row3','test_row3');
commit; The commit tooks a quite long. I looked into the trace file and the actual insert took 0.01 seconds but one of the internel DML took most of time. I copy the relevant TKPROF output for the internal DML belowINSERT INTO QAPF.MV_CASE SELECT /*+ NO_MERGE(JV$) */
MAS$4.JPERSON_ID,JV$.OFFENSE_ID,MAS$2.CASE_SENTENCE_DATE,
MAS$2.COURT_REF,MAS$2.CASE_COURT_ORI,MAS$2.CASE_VERDICT_DATE,
MAS$2.CASE_DOCKET,MAS$2.CASE_EXPUNGED,MAS$2.JCASE_ID,
MAS$0.CYCLEID_ID,MAS$4.ROWID,MAS$3.ROWID,MAS$2.ROWID,JV$.RID$,
MAS$0.ROWID
FROM ( SELECT MAS$.ROWID RID$ , MAS$.* FROM QAPF.JCASE_X_OFFENSE MAS$ WHERE ROWID IN
(SELECT /*+ HASH_SJ */ CHARTOROWID(MAS$.M_ROW$$) RID$
FROM QAPF.MLOG$_JCASE_X_OFFENSE MAS$ WHERE MAS$.XID$$ = :1 )) JV$,
JCASE_X_CYCLEID AS OF SNAPSHOT(:B_SCN) MAS$0, JCASE AS OF SNAPSHOT(:B_SCN) MAS$2,
JPERSON_X_JCASE AS OF SNAPSHOT(:B_SCN) MAS$3, JPERSON AS OF SNAPSHOT(:B_SCN) MAS$4
WHERE (MAS$4.JPERSON_ID=MAS$3.JPERSON_ID(+)
AND MAS$3.JCASE_ID=MAS$2.JCASE_ID(+)
AND MAS$2.JCASE_ID=JV$.JCASE_ID(+)
AND MAS$2.JCASE_ID=MAS$0.JCASE_ID)
AND NOT EXISTS (
SELECT 1 FROM QAPF.MV_CASE SNA2$
WHERE (SNA2$.P_ROWID = MAS$4.ROWID)
AND (SNA2$.XC_ROWID = MAS$3.ROWID OR MAS$3.ROWID IS NULL )
AND (SNA2$.C_ROWID = MAS$2.ROWID OR MAS$2.ROWID IS NULL )
AND (SNA2$.CC_ROW_ID = MAS$0.ROWID OR MAS$0.ROWID IS NULL )
AND JV$.RID$ IS NULL)
AND NOT EXISTS (
SELECT 1 FROM JCASE_X_OFFENSE MAS_INNER$, JCASE AS OF SNAPSHOT(:B_SCN) MAS_OUTER$
WHERE MAS$2.ROWID = MAS_OUTER$.ROWID AND JV$.RID$ IS NULL
AND MAS_OUTER$.JCASE_ID=MAS_INNER$.JCASE_ID)
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 99.51 364.87 377012 17412972 1 0
Fetch 0 0.00 0.00 0 0 0 0
total 2 99.51 364.87 377012 17412972 1 0
Rows Row Source Operation
0 LOAD TABLE CONVENTIONAL (cr=17412968 pr=377012 pw=120527 time=0 us)
0 FILTER (cr=17412968 pr=377012 pw=120527 time=0 us)
3363837 HASH JOIN RIGHT OUTER (cr=264914 pr=280254 pw=120527 time=35845080 us cost=299444 size=1029332286 card=3363831)
1 VIEW (cr=112490 pr=180864 pw=119722 time=0 us cost=30743 size=78 card=1)
1 HASH JOIN SEMI (cr=112490 pr=180864 pw=119722 time=0 us cost=72627 size=208 card=1)
11354346 TABLE ACCESS FULL JCASE_X_OFFENSE (cr=112488 pr=112447 pw=0 time=4814838 us cost=30703 size=749386770 card=11354345)
1 TABLE ACCESS BY INDEX ROWID MLOG$_JCASE_X_OFFENSE (cr=2 pr=0 pw=0 time=0 us cost=1 size=142 card=1)
1 INDEX RANGE SCAN IDX_MLOG$_XID_JCASE_X_OFFENSE (cr=1 pr=0 pw=0 time=0 us cost=1 size=0 card=1)(object id 98375)
3363837 HASH JOIN (cr=152424 pr=99390 pw=805 time=29973970 us cost=268690 size=766953468 card=3363831)
2994042 INDEX FAST FULL SCAN JPERSON_I0 (cr=18134 pr=0 pw=0 time=772990 us cost=17450 size=134731845 card=2994041)(object id 83738)
3363837 HASH JOIN (cr=134290 pr=99390 pw=805 time=25292580 us cost=212128 size=615581073 card=3363831)
3363837 HASH JOIN (cr=69008 pr=34127 pw=805 time=4750330 us cost=101637 size=393568929 card=3363837)
3363837 TABLE ACCESS FULL JCASE_X_CYCLEID (cr=33337 pr=33322 pw=0 time=2942460 us cost=33569 size=222013242 card=3363837)
6586646 TABLE ACCESS FULL JCASE (cr=35671 pr=0 pw=0 time=1584102 us cost=35988 size=335918895 card=6586645)
6586635 TABLE ACCESS FULL JPERSON_X_JCASE (cr=65282 pr=65263 pw=0 time=5446686 us cost=65632 size=434717844 card=6586634)
3363837 FILTER (cr=17148054 pr=96758 pw=0 time=0 us)
3363837 MAT_VIEW ACCESS BY INDEX ROWID MV_CASE (cr=17148054 pr=96758 pw=0 time=0 us cost=7 size=40 card=1)
32464070 INDEX RANGE SCAN IDX_MV_CASE_P_ROWID (cr=4489770 pr=15250 pw=0 time=19576798 us cost=3 size=0 card=7)(object id 98467)
0 FILTER (cr=0 pr=0 pw=0 time=0 us)
0 NESTED LOOPS (cr=0 pr=0 pw=0 time=0 us cost=4 size=78 card=1)
0 TABLE ACCESS BY USER ROWID JCASE (cr=0 pr=0 pw=0 time=0 us cost=1 size=45 card=1)
0 INDEX RANGE SCAN JCASE_X_OFFENSE_I0 (cr=0 pr=0 pw=0 time=0 us cost=3 size=33 card=1)(object id 83623)Questions:
1) what are the objects like JCASE AS OF SNAPSHOT(:B_SCN) ? Can I index them? I tried access it but got error
select * from JCASE AS OF SNAPSHOT(:B_SCN) ;
ORA-08187: snapshot expression not allowed here
08187. 00000 - "snapshot expression not allowed here"
*Cause: A snapshot expression using AS OF was specified when not allowed.
*Action: Do not use the AS OF clause
2) In the inline view following the firs FROM, it used ROWID in where clause. I tried create an index on ROWID, and error
create index idx_jcase_offense_rid on JCASE_X_OFFENSE(rowid)
ERROR at line 1:
ORA-00904: : invalid identifier
Note: I checked that I have indexes all fields in all where clauses in the DML except rowid.
Thanks for help.
sybrand_b wrote:
1 Apparently Oracle is using Flashback technology when no materialized view logs have been set up
As your MV is a complex MV it is not a candidate for FAST REFRESH ON COMMIT.
I haven't looked closely at how 11.2 has changed the "fast refresh on commit" - but I would have expected it to raise an Oracle error when the OP tried to create the materialized view with that option if it were not possible.
I think your first comment is probably the more important one - if the user sets up suitable materialized view logs on all the tables in the outer join then it's possible that the fast refresh could work properly.
This is pure speculation, of course, based on the absence of an error message.
Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
http://www.jlcomp.demon.co.uk
To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
There is a +"Preview"+ tab at the top of the text entry panel. Use this to check what your message will look like before you post the message. If it looks a complete mess you're unlikely to get a response. (Click on the +"Plain text"+ tab if you want to edit the text to tidy it up.)
+"Science is more than a body of knowledge; it is a way of thinking"+
+Carl Sagan+
Similar Messages
-
How to CREATE MATERIALIZED VIEW LOG (MV fast refresh) with some JOINS
Hi @ all,
i'm trying to create a MATERIALIZED VIEW LOG for a fast refresh of a MATERIALIZED VIEW.
It works fine with a simple Request in the MATERIALIZED VIEW:
CREATE MATERIALIZED VIEW MV_ZOTD43_P
TABLESPACE GDII
BUILD IMMEDIATE
REFRESH FORCE AS
SELECT * FROM ZOTD43_P;
COMMIT;
CREATE MATERIALIZED VIEW LOG ON ZOTD43_P
TABLESPACE "GDII"
WITH PRIMARY KEY, ROWID, SEQUENCE INCLUDING NEW VALUES;
call DBMS_MVIEW.REFRESH('MV_ZOTD43_P', 'f');
But when I use a complex SQL-Request with some JOINS (one of the Table with spatial Data) in the MATERIALIZED VIEW, I get an error:
CREATE MATERIALIZED VIEW MV_TEST
TABLESPACE GDII
BUILD IMMEDIATE
REFRESH FORCE AS
SELECT lptd04_p.sst_nr AS sst_nr,
lptd03_p.aaaa AS aaaa,
lptd04_geom.geom as geom
FROM lptd04_p lptd04_p
JOIN lptd01_p lptd01_p ON lptd01_p.cre_nr = lptd04_p.sst_nr
JOIN lptd04_geom ON lptd04_geom.sst_nr = lptd04_p.sst_nr
JOIN lptd03_p lptd03_p ON lptd03_p.lief_nr = lptd04_p.lief_nr;
COMMIT;
CREATE MATERIALIZED VIEW LOG ON LPTD04_P
TABLESPACE "GDII"
WITH PRIMARY KEY, ROWID, SEQUENCE INCLUDING NEW VALUES;
call DBMS_MVIEW.REFRESH('MV_TEST', 'f');
Error report:
SQL Error: ORA-12004: REFRESH FAST kann für Materialized View "GDI"."MV_GDI_SST_STAMM" nicht benutzt werden
ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 2255
ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 2461
ORA-06512: in "SYS.DBMS_SNAPSHOT", Zeile 2430
ORA-06512: in Zeile 1
12004. 00000 - "REFRESH FAST cannot be used for materialized view \"%s\".\"%s\""
*Cause: The materialized view log does not exist or cannot be used. PCT
refresh is also not enabled on the materialized view
*Action: Use just REFRESH, which will reinstantiate the entire table.
If a materialized view log exists and the form of the materialized
view allows the use of a materialized view log or PCT refresh is
possible after a given set of changes, REFRESH FAST will
be available starting the next time the materialized view is
refreshed.
Am I doing something wrong or is it not possible CREATE MATERIALIZED VIEW LOG when the MATERIALIZED VIEW got some JOINS?
Regards,
GreqThanks for the link Alessandro ,
the error seems something to do with the Column-Type SDO_GEOMETRY, so
i create a new thread in the Spatial Discussion forum:
FAST REFRESHing of Oracle Materialized Views containing SDO_GEOMETRY column
Regards,
Greq -
SELECT DISTINCT xxxx
TO_CHAR(TRUNC(MTRAN.DAT_TRANSACTION_MTRAN), 'YYYY') DAT_TRANSACTION_MTRAN,
NVL((SELECT DISTINCT SUM(MTRAN1.QTY_PRIMARY_MTRAN)
FROM MAM_MATERIAL_TRANSACTIONS MTRAN1
WHERE TO_CHAR(TRUNC(MTRAN1.DAT_TRANSACTION_MTRAN),
'YYYY') =
TO_CHAR(TRUNC(MTRAN.DAT_TRANSACTION_MTRAN),
'YYYY')
AND TO_CHAR(TRUNC(MTRAN1.DAT_TRANSACTION_MTRAN),
'MM') = '01'
AND MTRAN1.MTYP_TRANSACTION_TYPE_ID IN
(41, 42, 43, 44, 45)
AND MTRAN1.ITEM_ITEM_ID_FOR = MTRAN.ITEM_ITEM_ID_FOR),
0) QTY_FARVARDIN,
NVL((SELECT DISTINCT SUM(MTRAN1.QTY_PRIMARY_MTRAN)
FROM M
i have a view like above with 10 select to select on one table.
this view take long time to execute ,how could i decrese this time!user498843 wrote:
SELECT DISTINCT xxxx
TO_CHAR(TRUNC(MTRAN.DAT_TRANSACTION_MTRAN), 'YYYY') DAT_TRANSACTION_MTRAN,
NVL((SELECT DISTINCT SUM(MTRAN1.QTY_PRIMARY_MTRAN)
FROM MAM_MATERIAL_TRANSACTIONS MTRAN1
WHERE TO_CHAR(TRUNC(MTRAN1.DAT_TRANSACTION_MTRAN),
'YYYY') =
TO_CHAR(TRUNC(MTRAN.DAT_TRANSACTION_MTRAN),
'YYYY')
AND TO_CHAR(TRUNC(MTRAN1.DAT_TRANSACTION_MTRAN),
'MM') = '01'
AND MTRAN1.MTYP_TRANSACTION_TYPE_ID IN
(41, 42, 43, 44, 45)
AND MTRAN1.ITEM_ITEM_ID_FOR = MTRAN.ITEM_ITEM_ID_FOR),
0) QTY_FARVARDIN,
NVL((SELECT DISTINCT SUM(MTRAN1.QTY_PRIMARY_MTRAN)
FROM M
i have a view like above with 10 select to select on one table.
this view take long time to execute ,how could i decrese this time!Thread: HOW TO: Post a SQL statement tuning request - template posting
HOW TO: Post a SQL statement tuning request - template posting -
Materialized view taking long time to refresh
I want to understand why materialized view refresh takes more time than running the sql for the materialized view.
For example say I have a materialized view test_mv which is created as below; When I run just the select statement i get the result within 34 secs whereas if I try to refresh it using
BEGIN
DBMS_MVIEW.refresh ('wi_mv7_monthly','C',ATOMIC_REFRESH=>false);
end;
/This takes around 74 secs
MV creation
Oracle version : Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
create materialized view TEST_MV
COLUMN_NAME_1,
OBJECT_NAME,
COLUMN_ID,
"SUM(C.DATA_LENGTH)"
) organization heap
partition by list (COLUMN_ID) (
PARTITION "first_10_col" VALUES
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
PARTITION "After_10_col" VALUES
11,12, 13, 14, 15, 16, 17, 18, 19, 20
PARTITION "NONE" VALUES (DEFAULT)
BUILD IMMEDIATE USING INDEX REFRESH COMPLETE ON DEMAND USING DEFAULT LOCAL ROLLBACK SEGMENT USING ENFORCED CONSTRAINTS
as
select /*+ parallel(o,8) parallel(c,2) */
C.COLUMN_NAME as COLUMN_NAME_1,O.OBJECT_NAME,C.COLUMN_ID,SUM(C.DATA_LENGTH) from ALL_OBJECTS O
join ALL_tab_columns c on c.table_name=o.object_name
group by
C.COLUMN_NAME,O.OBJECT_NAME,C.COLUMN_IDEdited by: user627047 on Sep 6, 2012 6:56 AMI want to understand why materialized view refresh takes more time than running the sql for the materialized view.Mview has to save the data as well .
-
Dear All,
I have created a materialized view which refreshes on commit.materialized view is enabled query rewrite.I have created a materialized view log on the base table also While inserting into the base table it takes lot of time................Can u please tell me why?Dear Rahul,
Here is my materialized view..........
create materialized view mv_test on prebuilt table refresh force on commit
enable query rewrite as
SELECT P.PID,
SUM(HH_REGD) AS HH_REGD,
SUM(INPRO_WORKS) AS INPRO_WORKS,
SUM(COMP_WORKS) AS COMP_WORKS,
SUM(SKILL_WAGE) AS SKILL_WAGE,
SUM(UN_SKILL_WAGE) AS UN_SKILL_WAGE,
SUM(WAGE_ADVANCE) AS WAGE_ADVANCE,
SUM(MAT_AMT) AS MAT_AMT,
SUM(DAYS) AS DAYS,
P.INYYYYMM,P.FIN_YEAR
FROM PROG_MONTHLY P
WHERE SUBSTR(PID,5,2)<>'PP'
GROUP BY PID,P.INYYYYMM,P.FIN_YEAR;
Please help me if query enable rewrite does any performance degradation......
Thanks & Regards
Kris -
Materialized View - Point in time refresh
I have a MV group which refreshes from a bunch of master tables. The master tables are constantly getting updated from an OLTP application. In this scenario, I want all the MVs to hold data which was available at the time the refresh started and not the changes after that.
Eg:
Master tables are T1, T2 ... T20 refresh to MVs T1_MV, T2_MV ...T20_MV
All the MVs T1_MV to T20_MV are in a refresh group.
At 3 PM: Execute an explicit refresh for the MV refresh group
At 3:05 PM: OLTP application inserts a record into table T5 & commits
At 3:06 PM (rather any time after 3:05 PM): Refresh of T5_MV happens. Will the latest insert get captured in T5_MV? I actually don't want this to happen for my requirement, because I want the data captured as of 3 PM into the MVs.
The Oracle Advanced Replication guide says the following about Materialized Views -
+"A materialized view is a replica of a target master from a single point in time."+
From the above line, it looks like by default this will not be captured in the MV. Can someone please confirm my understanding ?MVs in a Refresh Group when refreshed as a Refresh Group are refreshed as of the same point in time.
So if the Refresh Group begins at 3:00pm and ends at 3:25pm, all the MVs in that group reflect the data as in the source tables as of 3:00pm, ignoring any updates to source tables after 3:00pm (i.e. while the Group is being refreshed).
However, if you refresh MVs individually, then each MV is refreshed at it's relative point in time -- so individual Refreshs of MVs would not be to the same point in time.
How have you defined the Refresh Group ?
How do you execute the Refresh for the whole Group ? What PLSQL procedure do you use ? What parameters do you use ?
Ensure that you do not execute an individual MV Refresh.
Hemant K Chitale
http://hemantoracledba.blogspot.com -
Materialized view (creating and complete refresh)
Good day.
I have a huge query that is used to create a materialized view. The query consist of 9 joins, a lot of aggregations, some subqueries, so we can say it is rather huge. The query itself executes for about 30 seconds and returns about 200 rows. The materialized view creates and refreshes for more than 30 minutes. Can someone please explain me the mechanism of materialized view creation which causes such bad performance.
We use Oracle Database 9.2.0.4.
Thank you in advance.I've fount the solution. May be it will be useful for someone not regarding that 9.2 database is less used today than 10.2.
I studied carefully the plan of the query and the plan of insert statement that is used when creating materialized view and found the cause of trouble. Insert statements generates VIEW PUSHED PREDICATE and BITMAP CONVERSION FROM ROWIDS when parsing. Bitmap conversion can be removed by setting environment parameter btree_bitmap_plans to false (a well-known issue), but I decided not ot change the production environment. The pushed predicate can be removed by using hint NO_PUSH_PRED to each subquery used in a materialized view. This step reduced the time of materialized view creation and execution to about a minute.
Thank everyone who tried to help. -
Materialized view logs for Fast refreshes
Hi,
I created MV and MV logs on the base table/main table. I set the base table in NOLOGGING MODE. so ofcourse redo is not gonna generate during DML but i wanted to know that:
Will NOLOGGING effect the MV logs for fast refreshes?
I came up on conclusion that MV logs are nothing to do with Redo Logs and would have no impact on MV logs for fast refresh since i have set my all base table in NOLOGGING MODE.
Looking forward for expert opinion.
REGARDS,Though I'm not an expert...
SQL> alter table emp nologging;
Table altered.
SQL> create materialized view log on emp;
Materialized view log created.
SQL> select * from tab;
TNAME TABTYPE CLUSTERID
EMP TABLE
BONUS TABLE
SALGRADE TABLE
RUPD$_EMP TABLE
MLOG$_EMP TABLE
SQL> insert into emp values(1000,'Matt','Test',100,sysdate,1000,1000,10,11,11);
1 row created.
SQL> select *From mlog$_emp;
EMPNO SNAPTIME$ D O
CHANGE_VECTOR$$
1000 01-JAN-00 I N
FEFF -
MATERIALIZED VIEW BECOMES INVALID AFTER REFRESH
Hello All,
I have wierd problem ,
In my enviroinment we have a MATERIALIZED VIEW ,which is refreshed by a sheduled DBMS_SNAPSHOT.REFRESH Job post the refresh it becomes invalid and every time we have to compile it manually ,Could anybody help with a solution .Thanks a lot in Advance .
DETAILS :
======
VERSION:Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
HOST: IBM AIXIs the MV part of a refresh group?
Post the command and parameters used by the scheduled job to do the refresh as well as the parameters you use when you do it manually. -
Create materialized view is failing when refresh fast is used
version 10.2.0.4 on solaris
This statement is working fine
CREATE MATERIALIZED VIEW MVIEW1
TABLESPACE MIS_CURD01
BUILD IMMEDIATE
as
SELECT ACTIVITY_ID "ACTIVITY_ID",
ASSOC_ID "ASSOC_ID",
PIT_ROLE_CODE "PIT_ROLE_CODE",
PIT_BANK_CODE "PIT_BANK_CODE",
PIT_COST_CENTER "PIT_COST_CENTER",
RESP_ASSOC_IND "RESP_ASSOC_IND"
FROM TABLE1@DBLINK;
The statement with fast refresh is failing with this error message
ERROR at line 18:
ORA-12018: following error encountered during code generation for
"TABLE1"
ORA-00942: table or view does not exist
Here is the statement
CREATE MATERIALIZED VIEW MVIEW1
TABLESPACE MIS_CURD01
NOCACHE
LOGGING
NOCOMPRESS
NOPARALLEL
BUILD IMMEDIATE
USING INDEX TABLESPACE MIS_CURI01
REFRESH FAST ON DEMAND
WITH PRIMARY KEY
AS
SELECT ACTIVITY_ID "ACTIVITY_ID",
ASSOC_ID "ASSOC_ID",
PIT_ROLE_CODE "PIT_ROLE_CODE",
PIT_BANK_CODE "PIT_BANK_CODE",
PIT_COST_CENTER "PIT_COST_CENTER",
RESP_ASSOC_IND "RESP_ASSOC_IND"
FROM TABLE1@DBLINK;
Any idea what's going wrong here. Thanks for your help in advance.
Edited by: user11319873 on Jun 30, 2010 4:17 PMRefresh FAST requires that
a. An MV Log (Snapshot Log) be created on the source table
b. The user doing the refresh (i.e. the account that the DBLink uses) has SELECT privilege on the MV Log.
Hemant K Chitale -
Oracle Materialized view tables not getting refreshed automatically.
At Destination:--
CREATE MATERIALIZED VIEW PROG_MEDIA
TABLESPACE ONA_TS1
BUILD IMMEDIATE
REFRESH FAST with rowid
START WITH SYSDATE
NEXT SYSDATE+1/96
AS (select /*+ PARALLEL(a,6) */ * from PROG_MEDIA@onair a);
exec dbms_mview.refresh('PROG_MEDIA','C');
At Source:--
CREATE MATERIALIZED VIEW LOG ON ONAIR.PROG_MEDIA
TABLESPACE MVLOG
WITH ROWID;
Fired manually:--
13:00:43 SQL> exec dbms_mview.refresh('PROG_MEDIA','C');
PL/SQL procedure successfully completed.
At source:--
13:18:35 SQL> select PROG_MEDIA_ID,PROG_MEDIA_NAME from PROG_MEDIA where PROG_MEDIA_ID='102226';
PROG_MEDIA_ID
PROG_MEDIA_NAME
102226
test
At Destination:--
14:03:28 SQL> select PROG_MEDIA_ID,PROG_MEDIA_NAME from PROG_MEDIA where PROG_MEDIA_ID='102226';
PROG_MEDIA_ID PROG_MEDIA_NAME
102226 UTSAV-5-162077
JOB LOG_USER THIS_DATE LAST_DATE_TIME NEXT_DATE_TIME INTERVAL FAILURES WHAT
242 ONAIR 17-05-11 14:17:24 SYSDATE+1/96 7 dbms_refresh.refresh('"ONAIR"."PROG_MEDI
A"');
242 ONAIR 17-05-11 14:32:25 SYSDATE+1/96 8 dbms_refresh.refresh('"ONAIR"."PROG_MEDI
A"');
1> I have scheduled this refresh job for every 15mins, but its not getting executed. Also my job_queue_process is '20'. Whenever i execute it manually it get's refresh.
2> I can schedule a cron for the same for every 15mins but i really dont want to do it.
Kindly help me out.Hi,
I have created MV_CAPABILITIES_TABLE & executed below commands:--
17:56:54 SQL> EXECUTE DBMS_MVIEW.EXPLAIN_MVIEW ('"ONAIR"."PROG_MEDIA"');
PL/SQL procedure successfully completed.
17:57:26 SQL> SELECT capability_name, possible, SUBSTR(related_text,1,8)
17:57:27 2 AS rel_text, SUBSTR(msgtxt,1,60) AS msgtxt
17:57:27 3 FROM MV_CAPABILITIES_TABLE
17:57:27 4 ORDER BY seq;
CAPABILITY_NAME P REL_TEXT MSGTXT
PCT N
PCT N
REFRESH_COMPLETE Y
REFRESH_COMPLETE Y
REFRESH_FAST Y
REFRESH_FAST Y
REWRITE N
REWRITE N
PCT_TABLE N PROG_MED relation is not a partitioned table
PCT_TABLE N PROG_MED relation is not a partitioned table
REFRESH_FAST_AFTER_INSERT Y
REFRESH_FAST_AFTER_INSERT Y
REFRESH_FAST_AFTER_ONETAB_DML Y
REFRESH_FAST_AFTER_ONETAB_DML Y
REFRESH_FAST_AFTER_ANY_DML Y
REFRESH_FAST_AFTER_ANY_DML Y
REFRESH_FAST_PCT N PCT is not possible on any of the detail tables in the mater
REFRESH_FAST_PCT N PCT is not possible on any of the detail tables in the mater
REWRITE_FULL_TEXT_MATCH N PROG_MED mv references a remote table or view in the FROM list
REWRITE_FULL_TEXT_MATCH N PROG_MED mv references a remote table or view in the FROM list
REWRITE_FULL_TEXT_MATCH N query rewrite is disabled on the materialized view
REWRITE_FULL_TEXT_MATCH N query rewrite is disabled on the materialized view
REWRITE_PARTIAL_TEXT_MATCH N materialized view cannot support any type of query rewrite
REWRITE_PARTIAL_TEXT_MATCH N materialized view cannot support any type of query rewrite
REWRITE_PARTIAL_TEXT_MATCH N query rewrite is disabled on the materialized view
REWRITE_PARTIAL_TEXT_MATCH N query rewrite is disabled on the materialized view
REWRITE_GENERAL N materialized view cannot support any type of query rewrite
REWRITE_GENERAL N materialized view cannot support any type of query rewrite
REWRITE_GENERAL N query rewrite is disabled on the materialized view
REWRITE_GENERAL N query rewrite is disabled on the materialized view
REWRITE_PCT N general rewrite is not possible or PCT is not possible on an
REWRITE_PCT N general rewrite is not possible or PCT is not possible on an
PCT_TABLE_REWRITE N PROG_MED relation is not a partitioned table
PCT_TABLE_REWRITE N PROG_MED relation is not a partitioned table
34 rows selected.
Elapsed: 00:00:00.09
What to be done next?
Also i fired the job manually by:--
17:38:02 SQL> set serveroutput on
17:39:45 SQL> EXEC DBMS_JOB.RUN(242);
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.48 -
Create materialized view as part of refresh group
Hello,
When I create a materialized view in 11g it automatically creates its own refresh group. How can I create the materialized group as part of an existing refresh group? (I know I can drop the individual refresh group and add the mview to the main refresh group but that is a pain).
Thank you,>
How can I create the materialized group as part of an existing refresh group?
>
You can't - you need to add the MV to the existing refresh group.
See the Add Procedure of the DBMS_REFRESH package
http://docs.oracle.com/cd/B28359_01/server.111/b28327/rarrefreshpac.htm -
Materialized view takes long time to refresh but when i tried select & insert into table it's very fast.
i executed SQL and it takes ust 1min ( total rows is 447 )
but while i refresh the MVIEW it takes 1.5 hrs ( total rows is 447 )
MVIEW configration :-
CREATE MATERIALIZED VIEW EVAL.EVALSEARCH_PRV_LWC
TABLESPACE EVAL_T_S_01
NOCACHE
NOLOGGING
NOCOMPRESS
NOPARALLEL
BUILD DEFERRED
REFRESH FORCE ON DEMAND
WITH PRIMARY KEY
Not sure why so much diffrenceinfant_raj wrote:
Materialized view takes long time to refresh but when i tried select & insert into table it's very fast.
i executed SQL and it takes ust 1min ( total rows is 447 )
but while i refresh the MVIEW it takes 1.5 hrs ( total rows is 447 )A SELECT does a consistent read.
A MV refresh does that and also writes database data.
These are not the same thing and cannot be directly compared.
So instead of pointing at the SELECT execution time and asking why the MV refresh is not as fast, look instead WHAT the refresh is doing and HOW it is doing that.
Is the execution plan sane? What events are the top ones for the MV refresh? What are the wait states that contributes most to the processing time of the refresh?
You cannot use the SELECT statement's execution time as a direct comparison metric. The work done by the refresh is more than the work done by the SELECT. You need to determine exactly what work is done by the refresh and whether that work is done in a reasonable time, and how other sessions are impacting the refresh (it could very well be blocked by another session). -
Very long materialized view refresh when using self-referencing table
hi,
I have the following query, that takes 15 sec. to execute. When building a materialized view for it, the refreshing process doesn't stop for hours. The result of the query are about 500 rows and the tables contain not more than some 1000 rows, so it's a really simple query.
SELECT a.A,
b.B,
c.C
FROM (SELECT *
FROM (SELECT a
FROM TableA)) a,
(SELECT b
FROM TableA
WHERE type = 3) b,
(SELECT c
FROM TableA) c
WHERE TRIM (a.x) = TRIM (b.y) AND b.z = c.w;I think it has something to do with the fact, that the same table is used 3 times in the query. When I look in the trace I see that the following statement is executed:
INSERT /*+ BYPASS_RECURSIVE_CHECK */
INTO DM.Test_MV
SELECT ...What is the + BYPASS_RECURSIVE_CHECK / hint doing? Can I deactivate it somehow?
And why is there any difference between the query execution and the query execution when refreshing the mat view?
Thanks for your help!5 digit version no? lots of bugs with mviews out there.
theres a specific note (not a bug) on support 1115148.1 that references that hint though, so try dropping and recreating the view before refreshing. -
How do I monitor the actual refresh of materialized view.
Hi See below,
I am creating the materialized view.
It took a while to see the actual data in the table. Do you any reason.
How do I, investigate, if there is any issue, how do I monitor the actual refresh.
I am worried since, it look long time to see the actual data, after creating the materialized view.
SQL> @"ee_grant_details_mview.sql.bkp"
Snapshot dropped.
Snapshot created.
SQL>
select count(*) from grant_details_mview;SQL>
COUNT(*)
0
SQL> select count(*) from grant_details_mview;
COUNT(*)
0
SQL> commit;
Commit complete.
SQL> select count(*) from grant_details_mview;
COUNT(*)
0
SQL> select count(*) from grant_details_mview;
COUNT(*)
0
SQL> select count(*) from grant_details_mview;
COUNT(*)
0
SQL> select count(*) from grant_details_mview;
COUNT(*)
0
SQL> select count(*) from grant_details_mview;
COUNT(*)
344466
SQL>During the initial building of the materialized view, the data is not available to users until the refresh completes.
If you are talking about subsequent refreshes, you have a few options
- Can the materialized view be made fast refreshable?
- If not, can you put the materialized view be put into a refresh group? This will increase the time required to refresh, since Oracle would be deleting and inserting rather than truncating and inserting, but the old data will remain available for users until the refresh completes.
Note that the Replication or Database - General forums might be more appropriate for this sort of question. You may want to move further discussion to one of those forums.
Justin
Maybe you are looking for
-
Push notification settings changing on their own
I have an iPhone 4 and so does my wife. We understand how to set push notifications on our phones for different apps. On my wife's iPhone, the push notifications for whatsapp and viber keep switching on their own from Alerts to Banners. We do not un
-
Linking a programmatically created folder in SharePoint Document Library.
I have created folders within a document library using InfoPath & C#. To that folder I uploaded several documents using several file attachment controls within the same InfoPath Form using the code behind the form. Now I want to create an Hyperlink
-
877W %DOT11-7-CCKM_AUTH_FAILED
Sometimes when I connect to 877W router via WiFi Im getting notice (which mentioned on cisco.com site) in logs: %DOT11-7-CCKM_AUTH_FAILED : Station [enet] CCKM authentication failed official explanation is: "The station has failed CCKM authentication
-
Copy a recurring event to second calendar
I've created a recurring event, which I have also modified - meaning I have deleted a couple of recurrances. Now I want to copy that event to a public calendar, but still want to keep it in my own calendar as I usually have the public one turned off,
-
Session expired - sitzungszeit abgelaufen
I have now a new ipad mini. After setup I want to download some Apps. But I can´t buy some apps with my Itunes account. (Need to change credit card details). Seconds upon registering I get the message "session expired". It comes again and again... A