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
Similar Messages
-
Fast refresh of a materialized view works incorrect
Hi All,
I have created a MV using the sql below:
create materialized view WLS
refresh fast
enable query rewrite
as
SELECT Employees.USER_NAME,
Permissions.ROLE_NAME,
Vouchers.VOUCHER_ID,
EmployeeRoles.FROM_DATE,
EmployeeRoles.TO_DATE,
VoucherPatterns.rowid ACC_VOUCHER_PATTERNS_ROW_ID,
Vouchers.rowid ACC_VOUCHERS_ROW_ID,
Ledgers.rowid ACC_LEDGERS_ROW_ID,
Employees.rowid BANK_EMPLOYEES_ROW_ID,
IncExcUnits.rowid INC_EXC_UNITS_ROW_ID,
EmployeeRoles.rowid BANK_EMPLOYEE_ROLES_ROW_ID,
ParentRoles.rowid PARENT_ROLES_ROW_ID,
Roles.rowid ROLES_ROW_ID,
Permissions.rowid PERMISSIONS_ROLES_ROW_ID,
RolesMemberships.rowid ROLES_MEMBERSHIPS_ROW_ID
FROM ACC_VOUCHER_PATTERNS VoucherPatterns,
ACC_VOUCHERS Vouchers,
ACC_LEDGERS Ledgers,
BANK_EMPLOYEES Employees,
BANK_EMPLOYEE_INC_EXC_UNITS IncExcUnits,
BANK_EMPLOYEE_ROLES EmployeeRoles,
ROLES ParentRoles,
ROLES Roles,
ROLES Permissions,
ROLES_MEMBERSHIPS RolesMemberships
WHERE Vouchers.TYPE_VOUCHER_PATTERN_FK =
VoucherPatterns.VOUCHER_PATTERN_ID
AND VoucherPatterns.CONFIRM_COUNT = 2
AND Vouchers.STATE = 'ISU'
AND Vouchers.LEDGER_FK = Ledgers.LEDGER_ID
AND Employees.ID = IncExcUnits.BKEM_ID(+)
AND (((IncExcUnits.INC_EXCLUD_TYPE IS NULL OR
IncExcUnits.INC_EXCLUD_TYPE != 'EXC') AND
Ledgers.ORGANIZATION_UNIT_FK = Employees.ORGU_ID) OR
(Ledgers.ORGANIZATION_UNIT_FK = IncExcUnits.ORGU_ID AND
IncExcUnits.INC_EXCLUD_TYPE = 'INC'))
AND EmployeeRoles.BKEM_ID = Employees.ID
AND ParentRoles.ID = EmployeeRoles.ROLS_ID
AND ParentRoles.IS_PERMISSION = 'N'
AND ParentRoles.ROLE_TYPE = 'ORG'
AND ParentRoles.ID = Roles.ROLS_ID
AND Roles.IS_PERMISSION = 'N'
AND Roles.ROLE_TYPE = 'SYS'
AND Permissions.IS_PERMISSION = 'Y'
AND Permissions.ROLE_NAME = 'ACC_AccVoucherConfirm'
AND Roles.ID = RolesMemberships.ROLS_ID
AND Permissions.ID = RolesMemberships.ROLS_ID_MEMBER_OF;
Then I have issued a SELECT * though it and that works fine.
And then I've manipulated the data in some tables such that according to MV's WHERE clause it must return no rows.
Intuitively before refreshing the MV it will return the data last placed on it,
But it return the same data after issuing the following command in PL/SQL Developer:
call dbms_mview.refresh(list => 'WLS', method => 'F');
And unfortunately the following will correct it:
call dbms_mview.refresh(list => 'WLS', method => 'C');
Why the fast refresh of a fast refreshable MV does not work fine while its complete refresh works good?
How ever after undoing made changes to those tables and issuing the fast refresh using the following command the MV will contain correct updated data:
call dbms_mview.refresh(list => 'WLS', method => 'F');
It seems that it has bug in deleting rows from Fast Refreshable MV but upserts work fine.
I've tried to simulate the problem for a simpler query with simple tables containing some sample data but those don't have any problem.
Please help me,
ThanksThanks Martin,
Finally I've discovered one of possible several situations in which a MV fast refreshed incorrectly.
This is happened when an OR condition exists among several AND conditions and at least one outer join symbol there exists!
this is the scenario:
-- create two sample tables
create table t as select 1 a, 2 b from dual;
create table j as select 1 a, 2 b from dual;
-- defining primary keys
alter table t add constraint tp primary key (a);
alter table j add constraint jp primary key (a);
-- creating MV Logs
create materialized view log on t with primary key, rowid;
create materialized view log on j with primary key, rowid;
-- creating Fast Refresh MV with a sample query
create materialized view mvt refresh fast enable query rewrite as
select t.a, j.b, t.rowid tr, j.rowid jr from t,j where t.a = j.a(+)
and (t.b = j.b or t.a = t.b);
-- select through MV, the MV returns correct data
select * from mvt;
A B TR JR
1 2 AAAYwQAAEAAFhwzAAA AAAYwRAAEAAFhw7AAA
-- intentionally manipulate the data to the query returns no rows
update j set a = 2;
commit;
-- query the select of MV
select t.a, j.b, t.rowid tr, j.rowid jr from t,j where t.a = j.a(+)
and (t.b = j.b or t.a = t.b);
-- returns now rows, The query rewrite does not work here!
-- select through MV, the MV returns correct data because it has not refreshed yet!
select * from mvt;
A B TR JR
1 2 AAAYwQAAEAAFhwzAAA AAAYwRAAEAAFhw7AAA
-- fast refreshing the mv and issuing select again
call dbms_mview.refresh(list => 'MVT', method => 'F');
select * from mvt;
A B TR JR
1 null AAAYwuAAEAAFh2jAAA null
-- A change is occured but it is not correct, it must returns no rows!
-- query the select of MV
select t.a, j.b, t.rowid tr, j.rowid jr from t,j where t.a = j.a(+)
and (t.b = j.b or t.a = t.b);
A B TR JR
1 null AAAYwuAAEAAFh2jAAA null
-- Query rewrite does work here! because appending a neutral "and 1=1" conditions will show the correct empty result:
select t.a, j.b, t.rowid tr, j.rowid jr from t,j where t.a = j.a(+)
and (t.b = j.b or t.a = t.b) and 1=1;
-- returns no rows
-- now complete refreshing the MV and achieving the correct result:
call dbms_mview.refresh(list => 'MVT', method => 'C');
select * from mvt;
-- returns no rows
Is this a BUG?
Any suggestions? -
Issue in Complete Refresh of a Materialized View
Hello,
We have an MV in the Datawarehouse that does a FAST REFRESH daily. Every Saturday, a COMPLETE REFRESH is done as part of the normal Database Activities. The Database is Oracle 9i. The MV contains a Join between a Dimension and Fact Table of a Datawarehouse and does a FAST REFRESH using the MV logs.
However, last Sat, the COMPLETE REFRESH has failed. The DBA tried to run the script twice again but it failed on both occasions with an UNDO TABLESPACE error (ORA-30036). The DBA tried to extend the Tablespace; it did not help either.
- Could this be linked to Tablespace allocations for the MV? Are there any specific steps that can be followed to resolve this?
- Can the MV be dropped and re-created?
Would appreciate a response on the same.
Many Thanks,
KetanHi Ketan,
I guess this is probably because MV complete refresh performs "delete" from the MV and then insert. If the MV is large, it may fail on undo allocation.
Please take a look at Re: materialized view refresh time! Plz Help me! you can see the explanation, metalink note and the solution (how to perform truncate instead of delete).
HTH
Liron Amitzi
Senior DBA consultant
[www.dbsnaps.com]
[www.orbiumsoftware.com] -
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. -
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. -
Peformance on complete refresh of a Materialized View
We are currently doing a complete refresh of a materialized view (35 mil rows) on a monthly basis. My question is would it be faster to disable all the indexes prior to refresh? if so, should we enable the indexes or simply rebuild and which would be faster? Below is the package we are calling to refresh the MV. Also, our platform is Oracle 11g1 Rac on Solaris 10. Thanks.
DBMS_MVIEW.REFRESH(MVIEW_NAME, 'C', ATOMIC_REFRESH => FALSE, PARALLELISM=>16);Trace it and see.
With ATOMIC_REFRESH set to FALSE, Oracle would be doing a TRUNCATE. See if it does a Direct Path Insert. (It should be doing so).
In which case, Index maintenance is deferred to the end.
Yet, Oracle builds "temporary" index segments when doing the insert and merges them later.
You might still get a performance benefit from setting the indexes to UNUSABLE (or DROPping them) and then doing a REBUID/CREATE with NOLOGGING and a different degree of Parallelism.
You'd have to test it yourself and see what the difference is.
Hemant K Chitale -
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 -
Refresh Order Management Materialized Views errors out in R12.1.3
Hi All -
Refresh Order Management Materialized Views errors out in R12.1.3 when submitted with blank parameters. Please find below error details ..
OEXITORDMV module: Refresh Order Management Materialized Views
Current system time is 15-OCT-2012 11:30:29
**Starts**15-OCT-2012 11:30:29
ORACLE error 12008 in FDPSTP
Cause: FDPSTP failed due to ORA-12008: error in materialized view refresh path
ORA-01555: snapshot too old: rollback segment number 4 with name "_SYSSMU4_3768336236$" too small
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2566
ORA
Start of log messages from FND_FILE
End of log messages from FND_FILE
Thanks,Cause: FDPSTP failed due to ORA-12008: error in materialized view refresh path
ORA-01555: snapshot too old: rollback segment number 4 with name "_SYSSMU4_3768336236$" too small
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2566Please see old threads for the ORA-015555 docs you need to refer to.
https://forums.oracle.com/forums/search.jspa?threadID=&q=ORA-01555&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
https://forums.oracle.com/forums/search.jspa?threadID=&q=ORA-01555+AND+Materialized+AND+View&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
Thanks,
Hussein -
Issue with complete refresh on materialized view when using rownum
Hi all,
I had an issue with rownum when using complete refresh
I am using rownum when creating materialized view and it is generation correctly.But the issue was when i am refreshing the same ,rownum was not getting sorted in ascending order.
anyone had come across this scenariorownum is determined as the row is output, so "order by rownum" does literally nothing.
http://docs.oracle.com/cd/B19306_01/server.102/b14200/pseudocolumns009.htm -
Refresh fails on materialized view with CLOB data type
Hi,
Hope somebody can help me with this issue.
Some materialized views get status broken on refreshment, but only sometime. When I try to refresh them manually I get following message: "ORA-01400: cannot insert NULL into...". But I know for sure that there are no NULL values in the master table, MV and master tables are declared in the same way and all columns in master tables are NOT NULL columns. Another ting is that this error I get only on columns with data type CLOB.
Please, help!
/Juliahi,
I cant upgrade to 11g.Also i cant change the table structure.
Here is a sample of xmltype field content:
RECID XMLRECORD
D00009999 <row id='D100009999'><c2>10000</c2><c3>xxxxx</c3><c5>xxxx..
And i need to extract in the mv the data from c2, c3 and so on.
Still waiting for a hint.
Thank you. -
About Refresh Error In Materialized view
hi
i have
Oracle 9.2.0.1 at the windows server 2003
i have created some materialized view to use in my one web application running on tomcat
i have scheduling for refresh it using refresh utility available in oracle materialized view snapshot refresh
but when its try to run state of refresh become unusable and table according to it
remains empty
when i try to do it manually it gives error log
Ora-12008 error in materialized view refresh path
ora-01114 io error writing block to file 201(block #2621321)
ora-27069 skgfdisp:attmempt to do i/o beyond the range of file
osd-04026 invalid parameter passed(OS 2621327)
ora-01114 io error writing block to file 201(block#2621321)
ora-27069 skgfdisp:attempt do i/o beyond the range of the file
osd-04026 invalid parameter passed (OS 2621327)
ora 06512 at "SYS.DBMS_SNAPSHOt",line 794
ora 06512 at "SYS.DBMS_SNAPSHOt", line 851
ora 06512 at "SYS.DBMS_SNAPSHOt", line 832
ora 06512 at line 2
even i could not understand this error
one strange thing in this when i restart my server and try to refresh
it is going to be refresh
please help meI suspect one of your datafiles has exceeded the 4Gb windows limit. Your tablespace has probably been set to autoextend and this has created the problem. I am not sure what you can do at this point apart from recover from backup. I would open a TAR with Oracle Support as soon as possible to try and resolve this issue.
Please note: This forum is for OLAP issues only. If you need more information I would try posting on the database forum.
Keith Laker
Oracle EMEA Consulting
OLAP Blog: http://oracleOLAP.blogspot.com/
OLAP Wiki: http://wiki.oracle.com/page/Oracle+OLAP+Option
DM Blog: http://oracledmt.blogspot.com/
OWB Blog : http://blogs.oracle.com/warehousebuilder/
OWB Wiki : http://wiki.oracle.com/page/Oracle+Warehouse+Builder
DW on OTN : http://www.oracle.com/technology/products/bi/db/11g/index.html -
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)
******************************************************************************** -
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. -
Refresh of a materialized view
Hi All!
I have a materialized view defined like:
CREATE MATERIALIZED VIEW v_ship_info_new
PCTFREE 5 PCTUSED 60
TABLESPACE DATA_BIG
STORAGE
INITIAL 32768K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
USING INDEX STORAGE (INITIAL 2M NEXT 500K)
REFRESH START WITH ROUND(SYSDATE + 1) + 08/24
NEXT ROUND(SYSDATE + 2) + 08/24
AS
SELECT .....
The view was created on Sep.-13-2005. I expected that the view will be refreshed today at 08:00 AM, but the last_ddl_time in user_objects is Sep.-18-2005 and the data in the view is also from Sep.-18-2005. There is no time filter in SELECT statement. The view should shows a result of left outer join of two tables.
Any idea?
Thanks,
AndrejAndrej,
You should consider the NEXT interval relative to the last materialized view refresh. Reading your materialized view definition it results that:
- the materialized view was refreshed for the first time on 14-sep at 8:00 am (START WITH ROUND(SYSDATE + 1) + 08/24)
- the materialized view is then refreshed on 16-sep at 8:00 am, 18-sep at 8:00 am (ROUND(SYSDATE + 2) + 08/24)
Considering you have specified the START WITH clause in your command, the NEXT date should be considered starting from the timestamp of the last refresh and not from the moment of the materialized view creation.
Regards,
Adi -
Refresh time for Materialized View
Hi,
I have created a materialized view and set it to refresh everyday at 4 am . When I check the status of the job , it shows the refresh timing between 20 mins to 4 hours . That means , some times it takes 20 mins to refresh , some times 40 , some time 2 hours and some times up to 4 hours. Any reason for the wide range ? Here is the query for the view.
CREATE MATERIALIZED VIEW BDS_COST_CATEGORY_MV
ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS"
BUILD IMMEDIATE
USING INDEX
REFRESH COMPLETE ON DEMAND START WITH sysdate+0 NEXT ROUND(SYSDATE + 1) + 4/24
USING DEFAULT LOCAL ROLLBACK SEGMENT
DISABLE QUERY REWRITE
AS SELECT AC.ACCOUNT_MANAGER, AC.ACCOUNT_NUMBER,
AC.ACCOUNT_NAME, DIV.DIVISION_NUMBER, ITEM.CODE_ID,
ITEM.CODE_NAME COST_CATEGORY_ITEM,
TO_NUMBER(TO_CHAR(AP.FIRST_DAY,'YYYY')) PERIOD_YEAR,
AP.FIRST_DAY PERIOD,
SUM(NVL(AD.CURRENT_EXPENSE,0)) EXPENSE
FROM ACCOUNTS AC, PERSONNEL AC_MGR, DIVISIONS DIV, ASR_HEADERS AH , ASR_DETAILS AD, CODES ITEM, CODES COSTCAT, ALL_PERIODS AP,
CODES COST_ELEMENT, ACCOUNTING_BASE_GROUP ABG
WHERE AC.ACCOUNT_MANAGER = AC_MGR.PERSONNEL_ID
AND AC_MGR.DIVISION_ID = DIV.DIVISION_ID (+)
AND AC.ACCOUNT_ID = AH.ACCOUNT_ID
AND AH.ASR_HEADER_ID = AD.ASR_HEADER_ID
AND AH.PERIOD_ASR = AP.FISCAL_SYSTEM_PERIOD_CAL_YR_EQ||', '|| AP.FISCAL_YEAR
AND ABG.COST_ELEMENT_CAT_ITEM_ID = ITEM.CODE_ID
AND COST_ELEMENT.CODE_ID = ABG.COST_ELEMENT_ID
AND AD.OBJECT_CODE = COST_ELEMENT.CODE_VALUE
AND ITEM.CODE_PARENT_ID = COSTCAT.CODE_ID
AND ( COSTCAT.CODE_NAME = 'BDS' OR ( COSTCAT.CODE_NAME = 'Base' AND ITEM.CODE_NAME = 'MTDC'))
GROUP BY AC.ACCOUNT_MANAGER,AC.ACCOUNT_NUMBER, AC.ACCOUNT_NAME,
DIV.DIVISION_NUMBER, ITEM.CODE_ID, ITEM.CODE_NAME,
TO_NUMBER(TO_CHAR(AP.FIRST_DAY,'YYYY')), AP.FIRST_DAYThis appears to be a duplicate of Refreshing Materilized view. I replied on the other thread.
Justin
Maybe you are looking for
-
Purchased movie in iTunes but "cannot load at this time"
Using my iPad, I purchased a movie on iTunes (through the iTunes app). Purchased was confirmed. The movie appears in my "Videos" app, but it will only play if I am connected to my wifi. If I go to iTunes it will show up as a "Purchased" movie and
-
Hi there, I just bought a web premium CS 4 suite. I am able to use all the other programmes however I am unable to use the photoshop CS 4. On start up, while it loads "reading preferences", another pop-up window appears with the message "Adobe Photos
-
Album Art Missing/No​t Showing Up...Among Other Things
Recently my new Q10 has decided to stop showing album art randomly - I say randomly as art work that used to show has now suddenly gone either black or now shows the default blue note art. I am practically OCD about my mp3 tags and while 3 different
-
Derivation of wrong commitment item in ML81N
Dear all, A material document is created in ML81N with expenses a/c Dr. & provision for expenses a/c Cr & the budget is cosumed with debit of the expenses.& also Cr of this provision for expenses.Because the system defaulting the committment item of
-
Personal Information iViews missing in Business Package for E.S.S.
Hi all, we have imported the business package for Employee Self-Service (ERP2005, Release 1.0 for nw2004s) in our portal. The iViews for the application 'Personal Information' (like 'Address', 'Bank Information',...) are language dependent and in the