Commit performance on table with Fast Refresh MV
Hi Everyone,
Trying to wrap my head around fast refresh performance and why I'm seeing (what I would consider) high disk/query numbers associated with updating the MV_LOG in a TKPROF.
The setup.
(Oracle 10.2.0.4.0)
Base table:
SQL> desc action;
Name Null? Type
PK_ACTION_ID NOT NULL NUMBER(10)
CATEGORY VARCHAR2(20)
INT_DESCRIPTION VARCHAR2(4000)
EXT_DESCRIPTION VARCHAR2(4000)
ACTION_TITLE NOT NULL VARCHAR2(400)
CALL_DURATION VARCHAR2(6)
DATE_OPENED NOT NULL DATE
CONTRACT VARCHAR2(100)
SOFTWARE_SUMMARY VARCHAR2(2000)
MACHINE_NAME VARCHAR2(25)
BILLING_STATUS VARCHAR2(15)
ACTION_NUMBER NUMBER(3)
THIRD_PARTY_NAME VARCHAR2(25)
MAILED_TO VARCHAR2(400)
FK_CONTACT_ID NUMBER(10)
FK_EMPLOYEE_ID NOT NULL NUMBER(10)
FK_ISSUE_ID NOT NULL NUMBER(10)
STATUS VARCHAR2(80)
PRIORITY NUMBER(1)
EMAILED_CUSTOMER TIMESTAMP(6) WITH LOCAL TIME
ZONE
SQL> select count(*) from action;
COUNT(*)
1388780MV was created
create materialized view log on action with sequence, rowid
(pk_action_id, fk_issue_id, date_opened)
including new values;
-- Create materialized view
create materialized view issue_open_mv
build immediate
refresh fast on commit
enable query rewrite as
select fk_issue_id issue_id,
count(*) cnt,
min(date_opened) issue_open,
max(date_opened) last_action_date,
min(pk_action_id) first_action_id,
max(pk_action_id) last_action_id,
count(pk_action_id) num_actions
from action
group by fk_issue_id;
exec dbms_stats.gather_table_stats('tg','issue_open_mv')
SQL> select table_name, last_analyzed from dba_tables where table_name = 'ISSUE_OPEN_MV';
TABLE_NAME LAST_ANAL
ISSUE_OPEN_MV 15-NOV-10
*note: table was created a couple of days ago *
SQL> exec dbms_mview.explain_mview('TG.ISSUE_OPEN_MV');
CAPABILITY_NAME P REL_TEXT MSGTXT
PCT N
REFRESH_COMPLETE Y
REFRESH_FAST Y
REWRITE Y
PCT_TABLE N ACTION relation is not a partitioned table
REFRESH_FAST_AFTER_INSERT Y
REFRESH_FAST_AFTER_ANY_DML Y
REFRESH_FAST_PCT N PCT is not possible on any of the detail tables in the mater
REWRITE_FULL_TEXT_MATCH Y
REWRITE_PARTIAL_TEXT_MATCH Y
REWRITE_GENERAL Y
REWRITE_PCT N general rewrite is not possible or PCT is not possible on an
PCT_TABLE_REWRITE N ACTION relation is not a partitioned table
13 rows selected.Fast refresh works fine. And the log is kept quite small.
SQL> select count(*) from mlog$_action;
COUNT(*)
0When I update one row in the base table:
var in_action_id number;
exec :in_action_id := 398385;
UPDATE action
SET emailed_customer = SYSTIMESTAMP
WHERE pk_action_id = :in_action_id
AND DECODE(emailed_customer, NULL, 0, 1) = 0
commit;I see the following happen via tkprof...
INSERT /*+ IDX(0) */ INTO "TG"."MLOG$_ACTION" (dmltype$$,old_new$$,snaptime$$,
change_vector$$,sequence$$,m_row$$,"PK_ACTION_ID","DATE_OPENED",
"FK_ISSUE_ID")
VALUES
(:d,:o,to_date('4000-01-01:00:00:00','YYYY-MM-DD:HH24:MI:SS'),:c,
sys.cdc_rsid_seq$.nextval,:m,:1,:2,:3)
call count cpu elapsed disk query current rows
Parse 1 0.00 0.01 0 0 0 0
Execute 2 0.00 0.03 4 4 4 2
Fetch 0 0.00 0.00 0 0 0 0
total 3 0.00 0.04 4 4 4 2
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: CHOOSE
Parsing user id: SYS (recursive depth: 1)
Rows Row Source Operation
2 SEQUENCE CDC_RSID_SEQ$ (cr=0 pr=0 pw=0 time=28 us)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file sequential read 4 0.01 0.01
update "TG"."MLOG$_ACTION" set snaptime$$ = :1
where
snaptime$$ > to_date('2100-01-01:00:00:00','YYYY-MM-DD:HH24:MI:SS')
call count cpu elapsed disk query current rows
Parse 1 0.00 0.01 0 0 0 0
Execute 1 0.94 5.36 55996 56012 1 2
Fetch 0 0.00 0.00 0 0 0 0
total 2 0.94 5.38 55996 56012 1 2
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: CHOOSE
Parsing user id: SYS (recursive depth: 1)
Rows Row Source Operation
0 UPDATE MLOG$_ACTION (cr=56012 pr=55996 pw=0 time=5364554 us)
2 TABLE ACCESS FULL MLOG$_ACTION (cr=56012 pr=55996 pw=0 time=46756 us)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file scattered read 3529 0.02 4.91
select dmltype$$, max(snaptime$$)
from
"TG"."MLOG$_ACTION" where snaptime$$ <= :1 group by dmltype$$
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.70 0.68 55996 56012 0 1
total 4 0.70 0.68 55996 56012 0 1
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: CHOOSE
Parsing user id: SYS (recursive depth: 1)
Rows Row Source Operation
1 SORT GROUP BY (cr=56012 pr=55996 pw=0 time=685671 us)
2 TABLE ACCESS FULL MLOG$_ACTION (cr=56012 pr=55996 pw=0 time=1851 us)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file scattered read 3529 0.00 0.38
delete from "TG"."MLOG$_ACTION"
where
snaptime$$ <= :1
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.71 0.70 55946 56012 3 2
Fetch 0 0.00 0.00 0 0 0 0
total 2 0.71 0.70 55946 56012 3 2
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: CHOOSE
Parsing user id: SYS (recursive depth: 1)
Rows Row Source Operation
0 DELETE MLOG$_ACTION (cr=56012 pr=55946 pw=0 time=702813 us)
2 TABLE ACCESS FULL MLOG$_ACTION (cr=56012 pr=55946 pw=0 time=1814 us)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file scattered read 3530 0.00 0.39
db file sequential read 33 0.00 0.00
********************************************************************************Could someone explain why are the SELECT/UPDATE/DELETE on MLOG$_ACTION so "expensive" when there should only be 2 rows (old value and new value) in that log after an update? Is there anything I could do to improve the performance of the update?
Let me know if you require more info...would be glad to provide it.
Brilliant. Thanks.
I owe you a beverage.
SQL> set autotrace on
SQL> select count(*) from MLOG$_ACTION;
COUNT(*)
0
Execution Plan
Plan hash value: 2727134882
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 12309 (1)| 00:02:28 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | TABLE ACCESS FULL| MLOG$_ACTION | 1 | 12309 (1)| 00:02:28 |
Note
- dynamic sampling used for this statement
Statistics
4 recursive calls
0 db block gets
56092 consistent gets
56022 physical reads
0 redo size
410 bytes sent via SQL*Net to client
400 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> truncate table MLOG$_ACTION;
Table truncated.
SQL> select count(*) from MLOG$_ACTION;
COUNT(*)
0
Execution Plan
Plan hash value: 2727134882
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 2 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | TABLE ACCESS FULL| MLOG$_ACTION | 1 | 2 (0)| 00:00:01 |
Note
- dynamic sampling used for this statement
Statistics
1 recursive calls
1 db block gets
6 consistent gets
0 physical reads
96 redo size
410 bytes sent via SQL*Net to client
400 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processedJust for fun...comparison of the TKPROF.
Before:
update "TG"."MLOG$_ACTION" set snaptime$$ = :1
where
snaptime$$ > to_date('2100-01-01:00:00:00','YYYY-MM-DD:HH24:MI:SS')
call count cpu elapsed disk query current rows
Parse 1 0.00 0.01 0 0 0 0
Execute 1 0.94 5.36 55996 56012 1 2
Fetch 0 0.00 0.00 0 0 0 0
total 2 0.94 5.38 55996 56012 1 2
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: CHOOSE
Parsing user id: SYS (recursive depth: 1)
Rows Row Source Operation
0 UPDATE MLOG$_ACTION (cr=56012 pr=55996 pw=0 time=5364554 us)
2 TABLE ACCESS FULL MLOG$_ACTION (cr=56012 pr=55996 pw=0 time=46756 us)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
db file scattered read 3529 0.02 4.91
********************************************************************************After:
update "TG"."MLOG$_ACTION" set snaptime$$ = :1
where
snaptime$$ > to_date('2100-01-01:00:00:00','YYYY-MM-DD:HH24:MI:SS')
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 7 1 2
Fetch 0 0.00 0.00 0 0 0 0
total 2 0.00 0.00 0 7 1 2
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: CHOOSE
Parsing user id: SYS (recursive depth: 1)
Rows Row Source Operation
0 UPDATE MLOG$_ACTION (cr=7 pr=0 pw=0 time=79 us)
2 TABLE ACCESS FULL MLOG$_ACTION (cr=7 pr=0 pw=0 time=28 us)
********************************************************************************
Similar Messages
-
MATERIALIZED view on two tables with Fast Refresh
i Wanted to create MV on two tables with Fast refresh on commit.
I followed below steps
create materialized view log on t1 WITH PRIMARY KEY, rowid;
create materialized view log on t2 WITH PRIMARY KEY, rowid;
CREATE MATERIALIZED VIEW ETL_ENTITY_DIVISION_ASSO_MV
REFRESH fast ON commit
ENABLE QUERY REWRITE
AS
select A.ROWID B.ROWID,a.c1, DECODE(a.c1,'aaa','xxx','aaa') c2
from t1 A
join t2 b
on AB.c1= CD.c2;
i am getting below error.
Error report:
SQL Error: ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized view
12054. 00000 - "cannot set the ON COMMIT refresh attribute for the materialized view"
*Cause: The materialized view did not satisfy conditions for refresh at
commit time.
*Action: Specify only valid options.
Basically i want to take record in MV by joinig two tables and if both of the base tables will updated then record should reflect in materialised view.
Please do the needfull.does the table support PCT? the other restrictions on joins look to be ok in your statement.
maybe try creating first with on demand instead of commit to see does it create.
http://docs.oracle.com/cd/B19306_01/server.102/b14223/basicmv.htm
>
Materialized Views Containing Only Joins
Some materialized views contain only joins and no aggregates, such as in Example 8-4, where a materialized view is created that joins the sales table to the times and customers tables. The advantage of creating this type of materialized view is that expensive joins will be precalculated.
Fast refresh for a materialized view containing only joins is possible after any type of DML to the base tables (direct-path or conventional INSERT, UPDATE, or DELETE).
A materialized view containing only joins can be defined to be refreshed ON COMMIT or ON DEMAND. If it is ON COMMIT, the refresh is performed at commit time of the transaction that does DML on the materialized view's detail table.
If you specify REFRESH FAST, Oracle performs further verification of the query definition to ensure that fast refresh can be performed if any of the detail tables change. These additional checks are:
A materialized view log must be present for each detail table unless the table supports PCT. Also, when a materialized view log is required, the ROWID column must be present in each materialized view log.
The rowids of all the detail tables must appear in the SELECT list of the materialized view query definition.
If some of these restrictions are not met, you can create the materialized view as REFRESH FORCE to take advantage of fast refresh when it is possible. If one of the tables did not meet all of the criteria, but the other tables did, the materialized view would still be fast refreshable with respect to the other tables for which all the criteria are met. -
hi everybody,
I have a problem in replication with fast refresh. I used 2 Windows 2000 server with Oracle 9i Release 9.0.1.1.1 and I can't made the automatic update. This doesn't work and I cant use ON DEMAND.
I made
Remote server
Create table teste (a number primary key, b varchar2(20));
insert into teste (a, b) values (1, 'weqwuqeui');
create materialized view log on teste with primary key;
Server Local --------
create materialized view admin.teste_mv
build immediate
refresh fast start with sysdate next sysdate + 1/1440
with primary key as
select * from teste@servidor1;
Server Remote -------
insert into teste (a, b) values (2, 'qwerty');
The first line is in the materialized view teste_mv but the second never appear.
I know it's a dumb trick but I can't solve this problem at the moment.
If somebody can help I would appreciate.
Thanks in advancethanks for the reply.
The job_queue_processes parameter in both servers is set to zero
The dba_jobs returned the following columns, every other columns are null. The next date and time is in the past.
JOB LOG_USER 1
PRIV_USER ADMIN
SCHEMA_USER ADMIN
NEXT_DATE 11-JUL-07
NEXT_SEC 17:45:47
TOTAL_TIME 0
BROKEN N
INTERVAL sysdate + 1/1440 FAILURES
WHAT dbms_refresh.refresh('"ADMIN"."TESTE_MV"');
NLS_ENV NLS_LANGUAGE='AMERICAN' NLS_TERRITORY='AMERICA' NLS_CURRENCY='$' NLS_ISO_CURRENCY='AMERICA' NLS_NUMERIC_CHARACTERS='.,' NLS_DATE_FORMAT='DD-MON-RR' NLS_DATE_LANGUAGE='AMERICAN' NLS_SORT='BINARY'
MISC_ENV 0102000200000000
INSTANCE 0
Cheers -
Materiazed view with fast refresh
Hi All,
I want to create a Materialized view with fast refresh.
I think for fast refresh we need to set up a materialized view log first before the MV gets created.
Can someone please provide the steps and the syntax to do this?
I am new to MV creation so appreciate any help in this regard.
Thanks.
AShttp://www.morganslibrary.org/library.html
Look up Materialized View Log and Materialized View ... both on the same page ... build the demo MV and you can modify the code to build any others you wish. -
Any way to materialize with fast refresh this query?
I have three tables, A, B, C
my query is:
select
from
A
inner join B on B.col=A.col
left join C on C.b_id=B.id and C.a_id=A.id
in essence, C is overriding a value from B in case it exists. I use this join often so I'd like to materialize it for performance reasons. The problem is, Mview requires traditional syntax (why is that??) which does not support joining C on two tables. Any way around this?
ThanksJernej Kase wrote:
The problem is, Mview requires traditional syntax (why is that??) which does not support joining C on two tables. Any way around this?Hi Jernej,
Your analysis is right. I don't know why MV's don't support ANSI join syntax, but I have encountered it before. Probably because when MV's where introduced, the ANSI join didn't exist in Oracle yet. But there is a way around this.
First, reproducing your situation:
SQL> create table a(id,col)
2 as
3 select 1, 'name 1' from dual union all
4 select 2, 'name 2' from dual union all
5 select 3, 'name 3' from dual
6 /
Tabel is aangemaakt.
SQL> create table b (id,col)
2 as
3 select 1, 'name 1' from dual union all
4 select 2, 'name 2' from dual union all
5 select 3, 'name 3' from dual
6 /
Tabel is aangemaakt.
SQL> create table c (a_id,b_id,col)
2 as
3 select 2, 2, 'name c2' from dual union all
4 select 3, 3, 'name c3' from dual union all
5 select 4, 4, 'name c4' from dual
6 /
Tabel is aangemaakt.
SQL> alter table a add primary key (id)
2 /
Tabel is gewijzigd.
SQL> alter table b add primary key (id)
2 /
Tabel is gewijzigd.
SQL> alter table c add primary key (a_id,b_id)
2 /
Tabel is gewijzigd.
SQL> select
2 *
3 from
4 A
5 inner join B on B.col=A.col
6 left join C on C.b_id=B.id and C.a_id=A.id
7 /
ID COL ID COL A_ID B_ID COL
1 name 1 1 name 1
2 name 2 2 name 2 2 2 name c2
3 name 3 3 name 3 3 3 name c3
3 rijen zijn geselecteerd.
SQL> create materialized view log on a with rowid
2 /
Gematerialiseerde viewlog is aangemaakt.
SQL> create materialized view log on b with rowid
2 /
Gematerialiseerde viewlog is aangemaakt.
SQL> create materialized view log on c with rowid
2 /
Gematerialiseerde viewlog is aangemaakt.
SQL> create materialized view abc_mv
2 refresh fast on commit
3 as
4 select a.rowid a_rowid
5 , b.rowid b_rowid
6 , c.rowid c_rowid
7 , a.id a_id
8 , b.id b_id
9 , a.col a_col
10 , b.col b_col
11 , c.col c_col
12 from A
13 inner join B on B.col=A.col
14 left join C on C.b_id=B.id and C.a_id=A.id
15 /
left join C on C.b_id=B.id and C.a_id=A.id
FOUT in regel 14:
.ORA-12054: cannot set the ON COMMIT refresh attribute for the materialized viewTo circumvent this error message, the only option I see is to use nested MV's like this:
SQL> create materialized view ab_mv
2 refresh fast on commit
3 as
4 select a.rowid a_rowid
5 , b.rowid b_rowid
6 , a.id a_id
7 , b.id b_id
8 , a.col a_col
9 , b.col b_col
10 from a
11 , b
12 where a.col = b.col
13 /
Gematerialiseerde view is aangemaakt.
SQL> create materialized view log on ab_mv with rowid
2 /
Gematerialiseerde viewlog is aangemaakt.
SQL> create materialized view abc_mv
2 refresh fast on commit
3 as
4 select ab.rowid ab_rowid
5 , c.rowid c_rowid
6 , ab.a_id a_id
7 , ab.b_id b_id
8 , ab.a_col a_col
9 , ab.b_col b_col
10 , c.col c_col
11 from ab_mv ab
12 , c
13 where ab.a_id = c.a_id (+)
14 and ab.b_id = c.b_id (+)
15 /
Gematerialiseerde view is aangemaakt.And to show that this works:
SQL> select * from abc_mv
2 /
AB_ROWID C_ROWID A_ID B_ID A_COL B_COL C_COL
AAGpZ4AAQAAAS2sAAA 1 1 name 1 name 1
AAGpZ4AAQAAAS2sAAB AAGpZxAAQAAAMrUAAA 2 2 name 2 name 2 name c2
AAGpZ4AAQAAAS2sAAC AAGpZxAAQAAAMrUAAB 3 3 name 3 name 3 name c3
3 rijen zijn geselecteerd.
SQL> update c set col = 'name c9' where a_id = 2
2 /
1 rij is bijgewerkt.
SQL> commit
2 /
Commit is voltooid.
SQL> select * from abc_mv
2 /
AB_ROWID C_ROWID A_ID B_ID A_COL B_COL C_COL
AAGpZ4AAQAAAS2sAAA 1 1 name 1 name 1
AAGpZ4AAQAAAS2sAAB AAGpZxAAQAAAMrUAAA 2 2 name 2 name 2 name c9
AAGpZ4AAQAAAS2sAAC AAGpZxAAQAAAMrUAAB 3 3 name 3 name 3 name c3
3 rijen zijn geselecteerd.
SQL> insert into c values (1, 1, 'bla')
2 /
1 rij is aangemaakt.
SQL> commit
2 /
Commit is voltooid.
SQL> select * from abc_mv
2 /
AB_ROWID C_ROWID A_ID B_ID A_COL B_COL C_COL
AAGpZ4AAQAAAS2sAAA AAGpZxAAQAAAMrVAAA 1 1 name 1 name 1 bla
AAGpZ4AAQAAAS2sAAB AAGpZxAAQAAAMrUAAA 2 2 name 2 name 2 name c9
AAGpZ4AAQAAAS2sAAC AAGpZxAAQAAAMrUAAB 3 3 name 3 name 3 name c3
3 rijen zijn geselecteerd.Regards,
Rob. -
Issue with fast refresh on a materialized view
Hi,
Oracle DB version is 10.2.0.3
We have a matierialized view created using this script. We have materialized view logs on these six tables.
By default, it is set to ON COMMIT .
When a batch job is run every morning (usually 100-200 records) we set it to ON DEMAND and then bring it back to ON COMMIT. It takes around 1-2 minutes.
If the batch is unusually big, like say 100,000 it takes more than 5 hours to put it back on ON COMMIT. (We analyze the schema (GATHER STALE) before refreshing the MV.) Trace shows deletes taking a long time.
When I see a big batch, I usually drop the view and recreate it with indexes (there is also a context index). Takes 30 mins to do the whole thing.
I tried refreshing it COMPLETE when the num of rows is high but it still takes more than 2 hours..(I killed it)
Is there any way to speed things up without dropping and recreating the MV ?
thanks
Mat view creation script:
CREATE MATERIALIZED VIEW WCC_INTERNAL_SEARCH_M
TABLESPACE ICV_TS_WCC_DATA
NOCACHE
LOGGING
NOCOMPRESS
NOPARALLEL
BUILD IMMEDIATE
REFRESH FAST ON COMMIT
WITH ROWID
AS
SELECT orgname.ROWID orgname_rowid,
cnt.ROWID cnt_rowid,
locgrp.ROWID locgrp_rowid,
cntry.ROWID cdcntry_rowid,
addrgrp.ROWID addrgrp_rowid,
addr.ROWID addr_rowid,
cnt.cont_id cont_id,
decode(cntry.name,'US',substr(addr.postal_code,1,5),addr.postal_code) postal_code,
cntry.name country,
UPPER(addr.addr_line_one) addr_line_one,
UPPER(addr.addr_line_two) addr_line_two,
UPPER(addr.addr_line_three) addr_line_three,
UPPER(addr.CITY_NAME) city_name,
UPPER(cnt.CONTACT_NAME) display_name,
UPPER(orgname.ORG_NAME) org_name,
addr.prov_state_tp_cd
FROM orgname,
contact cnt,
locationgroup locgrp,
cdcountrytp cntry,
addressgroup addrgrp,
address addr
WHERE locgrp.cont_id = orgname.cont_id
AND locgrp.cont_id = cnt.cont_id
AND addrgrp.location_group_id = locgrp.location_group_id
AND addr.country_tp_cd = cntry.country_tp_cd
AND addr.address_id = addrgrp.address_id
AND cnt.INACTIVATED_DT is null
AND locgrp.END_DT is null
AND orgname.END_DT is null
AND cnt.person_org_code = 'O'
AND cntry.lang_tp_cd = 100
AND locgrp.member_ind = 'Y'
AND locgrp.loc_group_tp_code = 'A'
ORDER by org_name,city_name,postal_code,country;This is the script that creates the preferences and then the context index.
exec ctx_ddl.create_preference('STEM_FUZZY_PREF', 'BASIC_WORDLIST');
exec ctx_ddl.set_attribute('STEM_FUZZY_PREF','FUZZY_MATCH','AUTO');
exec ctx_ddl.set_attribute('STEM_FUZZY_PREF','FUZZY_SCORE','60');
exec ctx_ddl.set_attribute('STEM_FUZZY_PREF','FUZZY_NUMRESULTS','100');
exec ctx_ddl.set_attribute('STEM_FUZZY_PREF','STEMMER','AUTO');
exec ctx_ddl.set_attribute('STEM_FUZZY_PREF', 'wildcard_maxterms',15000) ;
exec ctx_ddl.create_preference('LEXTER_PREF', 'BASIC_LEXER');
exec ctx_ddl.set_attribute('LEXTER_PREF','index_stems', 'ENGLISH');
exec ctx_ddl.set_attribute('LEXTER_PREF','skipjoins',',''."+/-&');
exec ctx_ddl.create_preference('ICV_WCC_INT_SEARCH_CTX_PREF', 'BASIC_STORAGE');
exec ctx_ddl.set_attribute('ICV_WCC_INT_SEARCH_CTX_PREF', 'I_TABLE_CLAUSE','tablespace ICV_TS_CTX_IDX');
exec ctx_ddl.set_attribute('ICV_WCC_INT_SEARCH_CTX_PREF', 'K_TABLE_CLAUSE','tablespace ICV_TS_CTX_IDX');
exec ctx_ddl.set_attribute('ICV_WCC_INT_SEARCH_CTX_PREF', 'N_TABLE_CLAUSE','tablespace ICV_TS_CTX_IDX');
exec ctx_ddl.set_attribute('ICV_WCC_INT_SEARCH_CTX_PREF', 'I_INDEX_CLAUSE','tablespace ICV_TS_CTX_IDX compress 2');
exec ctx_ddl.set_attribute('ICV_WCC_INT_SEARCH_CTX_PREF', 'P_TABLE_CLAUSE','tablespace ICV_TS_CTX_IDX');
exec ctx_ddl.set_attribute('ICV_WCC_INT_SEARCH_CTX_PREF', 'R_TABLE_CLAUSE','tablespace ICV_TS_CTX_IDX');
CREATE INDEX WCC_INT_SEARCH_CTX_I1 ON WCC_INTERNAL_SEARCH_M
(ORG_NAME)
INDEXTYPE IS CTXSYS.CTXCAT
PARAMETERS('Wordlist STEM_FUZZY_PREF
LEXER LEXTER_PREF
STORAGE ICV_WCC_INT_SEARCH_CTX_PREF');
DB is 10.2.0.3 -
Fast Refresh mview performance
Hi,
I'm actually facing with Fast Refresh Mview performace problems and i would like to know what is the possible improvments for the fast refresh procedure:
- base table is 1 500 000 000 rows partitions by day , subparttion by has (4)
- mlog partition by hash (4) with indexes on pk and snaptime
- mview partition by day subpartition by hash (4)
10 000 000 insertions / day in base table/mlog
What improvment or indexes can i add to improve fast refresh ?
Thanks for helpHi,
Which DB version are you using?
Did you have a look at the MV refresh via Partition Change Tracking (PCT)?
http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/advmv.htm#sthref575
If it's possible to use PCT, it would probably improve a lot the performance of the refresh of your MV.
Regards
Maurice -
Materialized view fast refresh with date field
I have a situation where I need to create a materialized view worth of 6 months of data with fast refresh option from the master table. Somehow whenever I have the where clause added with the date field then it craps out with "ORA-12015: cannot create a fast refresh materialized view from a complex query".
Here is what I am trying to do. Please let me know if there is any other way to accomplish this.
create table test (id number, date_time DATE);
CREATE MATERIALIZED VIEW LOG ON test WITH ROWID;
CREATE MATERIALIZED VIEW cms.scoreboard_statistics_mv
BUILD IMMEDIATE
REFRESH FAST
WITH ROWID
AS
SELECT * from test
WHERE date_time >= sysdate - 180;
ORA-12015: cannot create a fast refresh materialized view from a complex query
Thanks,
RajIt's crazy but a new time Metalink help us into the Note:179466.1
The restrictions that prevent snapshots from being fast refreshed depend on
the version of Oracle being used, a full list of these by version is included
in section 3. In all cases the snapshot defining query should:
- refer to fully qualified table names rather than to partial table names.
- refer to remote tables only, not to remote master views or synonyms.
- not generate context sensitive data. For example, do not create a simple
snapshot with a query that uses the SQL functions :SYSDATE, UID or USER. -
Fast Refresh in Materialized Views Partitioned
Hi all.. I've a little problem... let's go into it:
I have two tables:
A dimension table , named D1
A partitioned fact table, named F1
I create two materialized views log in each of 2 tables.
Ok.. Now, I created a Materialized View Partitioned, name MV_F1D1, with incremental refresh for it...
I can create the Materialized View Partitioned with fast refresh, no problem here...
First time Oracle make a Complete refresh, everything ok.. Then I make a
BEGIN
DBMS_SNAPSHOT.REFRESH('MV_F1D1','F');
END;
And everything goes well...
But.. In my fact tables, I load the data with a temporary table, named F1_NP (Fact table no partitionated)
with the data of the current month. Every week I do this:
1) Load the data in F1_NP
2) If the LAST_PARTITION_MM_YYYY not exists in F1, I add the partition to F1...
3) ALTER TABLE F1 EXCHANGE PARTITION LAST_PARTITION_MM_YYYY WITH TABLE F1_NP
And, this is the problem....
After that process, the Log table of F1 is empty..
When i'm trying to fast refresh the mv_F1D1, I got an error
ORA-12097 changes in the master tables during refresh, try refresh:
THis occurs when only I truncate a partition
in the fact table too.
Ok.. My only solution here is to make a complete refresh.. But I have only a new partition. I expected that with the PCT, Oracle let me
do it a fast refresh.
I'm looking for a solution in the web, and I installed the utlxmnv.sql:
1) Before add a partition in F1
truncate table mv_capabilities_table;
exec DBMS_MVIEW.EXPLAIN_MVIEW ( 'MV_F1D1' );
select * from mv_capabilities_table;
PCT Y
REFRESH_COMPLETE Y
REFRESH_FAST Y
REWRITE Y
PCT_TABLE Y F1
PCT_TABLE N D1 2068 Relation is not partitioned.
REFRESH_FAST_AFTER_INSERT Y
REFRESH_FAST_AFTER_ONETAB_DML Y
REFRESH_FAST_AFTER_ANY_DML Y
REFRESH_FAST_PCT Y
REWRITE_FULL_TEXT_MATCH Y
REWRITE_PARTIAL_TEXT_MATCH Y
REWRITE_GENERAL Y
REWRITE_PCT Y
PCT_TABLE_REWRITE Y F1
PCT_TABLE_REWRITE N D1 2068 Relation is not partitioned.
2) After truncate a partition in F1
truncate table mv_capabilities_table;
exec DBMS_MVIEW.EXPLAIN_MVIEW ( 'MV_F1D1');
select * from mv_capabilities_table;
PCT Y
REFRESH_COMPLETE Y
REFRESH_FAST Y
REWRITE Y
PCT_TABLE Y F1
PCT_TABLE N D1 2068 Relation is not partitioned.
REFRESH_FAST_AFTER_INSERT N F1 2077 Mv log is newer than last full refresh
REFRESH_FAST_AFTER_INSERT N F1 2077 Mv log is newer than last full refresh
REFRESH_FAST_AFTER_ONETAB_DML N 2146
REFRESH_FAST_AFTER_ANY_DML N F1 2076
REFRESH_FAST_AFTER_ANY_DML N 2161
REFRESH_FAST_PCT Y
REWRITE_FULL_TEXT_MATCH Y
REWRITE_PARTIAL_TEXT_MATCH Y
REWRITE_GENERAL Y
REWRITE_PCT Y
PCT_TABLE_REWRITE Y F1
PCT_TABLE_REWRITE N D1 2068 Relation is not partitioned.
BEGIN
DBMS_SNAPSHOT.REFRESH('MV_F1D1','F');
END;
ORA-32313: REFRESH FAST of "MV_F1D1" unsupported after PMOPs
any ideas? Can I fast refresh a MV partitioned (composed with a Table Dimension and Fact table)
with PCT when I add data in the Dimension Table/add a partition in a Fact Table Partitioned?Look at ATOMIC_REFRESH option, if you set this to FALSE you may see performance gain as it'll use DIRECT PATH and TRUNCATE. Data will be unavailable while being refreshed though.
Cheers
Si -
Regd FAST refresh option in a Materialized view
Hi All,
I am using a pipeline function in which I am creating a table of records and a few cursors to fetch data from various tables.
Now this PL/SQL table is being used to construct a Materialized view.
Creation of Materialized view is happening fine but not with FAST refresh option. It gives an error " Cannot create a FAST refresh Materialized view from a complex query."
The query which I have used for the view creation is
CREATE MATERIALIZED VIEW CUSTOM.ABC
PCTFREE 0
BUILD IMMEDIATE
REFRESH FAST ON DEMAND
AS
SELECT A.Number,
A.Guarantors_Number,
A.Guarantors_Name,
A.Personal_Garantee_PCNT,
A.Company, LG.Source_System,
A.Type_of_Info,
A.File_Gen_Date,
A.Periodicity
FROM
TABLE(CUSTOM.CDM_LG_PACK_PF.CDM_LG_FUNC) A;
where CDM_LG_PACK_PF is the package and CDM_LG_FUNC is the pipeline function I have written to fetch all the records.
Please help me on how can I do a FAST refresh on this materialized view.
Thanks in advance,
GauravWelcome to the forum!
FAST refresh doesn't mean that the operation is fast (time wise), it means it's an incremental refresh.
If you have a complex query, you can't use a FAST refresh - that's what the exception tells you. -
Regarding Error in Materialized view Fast Refresh
ORA-12015: cannot create a fast refresh materialized view from a complex query
CREATE MATERIALIZED VIEW MVCONTENTHISTORY_01
BUILD IMMEDIATE
REFRESH FAST
WITH PRIMARY KEY
ENABLE QUERY REWRITE
AS
SELECT a.DAY, a.contentname,
SUM
(CASE
WHEN (b.subscriptionstartdate) <= (a.DAY)
AND ((CASE
WHEN b.subscriptionenddate IS NOT NULL
THEN (a.DAY)
ELSE TO_DATE ('01/20/1990', 'MM/DD/YYYY')
END
) <=
(CASE
WHEN b.subscriptionenddate IS NOT NULL
THEN (b.subscriptionenddate)
ELSE TO_DATE ('01/20/1990', 'MM/DD/YYYY')
END
THEN 1
ELSE 0
END
) COUNT,
COUNT
(CASE
WHEN (b.subscriptionstartdate) <= (a.DAY)
AND ((CASE
WHEN b.subscriptionenddate IS NOT NULL
THEN (a.DAY)
ELSE TO_DATE ('01/20/1990', 'MM/DD/YYYY')
END
) <=
(CASE
WHEN b.subscriptionenddate IS NOT NULL
THEN (b.subscriptionenddate)
ELSE TO_DATE ('01/20/1990', 'MM/DD/YYYY')
END
THEN 1
ELSE 0
END
) cnt
FROM TBLTDATEWISECONTENT a,
(SELECT TRUNC (a.subscriptionstartdate) subscriptionstartdate,
TRUNC (a.subscriptionenddate) subscriptionenddate, b.NAME,
b.contentid
FROM syntbltcontentsubscrhistory a, syntblmcontent b
WHERE b.contentid = a.contentid(+)) b
WHERE a.contentid = b.contentid(+) AND a.DAY = b.subscriptionstartdate(+)
GROUP BY a.contentname, a.DAY;
I can't create Materialized view with fast Refresh .
Kindly provide solution .
Regards,
nayana chavda.Kindly provide full Oracle version since option vary by release.
There error message says it is impossible to fast refresh based on a complex query.
On 10g Oracle provides a package procedure that will tell you why the view cannot be fast refreshed: dbms_mview.explain_mview.
Otherwise see the Advanced Replication Manual for a list of restrictions.
10gR2 >>Restrictions for Materialized Views with Subqueries
The defining query of a materialized view with a subquery is subject to several restrictions to preserve the materialized view's fast refresh capability.
The following are restrictions for fast refresh materialized views with subqueries:
Materialized views must be primary key materialized views.
The master's materialized view log must include certain columns referenced in the subquery. For information about which columns must be included, see "Logging Columns in the Materialized View Log".
If the subquery is many to many or one to many, join columns that are not part of a primary key must be included in the materialized view log of the master. This restriction does not apply to many to one subqueries.
The subquery must be a positive subquery. For example, you can use the EXISTS condition, but not the NOT EXISTS condition.
The subquery must use EXISTS to connect each nested level (IN is not allowed).
Each table can be in only one EXISTS expression.
The join expression must use exact match or equality comparisons (that is, equi-joins).
Each table can be joined only once within the subquery.
A primary key must exist for each table at each nested level.
Each nested level can only reference the table in the level above it.
Subqueries can include AND conditions, but each OR condition can only reference columns contained within one row. Multiple OR conditions within a subquery can be connected with an AND condition.
All tables referenced in a subquery must reside in the same master site or master materialized view site.
<<
HTH -- Mark D Powell --
Message was edited by: added list of restrictions left off initial post
mpowel01 -
Regarding error in fast refresh for Materialized
ORA-12015: cannot create a fast refresh materialized view from a complex query
CREATE MATERIALIZED VIEW CRESTELVIEWSDEV510.MVCONTENTHISTORY
TABLESPACE CRESTELVIEWSDEV510
NOCACHE
LOGGING
NOCOMPRESS
NOPARALLEL
BUILD IMMEDIATE
REFRESH FAST
ENABLE QUERY REWRITE
AS
SELECT a.DAY, a.contentname,
SUM
(CASE
WHEN (b.subscriptionstartdate) <= (a.DAY)
AND ((CASE
WHEN b.subscriptionenddate IS NOT NULL
THEN (a.DAY)
ELSE TO_DATE ('01/20/1990', 'MM/DD/YYYY')
END
) <=
(CASE
WHEN b.subscriptionenddate IS NOT NULL
THEN (b.subscriptionenddate)
ELSE TO_DATE ('01/20/1990', 'MM/DD/YYYY')
END
THEN 1
ELSE 0
END
) COUNT,
COUNT
(CASE
WHEN (b.subscriptionstartdate) <= (a.DAY)
AND ((CASE
WHEN b.subscriptionenddate IS NOT NULL
THEN (a.DAY)
ELSE TO_DATE ('01/20/1990', 'MM/DD/YYYY')
END
) <=
(CASE
WHEN b.subscriptionenddate IS NOT NULL
THEN (b.subscriptionenddate)
ELSE TO_DATE ('01/20/1990', 'MM/DD/YYYY')
END
THEN 1
ELSE 0
END
) cnt
FROM TBLTDATEWISECONTENT a,
(SELECT TRUNC (a.subscriptionstartdate) subscriptionstartdate,
TRUNC (a.subscriptionenddate) subscriptionenddate, b.NAME,
b.contentid
FROM syntbltcontentsubscrhistory a, syntblmcontent b
WHERE b.contentid = a.contentid(+)) b
WHERE a.contentid = b.contentid(+)
AND a.DAY = b.subscriptionstartdate(+)
GROUP BY a.contentname, a.DAY;
while creation time of this Materialized I have receive above error ORA-12015
I have also crated log with Primary on all base tables and index on column that is in where clause.
Kindly provide solution .
I want to create this MV with FAST Refresh.
Regards,
nayana chavda.What's your Oracle version?
The error is pretty self explanatory. You can not build fast refresh MView with complex query.
check Oracle document,
http://download.oracle.com/docs/cd/B19306_01/server.102/b14226/repmview.htm#BABEEHGJ
To be fast refreshed, the defining query for a materialized view must observe certain restrictions. If you require a materialized view whose defining query is more general and cannot observe the restrictions, then the materialized view is complex and cannot be fast refreshed.
... -
M$view need to create with Fast Refersh?
Hi All,
I have to create m$veiw with Fast Refresh for only two table join.
CREATE MATERIALIZED VIEW pup_sub_poc_mv
REFRESH FAST
START WITH SYSDATE
NEXT SYSDATE+(1/48)
select a,b,c
from x, y
where x.id=y.id
and x.a in (select a from z)
i am getting below error below error.
ORA-12015: cannot create a fast refresh materialized view from a complex query
Is there any way to create Fast refresh view for above query.?Try this, I think EXISTS is suported for fast refersh, IN is not - It is Documented
CREATE MATERIALIZED VIEW pup_sub_poc_mv
REFRESH FAST
START WITH SYSDATE
NEXT SYSDATE+(1/48)
select a,b,c
from x, y
where x.id=y.id
and exists (select null from z where x.a = z.a)Just got it tested:
SQL> create materialized view log on emp;
Materialized view log created.
SQL> create materialized view log on dept;
Materialized view log created.
--"Trying with IN. Error"
SQL> create materialized view mv2
2 REFRESH FAST
3 START WITH SYSDATE
4 NEXT SYSDATE+(1/48)
5 as select * from emp where deptno in (select deptno from dept);
as select * from emp where deptno in (select deptno from dept)
ERROR at line 5:
ORA-12015: cannot create a fast refresh materialized view from a complex query
--"Trying with EXISTS."
SQL> create materialized view mv2
2 REFRESH FAST
3 START WITH SYSDATE
4 NEXT SYSDATE+(1/48)
5 as select * from emp where exists (select null from dept where dept.deptno = emp.deptno);
Materialized view created.Edited by: jeneesh on Oct 12, 2012 4:47 PM -
Materialized view - fast refresh not working on joins
Hello,
Is it true that fast refresh for materialized view is not possible when I do a union of 2 tables, although both tables have materialized view logs ?there are a number of restrictions with fast refresh, read Materialized View Fast Refresh Restrictions and ORA-12052 [ID 222843.1]
edit: his royal kyteness has posted on this before
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6506967884606
Edited by: deebee_eh on Apr 25, 2012 3:13 PM -
Materialized view fast refresh
I would like to create a fast refresh materialized view. The query is below.
create materialized view dw_v_bal_txn_fast
BUILD IMMEDIATE
refresh fast
as
SELECT b.machine_id,nvl(p.promotion_code_id,0)promotion_code_id,p.promotion_code_name
,min(bal_transaction_id) bal_transaction_id
,offered_promotion_id
,operator_session_id
,decode((case when count(*)>1 then 1 else 0 end),1,max(transaction_type),0,max(transaction_type))transaction_type
,sum(balance_change) balance_change
,min(transaction_time) transaction_time
,min(dtransaction_time) dtransaction_time
,count(*)cnt
,count(balance_change)cnt_balance_change
FROM balance_transaction b,promotion_code p
WHERE
b.machine_id=p.machine_id(+) and
b.promo_code_id=p.promotion_code_id(+)
and b.transaction_type in (3,5)
GROUP BY b.machine_id
,p.promotion_code_id,p.promotion_code_name
,offered_promotion_id
,operator_session_id
The materialized view logs are as follows:
create materialized view log on pims_repo.balance_transaction WITH SEQUENCE, ROWID
(machine_id,bal_transaction_id,MONEY_DEVICE_ID,offered_promotion_id,operator_session_id,transaction_type,
balance_change,transaction_time,dtransaction_time,EXT_KEY,PROMO_CODE_ID,IMP_FILE_HISTORY_ID,PROMOTION_CODE,ACCOUNT_MASTER_ID,EZCODE_VALUE,
PRIZECODE,PROMO_CODE_VALUE_ID
INCLUDING NEW VALUES
create materialized view log on pims_repo.promotion_code WITH SEQUENCE, ROWID
(machine_id,promotion_code_id,CONFIGURATION_ID,PROMOTION_CODE_TYPE_ID,PROMOTION_CODE_NAME,PRICE,credit,PROMOTION_ID,
ACTIVE_START_TIME,DACTIVE_START_TIME,ACTIVE_END_TIME,DACTIVE_END_TIME,AVAILABILITY,CREDIT_TYPE,TIME_MODIFIER,
DAYS,START_TIME,DURATION,TRAFFIC_WATERMARK,TRAFFIC_PERIODS,TRAFFIC_PERIOD_LEN,TRAFFIC_MIN_TIME,TRAFFIC_MAX_TIME,DERIVED
,EXPIRED,uses,USES_ON_PURCHASE,SORT_KEY,FILTER_KEY,EXT_KEY,IMP_FILE_HISTORY_ID,LINKED_PROMOTION_CODE,MARGIN_CRITERIA,
SELECTION_ODDS,AD_ONLY,REFILL_AMOUNT,FILLS
INCLUDING NEW VALUES
and the join columns (machine_id,promotion_code_id) of promotion_code has unique constraint in it.But it still says
ORA-12015: cannot create a fast refresh materialized view from a complex query
Can anyone please let me know what else needto be done.
Thanks in advance.There are certain restriction on create meterialize view with Fast Refresh
For example in your case,
Restrictions on Fast Refresh on Materialized Views with Joins Only
-They cannot have GROUP BY clauses or aggregates.
-Rowids of all the tables in the FROM list must appear in the SELECT list of the query.
-Materialized view logs must exist with rowids for all the base tables in the FROM list of the query.
Full list of restrictions here
http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14223/basicmv.htm#i1006803
Maybe you are looking for
-
This happened all of a sudden today and I didn't change anything.
-
How to read a Oracle Forms PARAMLIST without knowing parameter names
Hi All, Is there a way to read a Oracle Forms Paramlist on Oracle Forms (I mean read all parameters on it) without knowing any names of the parameters? I´d like to create a command line at run time and put on this command line all the parameters and
-
Hi SAP Gurus: Is there any way to upload JPEG picture in material master data. I know we can upload acad (autocad drawing ) in BAsic data 2 of MM master data. With Regards, Abhijit
-
How to add properties to Channels in Portal Server 7
hi, When in the Portal Server Console in the Manage Containers and Channels section I can easily edit the properties for the configured items. Now I want to add a property to, let's say, the SearchProvider or the preconfigured Search of the Developer
-
Siebel Tools 7.8: Watch window disappeared after undocking
Hi everyone, during a debugging session in Siebel Tools 7.8 I right clicked on the Watch window and deselected "Docked". Since this time the Watch windows has disappeared forever. I can activate and deactivate it, but have never seen the window again