A peculiar matter about Materialized Views
Hi ,
I have created successfully some months ago some MV. Later on , I was made to destroy the database and create a new one , using the DBCA. The peculiar is that whenever i issue the command :
sql> drop materialized view stat_biox_f_mv;
Oracle displays the error ORA-12003: the materialized view stat_biox_f_mv does not exist.
When i issue the command:
sql>create materialized view stat_biox_f_mv
build immediate
refresh start with (sysdate)+(10/1440)
next (sysdate)+10/1440
as
select count(f) N_f,sum(f) Sx_f,round(avg(f),3) x_f,round(stddev(f),3) SD_f,
round(avg(f)+2*stddev(f),3) Ru_f,round(avg(f)-2*stddev(f),3) Rd_f,
round(stddev(f)/sqrt(count(f)),3) SE_f,round((100*stddev(f))/avg(f),3) CV_f,
round(count(f)*((sum(power(f,4))-(power(sum(f),4)/count(f)))/
(power((sum(power(f,2))-(power(sum(f),2)/count(f))),2)))-3,3) Sk_f,
round((sum(power(f,2))-(power(sum(f),3)/count(f)))/
(power(stddev(f),2)*count(f)),3) Sa_f
from biox
Oracle displays the error ORA-00955: the object does exist
Eventually , the object exists or does not...?????
Thanks , a lot
Simon
Have you queried all_objects? Perhaps the materialized view doesn't exist but a table with the same name does. If you do find any objects with that name, drop them.
SELECT * FROM all_objects WHERE object_name = UPPER('stat_biox_f_mv');
Have you tried creating this MV with a different name? Does that work?
Similar Messages
-
I want detail info about materialized views?
I want detail info about materialized views?
The best place to start is the documentation available free online:
http://www.oracle.com/pls/db102/ -
Hi,
Can you please give me some link or info about Materilized view.I want to know in what cases Materilized views are most efficient.Can you also send me advantages and disadvantages of Materialized views
Thanks
AnandData warehousing guide
http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/toc.htm
Four chapters:
Basic materialized views
Advanced materialized views
Basic Query Rewrite
Advanced Query Rewrite
Gints Plivna
http://www.gplivna.eu -
I want to know about Materialized Views
Hi,
I am very new to this Oracle.
In my project, we are using Materialized Views to refresh. but I am not having the good Idea on this. and in our project we golden gate also. both are refreshing purpose i think so. So could you please help me...
Best Regards,
Naresh.Tuser13405404 wrote:
yes,
I have gone through the pages. And please i ahve dought, like
1)How it is going to be refreshed..?(Manuall/Auto)That depends on how you define the materialized view. You can (subject to various restrictions) have the materialized view refresh as part of the transaction that modifies the underlying tables, on a fixed schedule, or on demand.
2)will occupie space(No, because its a view)A materialized view does occupy space. You are creating a copy of the underlying data.
Justin -
Fast Refresh Materialized View - failure
Okay, this issue currently has me stumped. I searched the world wide web and still cannot seem to identify the cause of this issue.
Here is the scenario:
I created a materialized view log for the source table (let's say table1) found at DB1.
I then create a materialized view (fast refresh, with logging) at a remote database (let's say DB2). The query for the MV is basic: select * from schema1.table1@db1_link;
I set the materialized view to refresh every 30 seconds (for testing purposes).
This creates a dbms job that executes every 30 seconds. The materialized view gets created successfully. I purposely enter new data into table1. The materialized view log for table1 successfully captures these changes. However, the materialized view found at DB2 does not get refreshed (updated) successfully.
In fact, the dbms job errors-out. It keeps failing and failing. After 16 times, it gets marked as 'broken.'
The error message is as such:
RDBA WARNING: ORA-12012: error on auto execute of job 1472
RDBA WARNING: ORA-00604: error occurred at recursive SQL level 3
RDBA WARNING: ORA-01017: invalid username/password; logon denied
RDBA WARNING: ORA-02063: preceding line from db1
RDBA WARNING: ORA-06512: at "SYS.DBMS_SNAPSHOT", line 820
RDBA WARNING: ORA-06512: at "SYS.DBMS_SNAPSHOT", line 877
RDBA WARNING: ORA-06512: at "SYS.DBMS_IREFRESH", line 683
RDBA WARNING: ORA-06512: at "SYS.DBMS_REFRESH", line 195
RDBA WARNING: ORA-06512: at line 1
The strange thing is, that the error supposedly claims invalid username/password. But I've used the db links successfully before & the username/password is not invalid. Has anyone encountered this issue before?Justin,
From reading earlier posts about issues with materialized views, I remember reading something about materialized views (fast refreshable) not working with sysdate. What did you mean by such a statement? (I would copy & paste it here, but I am unable to find it at the moment).
The reason I am curious, is the fact that I am setting my MV to refresh every 30 seconds let's say (for testing). At this moment - it starts failing & failing & failing. -
Query rewrites with Nested materialized views with different aggregations
Platform used : Oracle 11g.
Here is a simple fact table (with measures m1,m2) and dimensions (a) Location (b) Calendar and (c) Product. The business problem is that aggregation operator for measure m1,m2 are different along location dimension and Calendar dimension. The intention is to preaggregate the measures for a product along the calendar dimension and Location dimension and store it as materialized views.
The direct option is to define a materialized view with Inline queries (Because of the different aggrergation operator, it is not possible to write a query without Inline query). http://download-uk.oracle.com/docs/cd/B28359_01/server.111/b28313/qradv.htm#BABEAJBF documents the limitations that it works only for 'Text match' and 'Equivalent queries' and that is too limiting.
So decided to have nested materialized view, with first view having just joins(my_dim_mvw_joins), the second view having aggregations along Calendar dimension (my_dim_mvw_calendar) and third view having aggregations along the Location dimension(my_dim_mvw_location). Obviously I do not want the query I fire to know about materialized views and I fire it against the fact table. I see that for the fired query (Which needs aggregations along both Calendar and Location), is rewritten with just second materialized view but not the third. (Had set QUERY_REWRITE_INTEGRITY as TRUSTED) .
Wanted to know whether there are limitations on Query Writes with nested materialized views? Thanks
(Have given a simple testable example below. Pls ignore the values given in 'CALENDAR_IDs', 'PRODUCT_IDs' etc as they are the same for all the queries)
-- Calendar hierarchy table
CREATE TABLE CALENDAR_HIERARCHY_TREE
( "CALENDAR_ID" NUMBER(5,0) NOT NULL ENABLE,
"HIERARCHY1_ID" NUMBER(5,0),
"HIERARCHY2_ID" NUMBER(5,0),
"HIERARCHY3_ID" NUMBER(5,0),
"HIERARCHY4_ID" NUMBER(5,0),
CONSTRAINT "CALENDAR_HIERARCHY_TREE_PK" PRIMARY KEY ("CALENDAR_ID")
-- Location hierarchy table
CREATE TABLE LOCATION_HIERARCHY_TREE
( "LOCATION_ID" NUMBER(3,0) NOT NULL ENABLE,
"HIERARCHY1_ID" NUMBER(3,0),
"HIERARCHY2_ID" NUMBER(3,0),
"HIERARCHY3_ID" NUMBER(3,0),
"HIERARCHY4_ID" NUMBER(3,0),
CONSTRAINT "LOCATION_HIERARCHY_TREE_PK" PRIMARY KEY ("LOCATION_ID")
-- Product hierarchy table
CREATE TABLE PRODUCT_HIERARCHY_TREE
( "PRODUCT_ID" NUMBER(3,0) NOT NULL ENABLE,
"HIERARCHY1_ID" NUMBER(3,0),
"HIERARCHY2_ID" NUMBER(3,0),
"HIERARCHY3_ID" NUMBER(3,0),
"HIERARCHY4_ID" NUMBER(3,0),
"HIERARCHY5_ID" NUMBER(3,0),
"HIERARCHY6_ID" NUMBER(3,0),
CONSTRAINT "PRODUCT_HIERARCHY_TREE_PK" PRIMARY KEY ("PRODUCT_ID")
-- Fact table
CREATE TABLE RETAILER_SALES_TBL
( "PRODUCT_ID" NUMBER,
"PRODUCT_KEY" VARCHAR2(50 BYTE),
"PLAN_ID" NUMBER,
"PLAN_PERIOD_ID" NUMBER,
"PERIOD_ID" NUMBER(5,0),
"M1" NUMBER,
"M2" NUMBER,
"M3" NUMBER,
"M4" NUMBER,
"M5" NUMBER,
"M6" NUMBER,
"M7" NUMBER,
"M8" NUMBER,
"LOCATION_ID" NUMBER(3,0),
"M9" NUMBER,
CONSTRAINT "RETAILER_SALES_TBL_LOCATI_FK1" FOREIGN KEY ("LOCATION_ID")
REFERENCES LOCATION_HIERARCHY_TREE ("LOCATION_ID") ENABLE,
CONSTRAINT "RETAILER_SALES_TBL_PRODUC_FK1" FOREIGN KEY ("PRODUCT_ID")
REFERENCES PRODUCT_HIERARCHY_TREE ("PRODUCT_ID") ENABLE,
CONSTRAINT "RETAILER_SALES_TBL_CALEND_FK1" FOREIGN KEY ("PERIOD_ID")
REFERENCES CALENDAR_HIERARCHY_TREE ("CALENDAR_ID") ENABLE
-- Location dimension definition to promote query rewrite
create DIMENSION LOCATION_DIM
LEVEL CHAIN IS LOCATION_HIERARCHY_TREE.HIERARCHY1_ID
LEVEL CONSUMER_SEGMENT IS LOCATION_HIERARCHY_TREE.HIERARCHY3_ID
LEVEL STORE IS LOCATION_HIERARCHY_TREE.LOCATION_ID
LEVEL TRADING_AREA IS LOCATION_HIERARCHY_TREE.HIERARCHY2_ID
HIERARCHY PROD_ROLLUP (
STORE CHILD OF
CONSUMER_SEGMENT CHILD OF
TRADING_AREA CHILD OF
CHAIN
-- Calendar dimension definition
create DIMENSION CALENDAR_DIM
LEVEL MONTH IS CALENDAR_HIERARCHY_TREE.HIERARCHY3_ID
LEVEL QUARTER IS CALENDAR_HIERARCHY_TREE.HIERARCHY2_ID
LEVEL WEEK IS CALENDAR_HIERARCHY_TREE.CALENDAR_ID
LEVEL YEAR IS CALENDAR_HIERARCHY_TREE.HIERARCHY1_ID
HIERARCHY CALENDAR_ROLLUP (
WEEK CHILD OF
MONTH CHILD OF
QUARTER CHILD OF
YEAR
-- Materialized view with just joins needed for other views
CREATE MATERIALIZED VIEW my_dim_mvw_joins build immediate refresh complete enable query rewrite as
select product_id, lht.HIERARCHY1_ID, lht.HIERARCHY2_ID, lht.HIERARCHY3_ID, lht.location_id, cht.HIERARCHY1_ID year,
cht.HIERARCHY2_ID quarter, cht.HIERARCHY3_ID month, cht.calendar_id week, m1, m3, m7, m9
from retailer_sales_tbl RS, calendar_hierarchy_tree cht, location_hierarchy_tree lht
WHERE RS.period_id = cht.CALENDAR_ID
and RS.location_id = lht.location_id
and cht.CALENDAR_ID in (10,236,237,238,239,608,609,610,611,612,613,614,615,616,617,618,619,1426,1427,1428,1429,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,1450,1451,1452,1453,1454,1455,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1471,1472,1473,1474,1475,1476,1477)
AND product_id IN (5, 6, 7, 8, 11, 12, 13, 14, 17, 18, 19, 20)
AND lht.location_id IN (2, 3, 11, 12, 13, 14, 15, 4, 16, 17, 18, 19, 20)
-- Materialized view which aggregate along calendar dimension
CREATE MATERIALIZED VIEW my_dim_mvw_calendar build immediate refresh complete enable query rewrite as
select product_id, HIERARCHY1_ID , HIERARCHY2_ID , HIERARCHY3_ID ,location_id, year, quarter, month, week,
sum(m1) m1_total, sum(m3) m3_total, sum(m7) m7_total, sum(m9) m9_total,
GROUPING_ID(product_id, location_id, year, quarter, month, week) dim_mvw_gid
from my_dim_mvw_joins
GROUP BY product_id, HIERARCHY1_ID , HIERARCHY2_ID , HIERARCHY3_ID , location_id,
rollup (year, quarter, month, week);
-- Materialized view which aggregate along Location dimension
CREATE MATERIALIZED VIEW my_dim_mvw_location build immediate refresh complete enable query rewrite as
select product_id, year, quarter, month, week, HIERARCHY1_ID, HIERARCHY2_ID, HIERARCHY3_ID, location_id,
sum(m1_total) m1_total_1, sum(m3_total) m3_total_1, sum(m7_total) m7_total_1, sum(m9_total) m9_total_1,
GROUPING_ID(product_id, HIERARCHY1_ID, HIERARCHY2_ID, HIERARCHY3_ID, location_id, year, quarter, month, week) dim_mvw_gid
from my_dim_mvw_calendar
GROUP BY product_id, year, quarter, month, week,
rollup (HIERARCHY1_ID, HIERARCHY2_ID, HIERARCHY3_ID, location_id)
-- SQL Query Fired (for simplicity have used SUM as aggregation operator for both, but they will be different)
select product_id, year, HIERARCHY1_ID, HIERARCHY2_ID,
sum(m1_total) m1_total_1, sum(m3_total) m3_total_1, sum(m7_total) m7_total_1, sum(m9_total) m9_total_1
from
select product_id, HIERARCHY1_ID , HIERARCHY2_ID , year,
sum(m1) m1_total, sum(m3) m3_total, sum(m7) m7_total, sum(m9) m9_total
from
select product_id, lht.HIERARCHY1_ID , lht.HIERARCHY2_ID , lht.HIERARCHY3_ID ,lht.location_id, cht.HIERARCHY1_ID year, cht.HIERARCHY2_ID quarter, cht.HIERARCHY3_ID month, cht.calendar_id week,m1,m3,m7,m9
from
retailer_sales_tbl RS, calendar_hierarchy_tree cht, location_hierarchy_tree lht
WHERE RS.period_id = cht.CALENDAR_ID
and RS.location_id = lht.location_id
and cht.CALENDAR_ID in (10,236,237,238,239,608,609,610,611,612,613,614,615,616,617,618,619,1426,1427,1428,1429,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,1450,1451,1452,1453,1454,1455,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1471,1472,1473,1474,1475,1476,1477)
AND product_id IN (5, 6, 7, 8, 11, 12, 13, 14, 17, 18, 19, 20)
AND lht.location_id IN (2, 3, 11, 12, 13, 14, 15, 4, 16, 17, 18, 19, 20)
GROUP BY product_id, HIERARCHY1_ID , HIERARCHY2_ID , HIERARCHY3_ID , location_id, year
) sales_time
GROUP BY product_id, year,HIERARCHY1_ID, HIERARCHY2_ID
This Query rewrites only with my_dim_mvw_calendar. (as saw in Query Plan and EXPLAIN_MVIEW). But we would like it to use my_dim_mvw_location as that has aggregations for both dimensions.blackhole001 wrote:
Hi all,
I'm trying to make my programmer's life easier by creating a database view for them to query the data, so they don't have to worry about joining tables. This sounds like a pretty horrible idea. I say this because you will eventually end up with programmers that know nothing about your data model and how to properly interact with it.
Additionally, what you will get is a developer that takes one of your views and see's that of the 20 columns in it, it has 4 that he needs. If all those 4 columns comes from a simple 2 table join, but the view has 8 tables, you're wasting a tonne of resources by using the view (and heaven forbid they have to join that view to another view to get 4 of the 20 columns from that other view as well).
Ideally you'd write stored routines that satisfy exactly what is required (if you are the database resource and these other programmers are java, .net, etc... based) and the front end developers would call those routines customized for an exact purpose.
Creating views is not bad, but it's by no means a proper solution to having developers not learn or understand SQL and/or the data model. -
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 -
Fast refresh materialized view on demand but not working
Hi all,
I've created a simple table called xx using the following statements:
1.) create table xx(x1 varchar2(10),x2 varchar2(10),x3 varchar2(10);
2.) alter table xx add primary key (x1,x2);
I've also created a materialized log on xx using:
3.) create materialized view log on xx;
Finally, I've create a very simple materialized view based on the table xx using:
4.) create materialized view mv_xx refresh fast on demand as select * from xx;
The version of Oracle I'm currently using is:
Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
PL/SQL Release 9.2.0.6.0 - Production
CORE 9.2.0.6.0 Production
TNS for 32-bit Windows: Version 9.2.0.6.0 - Production
NLSRTL Version 9.2.0.6.0 - Production
Everything seems to be ok. However when I execute the dbms_mview.refresh('mv_xx','f') after performing any DMLs like INSERT, DELETE or UPDATE statements to the xx table. The data never gets refreshed to mv_xx and it only works on the complete refresh. Could anyone help me please as I must have missed or misunderstood some of the points about materialized view. By the way, do I need to set any flags or alter any system or session parameters prior to creating the materialized view or any other related components. Thank you.
Regards,
JohnYes, mv_xx is created in the same schema as xx. Do you have any ideas.
-
Question on materialized view unregistered on master site
Hi
not sure how it is known, on master site, about the existence of an materialized view on another site referring some table of a master site. it seems registering is not necessary.
on master site orcl1 : I have a table A, and a materialized view log defined on table A.
on another site orcl2 : have a db link to orcl1 and a fast refreshable materialized view SCOTT.A_MVW (create materialized view A_MVW refresh fast as select * from A@orcl1)
on orcl1 I perform : exec DBMS_MVIEW.UNREGISTER_MVIEW (mviewowner => 'SCOTT' ,mviewname => 'A_MVW' ,mviewsite => 'ORCL2');
as a result the materialized view seems to be successfully unregistered (as it doesn't appear anymore in : select * from DBA_REGISTERED_MVIEWS; )
But, to my surprise, I can still perform fast refreshes on A_MVW, which also remove lines from the materialized view log . so how is site orcl1 still aware about the existence of the materialized view ?
it seems that, registered or not at master site, a materialized view behaves the same...or it doesn't ? where is it stored , on master site, information about materialized views (especially those fast refreshable) that reffer local tables ?
Thank youThe view allows the Administrator at the Master (Source) site to see information about MVs in remote databases that are querying his/her database.
A database in Singapore may be administered by DBA "Hemant" . This database may have built (with appropriate permissions !!!) an MV that queries table(s) in a database in London managed by "Alex". Alex can query DBA_REGISTERED_MVIEWS in his (London) database to see that a remote MV is referencing tables locally.
Why would "Alex" UNREGISTER the MV ? There's no real need to. Unless the information needs to be "hidden" from, say, an Outsource DBA who will be taking "Alex"'s place ! (just kidding !)
Hemant K Chitale -
How to pull materialized view code from database
I wana to view the code for the materialized view from the data base server.Whats the statment to fetch the code of materialized view from the database.
Neeraj GoelThere is table user_mviews,from where we get query and others related matter to materialized views.
Neeraj Goel -
Hi all,
I am reading about materialized view from 9i documentation. In this it is mentioned that for updatable materialized views one needs to have updatable materialized view log, but it is not given the log has to be created by us like the materialized view log used for fast refresh or is it automatically created. Also in types of materialized view I can see primary key materialized view and row id materialized view and in materialized view log creation I can see that two type of log creation is possible, one is primary kep MV log and rowid MV log. If mmy understanding is correct then Primary key MV can have only primary key log created. Am I right? One more fact is that one cant import MV from one schema to other by mentioning fromuser to user parameter in 9i, but when I tried doing it in 11g it got imported fine. So is it a new feature too?
Thanks
Kris.When you create a materialized view you should be able to set the refresh interval. Using that, you can refresh the M view based on your needs. Below example has the sytanx:
CREATE MATERIALIZED VIEW mv_emp_pk
REFRESH FAST START WITH SYSDATE
NEXT SYSDATE + 1/48
WITH PRIMARY KEY
AS SELECT * FROM emp@remote_db; -
A problem about ORA-12058 of materialized view
consider the huge data of tableB, we make a decision about build materialized view using "on prebuilt table" parameter.
create materialiezd view log on tableB rowid mode.
when we create materialized view we got the error ORA-12058.
Is there someone can tell us why?
thank you very much我
SQL> CREATE MATERIALIZED VIEW USERA.TABLEA
3 REFRESH FORCE
4 WITH ROWID
5 AS SELECT * FROM USERB.TABLEB@DBLINK01 ;
CREATE MATERIALIZED VIEW USERA.TABLEA
ON PREBUILT TABLE
REFRESH FORCE
WITH ROWID
AS SELECT * FROM USERB.TABLEB@DBLINK01
ORA-12058: materialized view cannot use prebuilt tableHello SuperPianist,
Please take a look at this document, and let me know if the troubleshooting steps help to resolve your microphone issues.
Good luck!
↙-----------How do I give Kudos?| How do I mark a post as Solved? ----------------↓ -
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 -
About LAST_REFRESH_DATE in Materialized views
Hi, in the user_mviews view there is a field called LAST_REFRESH_DATE.
Does it show the time when the last refresh STARTED or when the last refresh FINISHED populating the materialized view?
Thanks in advance.Yep, as Tekicora says: it's the time the last refresh started.
Ran a quick test ('cos I didn't know the answer) by creating a basic mview and refreshing it:
SQL> declare
2 start_time CHAR(8);
3 end_time CHAR(8);
4 refresh_time CHAR(8);
5 begin
6 select to_char(sysdate,'HH24:MI:SS') into start_time from dual;
7 dbms_mview.refresh('JJCMV');
8 select to_char(sysdate,'HH24:MI:SS') into end_time from dual;
9 select to_char(last_refresh_date,'HH24:MI:SS') into refresh_time from dba_mviews where mview_name = 'JJCMV'
10 dbms_output.put_line(start_time);
11 dbms_output.put_line(end_time);
12 dbms_output.put_line(refresh_time);
13* end;
SQL> /
20:37:22
20:46:36
20:37:23
PL/SQL procedure successfully completed.Pretty crude, but I think it demonstrates the answer. -
Materialized View Not Picked Up
Hopefully I'm doing something wrong, because so far
Materialized Views are useless. What's happening
is that the MV is only picked up by a select
statement when the select is identical to the MV
query - this means that we'd have to create a
separate MV for each possible query.
Here's an example:
create materialized view
FACT_DIM04_LVL02
enable query rewrite
as
select
d04.DKEY
, d04.LVL02_DESCR
, f.KEY01
, f.KEY03
, f.YEAR_MONTH
, f.SCENARIO
, sum(f.AMOUNT) "AMOUNT"
from FACT1 f
, DIM04 d04
where (f.KEY04 = d04.KEY04)
and (f.ATTR01 = 'O')
and (d04.LVL01_DESCR = '9999')
and (f.SCENARIO IN ('ACT', 'PLAN'))
group by
d04.DKEY
, d04.LVL02_DESCR
, f.KEY01
, f.KEY03
, f.YEAR_MONTH
, f.SCENARIO
analyze table FACT_DIM04_LVL02 compute statistics ;
So far so good. Now let's do an EXPLAIN using the exact
same DDL used to create the MV:
explain plan
set STATEMENT_ID = 'FACT04'
for
select
d04.DKEY
, d04.LVL02_DESCR
, f.KEY01
, f.KEY03
, f.YEAR_MONTH
, f.SCENARIO
, sum(f.AMOUNT) "AMOUNT"
from FACT1 f
, DIM04 d04
where (f.KEY04 = d04.KEY04)
and (f.ATTR01 = 'O')
and (d04.LVL01_DESCR = '9999')
and (f.SCENARIO IN ('ACT', 'PLAN'))
group by
d04.DKEY
, d04.LVL02_DESCR
, f.KEY01
, f.KEY03
, f.YEAR_MONTH
, f.SCENARIO
This gives:
Query Plan
SELECT STATEMENT Cost = 602
TABLE ACCESS FULL FACT_DIM04_LVL02
Great. However, now let's add one tiny little additional
where clause to the query:
explain plan
set STATEMENT_ID = 'FACT04'
for
select /*+ REWRITE */
d04.DKEY
, d04.LVL02_DESCR
, f.KEY01
, f.KEY03
, f.YEAR_MONTH
, f.SCENARIO
, sum(f.AMOUNT) "AMOUNT"
from FACT1 f
, DIM04 d04
where (f.KEY04 = d04.KEY04)
and (f.ATTR01 = 'O')
and (d04.LVL01_DESCR = '9999')
and (f.SCENARIO IN ('ACT', 'PLAN'))
and (1 = 1)
group by
d04.DKEY
, d04.LVL02_DESCR
, f.KEY01
, f.KEY03
, f.YEAR_MONTH
, f.SCENARIO
Notice that I added the simplest predicate possible
(1 = 1), AND I've added a hint telling the optimizer
to use the new MV. However, Oracle does not recognize
the MV; instead it goes back to the base tables:
Query Plan
SELECT STATEMENT Cost = 4130
SORT GROUP BY
HASH JOIN
TABLE ACCESS BY INDEX ROWID DIM04
INDEX RANGE SCAN DIM04_LVL02
TABLE ACCESS FULL FACT_DIM04_LVL02
In other words, this MV only seems to work if you're using
the EXACT query that was used to create the MV, which
makes it almost useless.
I notice that in DBA_MVIEWS, there's a field called
REWRITE_CAPABILITY, and this has a value of TEXTMATCH:
SQLlist
1 select mview_name, rewrite_enabled, rewrite_capability
2* from dba_mviews
SQL/
MVIEW_NAME R REWRITE_C
FACT_DIM04_LVL02 Y TEXTMATCH
TEST01 Y GENERAL
Here's what the manual says about this:
TEXTMATCH: The defining query of the materialized view
contained restrictions on the use of query rewrite.
Yes, I'm using CBO and have set QUERY REWRITE to true.
Also, should it matter, we're on 8.17, Sun Solaris 2.7
Any ideas out there? TIA.What is the value of the job_queue_processes initialization parameter?
Check dba|all|user_jobs to see if a refresh is actually scheduled and not marked broken.
If a job is present, what is the value of the next_date column?
Maybe you are looking for
-
Hi, In my repository, there may be a large amount of objects under one folder. Is there any paging component with which we can only retrieve limited amount of objects at one time, just like that in data base? Thanks, Ray
-
Hi all, I currently have 3 ISE servers running 1.2.1.198 - ISE1 - primary admin, secondary monitoring, PSN ISE2 - primary monitoring, secondary admin, PSN ISE3 - PSN only. A pair of 5508 controllers are located on the same campus as ISE1 and ISE2
-
Hide MS-DOS window when running java
I'd like to know i can hide the MS-DOS window when i am running my program. I try this in file.bat, but it doesn't work. file.bat: javaw myProgram exit any ideas? thank you.
-
Dear reader, My application is uploaded on the web. I want to open the "Open window dialog box" on the web but am unable to do so. also I dont want to get a static file but it should be selectable. Using java beans opens a static file and its not dyn
-
IPad crash and won't boot up and won't charge
first gen IPad today when I was reading went to black ... I thought it had timed out, but it wouldn't open back up. It wouldn't restart - I tried to even power off but nothing at all shows up on the screen. I don't think the battery was low but I ho