BEST WAY TO REFRESH A MATERIALIZED VIEW

Hi, I have a Materialized View that was created after two Base Tables, Table A is a Dynamic Table, this means that it have Insert's, update's and delete's, and a Table B that is a Fixed Table, this means that this table do not change over time (it's a Date's Table). The size of the Table related to the Materialized View is to big (120 millions rows) so the refresh has to be very efficient in order to not affect the Data Base performance.
I was thinking on a Fast Refresh mode but It would not work because the log created on the B table is not usefull, the thing is that I created the two materialized view log's (Tables A and B) and when I execute the dbms_mview.refresh(list =>'MV', method => 'F')+ sentence I got the error
cannot use rowid column from materialized view log on "Table B" ... remember that this table don't change over time ...
I need to mantain the Materialized view up to date, but do not know how ... Please Help !!!!!

The Materialized View name is test_sitedate2
The Table B name is GCO01.FV_DATES .... is a Fixed Table ... do not change over time ...
The Code of the MV is
CREATE MATERIALIZED VIEW TEST_SITEDATE2
REFRESH FORCE ON DEMAND
AS
SELECT site_id, date_stamp
FROM gco01.fv_site, gco01.fv_dates
where fv_dates.date_stamp >= fv_site.start_date
and fv_dates.date_stamp >= to_date('01/03/2010', 'dd/mm/yyyy')
and fv_dates.date_stamp < to_date('01/04/2010', 'dd/mm/yyyy');
Each table gco01.fv_site and gco01.fv_dates have it's materiallized view log created
The error is ....
SQL> execute dbms_mview.refresh(list =>'test_sitedate2', method => 'F');
begin dbms_mview.refresh(list =>'test_sitedate2', method => 'F'); end;
ORA-12032: cannot use rowid column from materialized view log on "GCO01"."FV_DATES"
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2254
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2460
ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2429
ORA-06512: at line 1
Thank's

Similar Messages

  • JPA -- Best way to refresh a List association?

    Hi,
    I need to refresh a OneToMany association.
    For example, I have two entities: Header & Detail.
    @Entity
    @Table(name="HEADERS")
    public class Header implements Serializable {
        @OneToMany(mappedBy="header")
        private List<Detail> details;
    @Entity
    @Table(name="DETAILS")
    public class Detail implements Serializable {
        @ManyToOne(fetch=FetchType.LAZY)
        @JoinColumn(name="HDR_ID", referencedColumnName="HDR_ID")
        private Header header;
    }So, I fetch the Header along with all its Details.
    At a later point of time, I know that some Detail rows in the database have been changed behind my back. I need to re-fetch the list of Details. What should I do?
    1. I could add a cascade parameter to the @OneToMany association. I could specify:
    @OneToMany(mappedBy="header", cascade={CascadeType.REFRESH})Then I could run:
    entityManager.refresh(header);The trouble is that, since all the Details are already in the cache, the cached entities will be returned, not the ones fetched from the database. So, I won't refresh a thing. A query will be sent to the database indeed, but I will get the cached (i.e. stale) entities. I don't know of a way to specify something like
    setHint(TopLinkQueryHints.REFRESH, HintValues.TRUE)dynamically for associations, so that the values in the cache would be replaced with the ones fetched from the database.
    2. I could try to turn off the caching for the while Entity class. The trouble is that for some reason this doesn't work (see my other question here JPA -- How can I turn off the caching for an entity? Besides, even if it worked, I don't want to turn off the caching in general. I simply want to refresh the list sometimes.
    Could anyone tell me what's the best way to refresh the association?
    Best regards,
    Bisser

    Hi Chris,
    First, let me thank you that you take the time to answer my questions. I really appreciate that. I wish to apologize for my late reply but I wasn't around the PC for a while.
    TopLink doesn't refresh an entity based on a view. I will try to explain in more detail. I hope you'll have patience with me because this might be a bit longer even than my previous post. I will oversimplify my actual business case.
    Let's assume we have two tables and a view:
    create table MASTERS
      (id number(18) not null primary key,
       master_name varchar2(50));
    create table DETAILS
      (id number(18) not null primary key,
       master_id number(18) not null,   -- FK to MASTER.ID
       price number(7,2));
    create view DETAILS_VW as
      select id, master_id, price
      from details;Of course, in real life the view is useful and actually peforms complex aggregate calculations on the details. But at the moment I wish to keep things as simple as possible.
    So, I create Entities for the tables and the view. Here are the entities for MASTERS and DETAILS_VW, only the essential stuff (w/o getters, setters, sequence info, etc.):
    @Entity
    @Table(name="MASTERS")
    public class Master {
         @Id
         @Column(name="ID", nullable=false)
         private Long id;
         @Column(name="MASTER_NAME")
         private String masterName;
         @OneToMany(mappedBy="master", fetch=FetchType.LAZY, cascade=CascadeType.REFRESH)
         private List<DetailVw> detailsVw;
    @Entity
    @Table(name="DETAILS_VW")
    public class DetailVw {
         @Id
         @Column(name="ID")
         private Long id;
         @ManyToOne(fetch=FetchType.LAZY)
         @JoinColumn(name="MASTER_ID", referencedColumnName="ID")
         private Master master;
         @Column(name="PRICE")
         private Double price;
    }So, now we have the tables and the entities. Let's assume one master row and two detail rows exist:
    MASTER:  ID=1, MASTER_NAME='Master #1'
    DETAIL:  ID=1, MASTER_ID=1, PRICE=3
    DETAIL:  ID=2, MASTER_ID=1, PRICE=8And now let's run the following code:
    // List the initial state
    Master master = em.find(Master.class, 1L);
    List<DetailVw> detailsVw = master.getDetailsVw();
    for (DetailVw dv : detailsVw) {
         System.out.println(dv);
    // Modify a detail
    EntityTransaction tx = em.getTransaction();
    tx.begin();
    Detail d = em.find(Detail.class, 2L);
    d.setPrice(1);
    tx.commit();
    // Refresh
    System.out.println("----------------------------------------");
    em.refresh(master);
    // List the state AFTER the update
    detailsVw = master.getDetailsVw();
    for (DetailVw dv : detailsVw) {
         System.out.println(dv);
    }And here are some excerpts from the console (only the essentials):
    DetailVw: id=1, price=3
    DetailVw: id=2, price=8
    UPDATE DETAILS SET PRICE = ? WHERE (ID = ?)
         bind => [1, 2]
    SELECT ID, MASTER_NAME FROM MASTERS WHERE (ID = ?)
         bind => [1]
    SELECT ID, PRICE, MASTER_ID FROM DETAILS_VW WHERE (MASTER_ID = ?)
         bind => [1]
    DetailVw: id=1, price=3
    DetailVw: id=2, price=8You see, the UPDATE statement changes the DETAILS row. The price was 8, but was changed to 1. I checked the database. It was indeed changed to 1.
    Furthermore, due to the refresh operation, a query was run on the view. But as you can see from the console output, the results of the query were completely ignored. The price was 8, and continued to be 8 even after the refresh. I assume it was because of the cache. If I run an explicit query on DETAILS_VW with the hint:
    q.setHint(TopLinkQueryHints.REFRESH, HintValues.TRUE);then I see the real updated values. But if I only refresh with em.refresh(master), then the DetailVw entities do not get refreshed, even though a query against the database is run. I have tested this both in JavaSE and in OC4J. The results are the same.
    An explicit refresh on a particular DetailVw entity works, though:
    DetailVw dvw = em.find(DetailVw.class, 2L);
    em.refresh(dvw);
    System.out.println(dvw);Then the console says:
    DetailVw: id=2, price=1So, the price is indeed 1, not 8.
    If you can explain that to me, I will be really thankful!
    Best regards,
    Bisser

  • Best way to refresh page after returning from task flow?

    Hello -
    (Using jdev 11g release 1)
    What is the best way to refresh data in a page after navigating to and returning from a task flow with an isolated data control scope where that data is changed and commited to the database?
    I have 2 bounded task flows: list-records-tf and edit-record-tf
    Both use page fragments
    list-records-tf has a list.jsff fragment and a task flow call to edit-record-tf
    The list.jsff page has a table of records that a user can click on and a button which, when pressed, will pass control to the edit-record-tf call. (There are also set property listeners on the button to set values in the request that are used as parameters to edit-record-tf.)
    The edit-record-tf always begins a new transaction and does not share data controls with the calling task flow. It consists of an application module call to set up the model according to the parameters passed in (edit record X or create new record Y or...etc.), a page fragment with a form to allow users to edit the record, and 2 different task flow returns for saving/cancelling the transaction.
    Back to the question - when I change a record in the edit page, the changes do not show up on the list page until I requery the data set. What is the best way to get the list page to refresh itself automatically upon return from the edit-record-tf?
    (If I ran the edit task flow in a popup dialog I could just use the return listener on the command component that launched the popup. But I don't want to run this in a dialog.)
    Thank you for reading my question.

    What if you have the bean which has refresh method as TF param? Call that method after you save the data. or use contextual event.

  • How can I manually refresh a Materialized View

    Hi,
    There's a materialized view created in 2006 as under:
    CREATE MATERIALIZED VIEW "schema"."mv_name"
    USING INDEX
    REFRESH FAST ON DEMAND
    WITH PRIMARY KEY USING DEFAULT LOCAL ROLLBACK SEGMENT
    DISABLE QUERY REWRITE AS SELECT * FROM "table_name@dblink;
    The problem is that the last refresh was done in Aug. I want to manually refresh this materialized view right now as there is a procedure based on this MV and its not showing the right data as the above materialized view has not been refreshed, so the data for this month is not showing.
    Please let me know how I can refresh that MV right now.
    Also do I need to change the refresh option. How can I change it so that the MV refreshes itself every second.
    Thanks

    Also do I need to change the refresh option. How can
    I change it so that the MV refreshes itself every
    second. Every second? Why do you want to do that?? Perhaps waht you really want is refresh the MV on commit.

  • Fast Refresh Nested Materialized View problem in ORACLE 9i 9.2.0.7

    Hello
    My problem is in creating fast refresh nested materialized view in oracle 9i
    In below is an example of my problem
    ( I need to say when I run this example in Oracle 11g all things is OK )
    create table ali.alitest1(id number primary key,n1 number,n2 number);
    create table ali.alitest2(id number primary key,n3 number);
    CREATE MATERIALIZED VIEW LOG ON ali.alitest1 WITH ROWID,PRIMARY KEY ,SEQUENCE
    (n1,n2)
    INCLUDING NEW VALUES;
    CREATE MATERIALIZED VIEW LOG ON ali.alitest2 WITH ROWID,PRIMARY KEY ,SEQUENCE
    (n3)
    INCLUDING NEW VALUES;
    CREATE MATERIALIZED VIEW ali.alitest1_mv
    REFRESH WITH PRIMARY KEY FAST
    AS
    select id,n1 from ali.alitest1;
    CREATE MATERIALIZED VIEW LOG ON ali.alitest1_mv WITH ROWID,PRIMARY KEY ,SEQUENCE
    (n1)
    INCLUDING NEW VALUES;
    CREATE MATERIALIZED VIEW ali.alitest2_mv
    REFRESH WITH PRIMARY KEY FAST
    AS
    select t1.id,t1.n1,t2.n3,t1.rowid "t1_rowid",t2.rowid "t2_rowid" from ali.alitest1_mv t1,ali.alitest2 t2 where t1.id=t2.id;
    SQL Error: ORA-12053: this is not a valid nested materialized view
    12053. 00000 - "this is not a valid nested materialized view"
    *Cause:    The list of objects in the FROM clause of the definition of this
    materialized view had some dependencies upon each other.
    *Action:   Refer to the documentation to see which types of nesting are valid.
    do you know what is problem ?
    thanks

    Take look for this link :
    http://rwijk.blogspot.com/2009/08/fast-refreshable-materialized-view.html

  • Access-SQL Server (Client Server Configuration) Best Way To Refresh SQL Server Records ?

    We are using Access 2013 as the front end and SQL Server 2014 as the back end to a client server configuration.
    Access controls are bound to the SQL fields with the same names. When using Access to create a new record in a Form, the data are not transferred to SQL if the form is exited to display a different Form or Access is closed. If the right or left arrow navigation
    buttons at the bottom of the form are first used to display either the previous or next record, then the data in the new record are correctly transferred to SQL.
    What is the best way to refresh the new SQL record prior to the closing of the new record in the bound Access form ? We have tried Requery of the entire form and with all of the individual controls without success. We are looking for a method of refreshing
    SQL that functions in a manner similar to that of what happens with the navigation buttons.
    Thank you very much for your assistance.
    Robert Robinson
    RERThird

    Hi Stefan,
    I had added the code to set me.dirty = False in response to the On Dirty event and didn't realize that it was working properly. I had tried other several approaches and must have become confused somewhere along the line.
    I retested the program. On Dirty is working and the problem is solved.
    Thank you very much for your assistance.
    Robert Robinson
    RERThird

  • Refresh of materialized views

    Hi there,
    i've got a question to the refreshment of materialized views: when updating or inserting / deleting data of some specific tables, my materialized view should be updated.
    First of all, i though to make that happen by using triggers on the specific table and the DBMS_MVIEW.REFRESH() mechanism. But as i have read pretty often, it isn't recommended doing that with triggers.
    But how can I get what I want :-)
    Thank a lot for your answers,
    Martin
    Edited by: 949697 on Mar 4, 2013 1:11 AM

    Thanks for your answers,
    the case with FAST REFRESH doesn't work. Our materialized are very complex and are using e.g subselect-statments, analytic functions,UNION, Order, Group by.... According to the documentation, we can't use the FAST REFRESH.
    Using the REFRESH ON COMMIT could be possible. Having a look at the documentation, there is one interesting sentence: A REFRESH ON COMMIT materialized view is refreshed automatically when a transaction that does DML to one of the materialized view's detail tables commits
    What are the materialized view's detail tables? Are that all tables in the FROM-Part of the query?
    Martin

  • What is the best way to replace the Inline Views for better performance ?

    Hi,
    I am using Oracle 9i ,
    What is the best way to replace the Inline Views for better performance. I see there are lot of performance lacking with Inline views in my queries.
    Please suggest.
    Raj

    WITH plus /*+ MATERIALIZE */ hint can do good to you.
    see below the test case.
    SQL> create table hx_my_tbl as select level id, 'karthick' name from dual connect by level <= 5
    2 /
    Table created.
    SQL> insert into hx_my_tbl select level id, 'vimal' name from dual connect by level <= 5
    2 /
    5 rows created.
    SQL> create index hx_my_tbl_idx on hx_my_tbl(id)
    2 /
    Index created.
    SQL> commit;
    Commit complete.
    SQL> exec dbms_stats.gather_table_stats(user,'hx_my_tbl',cascade=>true)
    PL/SQL procedure successfully completed.
    Now this a normal inline view
    SQL> select a.id, b.id, a.name, b.name
    2 from (select id, name from hx_my_tbl where id = 1) a,
    3 (select id, name from hx_my_tbl where id = 1) b
    4 where a.id = b.id
    5 and a.name <> b.name
    6 /
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=7 Card=2 Bytes=48)
    1 0 HASH JOIN (Cost=7 Card=2 Bytes=48)
    2 1 TABLE ACCESS (BY INDEX ROWID) OF 'HX_MY_TBL' (TABLE) (Cost=3 Card=2 Bytes=24)
    3 2 INDEX (RANGE SCAN) OF 'HX_MY_TBL_IDX' (INDEX) (Cost=1 Card=2)
    4 1 TABLE ACCESS (BY INDEX ROWID) OF 'HX_MY_TBL' (TABLE) (Cost=3 Card=2 Bytes=24)
    5 4 INDEX (RANGE SCAN) OF 'HX_MY_TBL_IDX' (INDEX) (Cost=1 Card=2)
    Now i use the with with the materialize hint
    SQL> with my_view as (select /*+ MATERIALIZE */ id, name from hx_my_tbl where id = 1)
    2 select a.id, b.id, a.name, b.name
    3 from my_view a,
    4 my_view b
    5 where a.id = b.id
    6 and a.name <> b.name
    7 /
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=8 Card=1 Bytes=46)
    1 0 TEMP TABLE TRANSFORMATION
    2 1 LOAD AS SELECT
    3 2 TABLE ACCESS (BY INDEX ROWID) OF 'HX_MY_TBL' (TABLE) (Cost=3 Card=2 Bytes=24)
    4 3 INDEX (RANGE SCAN) OF 'HX_MY_TBL_IDX' (INDEX) (Cost=1 Card=2)
    5 1 HASH JOIN (Cost=5 Card=1 Bytes=46)
    6 5 VIEW (Cost=2 Card=2 Bytes=46)
    7 6 TABLE ACCESS (FULL) OF 'SYS_TEMP_0FD9D6967_3C610F9' (TABLE (TEMP)) (Cost=2 Card=2 Bytes=24)
    8 5 VIEW (Cost=2 Card=2 Bytes=46)
    9 8 TABLE ACCESS (FULL) OF 'SYS_TEMP_0FD9D6967_3C610F9' (TABLE (TEMP)) (Cost=2 Card=2 Bytes=24)
    here you can see the table is accessed only once then only the result set generated by the WITH is accessed.
    Thanks,
    Karthick.

  • A bug when refreshing a materialized view?

    I am getting "ORA-00603: ORACLE server session terminated by fatal error" upon refresh of a materialized view. I've put together a test case to demonstrate the problem. Is it a bug?
    SQL*Plus: Release 10.1.0.3.0 - Production on Fri Jul 29 13:43:45 2005
    Copyright (c) 1982, 2004, Oracle.  All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.6.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.6.0 - Production
    [email protected]> create table t (
      2  id int primary key,
      3  t_name varchar2(10),
      4  t_date date
      5  );
    Table created.
    [email protected]> create materialized view log on t
      2    with rowid (t_name, id, t_date) including new values;
    Materialized view log created.
    [email protected]> create materialized view t_mv
      2   build immediate
      3   refresh fast
      4   on commit
      5  as
      6   select t_name, max(id) id, max(t_date) t_date, count(*)
      7     from t
      8    GROUP BY t_name;
    Materialized view created.
    [email protected]> create materialized view log on t_mv
      2    with rowid (id) including new values;
    Materialized view log created.
    [email protected]> create table v (
      2  id int primary key,
      3  t_id int references t(id) on delete cascade,
      4  v_name varchar2(10)
      5  );
    Table created.
    [email protected]> create materialized view log on v
      2    with rowid (v_name, t_id) including new values;
    Materialized view log created.
    [email protected]> create materialized view v_mv
      2   build immediate
      3   refresh fast
      4   on commit
      5  as
      6  select v.rowid rowid1, t_mv.rowid rowid2, v.v_name, v.t_id
      7  from v, t_mv
      8  where v.t_id = t_mv.id;
    Materialized view created.
    [email protected]> alter table v_mv
      2  add constraint v_mv_uk1 unique
      3  (
      4  v_name
      5  )
      6   enable
      7  ;
    Table altered.
    [email protected]> insert into t (id, t_name, t_date) values (1, 'A', sysdate);
    1 row created.
    [email protected]> insert into t (id, t_name, t_date) values (2, 'B', sysdate);
    1 row created.
    [email protected]> insert into t (id, t_name, t_date) values (3, 'A', sysdate);
    1 row created.
    [email protected]> insert into t (id, t_name, t_date) values (4, 'A', sysdate);
    1 row created.
    [email protected]> insert into t (id, t_name, t_date) values (5, 'B', sysdate);
    1 row created.
    [email protected]> insert into v (id, t_id, v_name) values (1, 1, 'V_A_1');
    1 row created.
    [email protected]> insert into v (id, t_id, v_name) values (2, 2, 'V_B_1');
    1 row created.
    [email protected]> insert into v (id, t_id, v_name) values (3, 3, 'V_A_2');
    1 row created.
    [email protected]> insert into v (id, t_id, v_name) values (4, 4, 'V_A_3');
    1 row created.
    [email protected]> insert into v (id, t_id, v_name) values (5, 5, 'V_B_2');
    1 row created.
    [email protected]> commit;
    Commit complete.
    [email protected]> insert into t (id, t_name, t_date) values (6, 'A', sysdate);
    1 row created.
    [email protected]> insert into v (id, t_id, v_name) values (6, 6, 'V_B_2');
    1 row created.
    [email protected]> commit;
    commit
    ERROR at line 1:
    ORA-12008: error in materialized view refresh path
    ORA-00001: unique constraint (FESA.V_MV_UK1) violated
    [email protected]> -- ORA-12008 is fine here: that's what was expected
    [email protected]> delete from t where id = 5;
    1 row deleted.
    [email protected]> commit;
    ERROR:
    ORA-03114: not connected to ORACLE
    commit
    ERROR at line 1:
    ORA-00603: ORACLE server session terminated by fatal errorWhy ORA-00603?
    Best regards,
    Maciej

    It may be a bug, or it may be a result of the dependencies between the materialized views. I don't have a 9.2.0.6 instance that I'm willing to trash to test this, but this is what I get on 9.2.0.1.
    If it is a bug they at least changed the behaviour of the bug in 9.2.0.6.
    I ran your script up to the first commit then did:
    SQL> SELECT * FROM t;
            ID T_NAME     T_DATE
             1 A          29-JUL-05
             2 B          29-JUL-05
             3 A          29-JUL-05
             4 A          29-JUL-05
             5 B          29-JUL-05
    SQL> SELECT * FROM t_mv;
    T_NAME             ID T_DATE      COUNT(*)
    A                   4 29-JUL-05          3
    B                   5 29-JUL-05          2
    SQL> SELECT * FROM v;
            ID       T_ID V_NAME
             1          1 V_A_1
             2          2 V_B_1
             3          3 V_A_2
             4          4 V_A_3
             5          5 V_B_2
    SQL> SELECT * FROM v_mv;
    no rows selectedHUH?? But:
    SQL> SELECT v.rowid rowid1, t_mv.rowid rowid2, v.v_name, v.t_id
      2  FROM v, t_mv
      3  WHERE v.t_id = t_mv.id;
    ROWID1             ROWID2             V_NAME           T_ID
    AAAH4QAAIAAAAl1AAD AAAH4MAAIAAAAlFAAA V_A_3               4
    AAAH4QAAIAAAAl1AAE AAAH4MAAIAAAAlFAAB V_B_2               5So, I tried:
    SQL> EXEC DBMS_MVIEW.REFRESH('V_MV');
    PL/SQL procedure successfully completed.
    SQL> SELECT * FROM v_mv;
    no rows selectedNow, this is confusing, so:
    SQL> EXEC DBMS_MVIEW.REFRESH('V_MV', 'COMPLETE');
    PL/SQL procedure successfully completed.
    SQL> SELECT * FROM v_mv;
    ROWID1             ROWID2             V_NAME           T_ID
    AAAH4dAAIAAAAl1AAD AAAH4ZAAIAAAAlFAAA V_A_3               4
    AAAH4dAAIAAAAl1AAE AAAH4ZAAIAAAAlFAAB V_B_2               5So at least I've got something in the MV. Now, to continue your test:
    SQL> insert into t (id, t_name, t_date) values (6, 'A', sysdate);
    1 row created.
    SQL> insert into v (id, t_id, v_name) values (6, 6, 'V_B_2');
    1 row created.
    SQL> COMMIT;
    Commit complete.I also expected the error but no joy, and look at this:
    SQL> SELECT * FROM v_mv;
    ROWID1             ROWID2             V_NAME           T_ID
    AAAH4dAAIAAAAl1AAE AAAH4ZAAIAAAAlFAAB V_B_2               5Forcing the refresh on v_mv gets:
    SQL> EXEC DBMS_MVIEW.REFRESH('V_MV', 'COMPLETE');
    BEGIN DBMS_MVIEW.REFRESH('V_MV', 'COMPLETE'); END;
    ERROR at line 1:
    ORA-12008: error in materialized view refresh path
    ORA-00001: unique constraint (OPS$ORACLE.V_MV_UK1) violatedVery strange! It gets better:
    SQL> DELETE FROM t WHERE id = 5;
    1 row deleted.
    SQL> commit;
    Commit complete.
    SQL> EXEC DBMS_MVIEW.REFRESH('V_MV', 'COMPLETE');
    PL/SQL procedure successfully completed.
    SQL> select * from v_mv;
    ROWID1             ROWID2             V_NAME           T_ID
    AAAH4dAAIAAAAl1AAF AAAH4ZAAIAAAAlFAAA V_B_2               6 But:
    SQL> SELECT * FROM t_mv;
    T_NAME             ID T_DATE      COUNT(*)
    A                   6 29-JUL-05          4
    B                   5 29-JUL-05          2
    SQL> SELECT * FROM t;
            ID T_NAME     T_DATE
             1 A          29-JUL-05
             2 B          29-JUL-05
             3 A          29-JUL-05
             4 A          29-JUL-05
             6 A          29-JUL-05Obvioulsy, something is not fast refreshing. So lets force it:
    SQL> EXEC DBMS_MVIEW.Refresh('T_MV', 'COMPLETE');
    PL/SQL procedure successfully completed.
    SQL> SELECT * FROM t_mv;
    T_NAME             ID T_DATE      COUNT(*)
    A                   6 29-JUL-05          4
    B                   2 29-JUL-05          1
    SQL> SELECT * FROM v_mv;
    ROWID1             ROWID2             V_NAME           T_ID
    AAAH4dAAIAAAAl1AAB AAAH4qAAIAAAAlEAAB V_B_1               2
    AAAH4dAAIAAAAl1AAF AAAH4qAAIAAAAlEAAA V_B_2               6Which looks right to me.
    Then, I blew everything away and did it allagain up to an including the inserts into t, then I inserted into v and commited. Now, both MV's were correct, so I did:
    SQL> insert into t (id, t_name, t_date) values (6, 'A', sysdate);
    1 row created.
    SQL> insert into v (id, t_id, v_name) values (6, 6, 'V_B_2');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> SELECT * FROM t_mv;
    T_NAME             ID T_DATE      COUNT(*)
    A                   6 29-JUL-05          4
    B                   5 29-JUL-05          2Still strange, so blow it all away again insert into t commit, insert into v commit, then:
    SQL> insert into t (id, t_name, t_date) values (6, 'A', sysdate);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> insert into v (id, t_id, v_name) values (6, 6, 'V_B_2');
    1 row created.
    SQL> commit;
    commit
    ERROR at line 1:
    ORA-12008: error in materialized view refresh path
    ORA-00001: unique constraint (OPS$ORACLE.V_MV_UK1) violatedAt least now it sees the error at commit time for v so lets try the delete:
    SQL> delete from t where id = 5;
    1 row deleted.
    SQL> commit;
    Commit complete.
    SQL> SELECT * FROM t_mv;
    T_NAME             ID T_DATE      COUNT(*)
    A                   6 29-JUL-05          4
    B                   5 29-JUL-05          2
    SQL> SELECT * FROM t;
            ID T_NAME     T_DATE
             1 A          29-JUL-05
             2 B          29-JUL-05
             3 A          29-JUL-05
             4 A          29-JUL-05
             6 A          29-JUL-05Still not actually refreshing somehow.
    I may play with this some more, it seems truly strange to me.
    John

  • ORA-01555 when performing refresh of materialized views via DBMS_JOB

    All,
    With this project needing to be finished soon and an issue occuring on the local database, I am hopefuly one of you will have the answer or resolution so that I may complete this project soon....
    Here is the setup..
    10g database (remote)
    9i database (local
    DB Link from local to remote database
    103 materialized views in local database that are refreshed by pulling data from dblink to remote database.
    A PL/SQL procedure has been created which sets the v_failures variable = 0 and then performs a check to see if the current job has a failure and if so, inserts that value into the v_failures variable. When that reaches "1", then the procedure does nothing and closes out. If the failures are equal to "0" then it performs a DBMS_MVIEW.REFRESH procedure for each materialized view.
    This worked the first time but its continually failing now with the ORA-01555 error (snapshot too old). From what I can tell, the dbms_job duration is 4 seconds and the Last_Exec is 2m 7s after it starts (8:30 PM). With that said, our DBAs working o nthe project have increased the Undo_Retention settings and assure us that shouldn't be the problem. Odd thing is, this never happened in the dev environment when we were developing/testing - only in the production environment once it got migrated.
    I am looking for possible causes and possible solutions to the ORA-01555 error. A sample of the code in my procedure is below:
    CREATE OR REPLACE PROCEDURE Ar_Mviews IS
    V_FAILURES NUMBER := 0;
    BEGIN
    BEGIN
              SELECT FAILURES INTO V_FAILURES FROM USER_JOBS WHERE SCHEMA_USER = 'CATEBS' AND WHAT LIKE '%DISCO_MVIEWS%';
              IF V_FAILURES = 1 THEN NULL;
              ELSE
    DBMS_MVIEW.REFRESH ('AR_BATCH_RECEIPTS_V', 'C');
              DBMS_OUTPUT.PUT_LINE(V_FAILURES); END IF;
    END;
    BEGIN
         SELECT FAILURES INTO V_FAILURES FROM USER_JOBS WHERE SCHEMA_USER = 'CATEBS' AND WHAT LIKE '%DISCO_MVIEWS%';
              IF V_FAILURES = 1 THEN NULL;
              ELSE
    DBMS_MVIEW.REFRESH ('AR_BATCHES_ALL_V', 'C');
              DBMS_OUTPUT.PUT_LINE(V_FAILURES); END IF;
    END;
    END Ar_Mviews;
    ---------------------------------------------------------------------------------------------------------------

    We are doing complete refreshes and doing it that way for consistency in the data presented. Because some materialized views are dependent upon data in other materialized views, we have them ordered in a procedure so that when one finishes, the next starts and they are also in a specific order as to ensure accurate data.
    The condition for v_failures is done so that the job doesn't get, lets say, 90% finished and hit an error and start over again. We do the IF statement which results in NULL (do nothing) so that the job doesn't repeat itself over and over again. If one MV fails, we have to consider the job a failure and do nothing else because the one MV that failed may have been a dependency of another MV down the line. (i.e. MV7 calls MV3 and MV3 fails, so the whole job fails because MV7 can't be accurate without the most current data from MV3).
    As well, this is being performed in off-business hours after backup to tape, etc. and prior to start of business so that no one is using the system when we run this job. That won't always be the case when we move to high availability with this system for varying time-zone end-users.
    I hope I have answered your question and look forward to continued feedback.
    Thanks!

  • How can I fast refresh the  materialized view !!

    I created a MV base on some tables in order to improve the querey speed.
    but the mv I have created falied to refresh fast.
    because there are two same table in the from clause:
    jcdm jc1,jcdm jc2
    create materialized view temp_mv
    nologging
    pctfree 0
    storage (initial 2048k next 2048k pctincrease 0)
    parallel
    build immediate
    refresh force
    on demand
    as
    select
    TAB_GSHX.rowid hx_rid,
    TAB_GSHD.rowid hd_rid ,
    JC1.rowid jc1_rid ,
    JC2.rowid jc2_rid ,
    YSHD_ID     HXID,          
    JC1.JCDM     QFD,     
    JC2.JCDM     JLD     
    FROM
    TAB_GSHX,
    TAB_GSHD,
    jCDM JC1,
    JCDM JC2
    WHERE
    YSHD_ID=YSHX_ID
    AND YSHD_QFD=JC1.JBJC_ID
    AND YSHD_JLD=JC2.JBJC_ID
    AND TO_CHAR(YSHX_time,'YYYYMMDD')='20030101'
    the column msgtxt of the table MV_CAPABILITIES_TABLE is :
    "the multiple instances of the same table or view" and " one or more joins present in mv".
    How can I succeed in fast refresh the above temp_mv!!!
    thanks.

    lianjun,
    When you are using Oracle9i there is a procedure which can help you setup the materialized view. If some option isn't working it gives you hint why it doesn't work.
    The procedure is dbms_mview.explain_mview.
    Take a look at the documentation how to use it. (In the Oracle9i DWH guide the package is explained.)
    Hope this helps
    With kind regards,
    Bas Roelands

  • Refresh a materialized view in parallel

    Hi,
    To improve the refresh performance for a materialized view, I set up it to be refreshed in parallel. The view can be refreshed successfully, however, I did not see the view is refreshed in parallel from session browser, can someone let me know if I miss any steps?
    1) In DB A (running 8 CPUs), set up the base table to be parallelized, the base table is called table1
    ALTER TABLE A.table1 PARALLEL ( DEGREE Default INSTANCES Default );
    2) In Database A, set up the materialized view log
    CREATE MATERIALIZED VIEW LOG
    ON table1 WITH primary key
    INCLUDING NEW VALUES;
    3) In Database B (in the same server with Database A), there is an existing table called table1, prebuilt with millions of records in the table. Due to the size of table1, I have to use prebuilt option
    Drop MATERIALIZED VIEW table1;
    CREATE MATERIALIZED VIEW table1 ON PREBUILT TABLE
    REFRESH FAST with primary key
    AS
    select /*+ PARALLEL(table1, 8) */ *
    from table1@A;
    4) in Database B, I executed this stored procedure -
    EXECUTE DBMS_MVIEW.REFRESH(LIST=>'table1',PARALLELISM=>8, METHOD=>'F');
    Thanks in advance!
    Liz

    I checked the execution plan when I executed the refresh stored procedure again, Does the plan indicates the parallel execution is working or not?
    SELECT STATEMENT REMOTE ALL_ROWSCost: 32,174 Bytes: 775,392 Cardinality: 1,182                                                   
    13 PX COORDINATOR                                              
    12 PX SEND QC (RANDOM) PARALLEL_TO_SERIAL SYS.:TQ10001 :Q1001                                        
         11 NESTED LOOPS PARALLEL_COMBINED_WITH_PARENT :Q1001                                   
         9 NESTED LOOPS PARALLEL_COMBINED_WITH_PARENT :Q1001Cost: 32,174 Bytes: 775,392 Cardinality: 1,182                               
              6 BUFFER SORT PARALLEL_COMBINED_WITH_CHILD :Q1001                         
                   5 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT :Q1001                    
                        4 PX SEND ROUND-ROBIN PARALLEL_FROM_SERIAL SYS.:TQ10000 A               
                             3 VIEW APP_USR. Cost: 12,986 Bytes: 6,070,196 Cardinality: 275,918           
                                  2 HASH UNIQUE Cost: 12,986 Bytes: 9,105,294 Cardinality: 275,918      
                                       1 TABLE ACCESS FULL TABLE A.MLOG$_TABLE1 A Cost: 10,518 Bytes: 9,105,294 Cardinality: 275,918
         8 PARTITION RANGE ITERATOR PARALLEL_COMBINED_WITH_PARENT :Q1001Cost: 0 Cardinality: 1                          
         7 INDEX RANGE SCAN INDEX (UNIQUE) PARALLEL_COMBINED_WITH_PARENT A.PK_TABLE1 :Q1001Cost: 0 Cardinality: 1                     
    10 TABLE ACCESS BY LOCAL INDEX ROWID TABLE PARALLEL_COMBINED_WITH_PARENT A.TABLE1 :Q1001Cost: 0 Bytes: 634 Cardinality: 1

  • Time taken to Refresh a Materialized View

    Hi,
    Can we somehow estimate the approximate time it takes to Fast Refresh a particular Materialized View?
    In my case it is REFRESH FAST ON DEMAND and it contains close to 65 Million Records. On a daily basis 40K records are updated/inserted in the Materialized View. Also MV Logs are created on the Master Tables.
    The query of the MV is a join between a Dimension and Fact Table of a Datawarehouse. Each Master Table contains close to 70 million records.
    Could you please let me know?
    Thanks, Ketan

    Hi Jignesh,
    Thanks for the reply.
    Actually what I would like to know is can we somehow estimate/forecast the Refresh Time before actually refreshing the MV.
    Currently, in my case I am testing in a Non-Production Environment where the two MV logs contain 65K and just 70 records respectively. The Records finally Inserted/Updated from the MV is just 50. The time to refresh is about 7 minutes.
    However, in the Production Environment, I am expecting close to 25-30K Inserts/Updates from the MV. So, I would like to know if we could PREDICT the approximate time required to Refresh a far larger dataset?
    For example, to refresh close to 100K records in the View Logs will it take a far greater time or just some additional time? Is the Refresh rate directly dependent on the Number of Records to be refreshed or it takes a standard time to Refresh irrespective of the No. of Records?
    Would appreciate your inputs on this.
    Thanks, Ketan

  • JOB to refresh the materialized views

    Hi,
    I have created the following job to call a procedure which refreshes all the materialized views but it that job has been running from ages although in the past it seems to work.
    Can u advise me what im missing
    REM : procedure to refresh all the job
    PROCEDURE PROC_REFRESH_MVS AS
    BEGIN
    This procedure will refresh all of the MVs
    DBMS_MVIEW.REFRESH('MV_A','c');
    DBMS_MVIEW.REFRESH('MV_B','c');
    DBMS_MVIEW.REFRESH('MV_Z','c');
    END PROC_REFRESH_MVS;
    REM Job to call the procedure
    BEGIN
    sys.dbms_scheduler.create_job(
    job_name => '"SCHEMAOWNER"."REFRESH_MVS"',
    job_type => 'STORED_PROCEDURE',
    job_action => 'SCHEMAOWNER.PROC_REFRESH_MVS',
    start_date => systimestamp at time zone 'Europe/Lisbon',
    job_class => 'DEFAULT_JOB_CLASS',
    comments => 'Refresh all the materialized views ',
    auto_drop => FALSE,
    enabled => FALSE);
    sys.dbms_scheduler.set_attribute( name => '"SCHEMAOWNER"."REFRESH_MVS"', attribute => 'logging_level', value => DBMS_SCHEDULER.LOGGING_FULL);
    sys.dbms_scheduler.enable( '"SCHEMAOWNER"."REFRESH_MVS"' );
    END;

    Hi
    To understand what's going on you should analyze the trace file that is generated when such an error occurs. Metalink note 131885.1 may be helpful.
    HTH
    Chris

  • Fast refresh of materialized view

    Hi All,
    This is my first posting on this forum, so I hope I don't step on anyone's toes as I wade into a problem that I am experiencing.
    I have a number of either join-only or single table aggregate materialized views that I have experienced problems with. All the views are setup for FAST REFRESH ON DEMAND but I'm hitting an error if I execute a COMPLETE refresh of the view when I've done an ALTER SESSION ENABLE PARALLEL DML. The error I get is:
    ERROR at line 1:
    ORA-30439: refresh of 'DTKTGT.CTNS_PER_HR_VOL_AGG_MV' failed because of ORA-32320: REFRESH FAST of "DTKTGT"."CTNS_PER_HR_VOL_AGG_MV" unsupported after cointainer table PMOPs
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 814
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 872
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 852
    ORA-06512: at "DTKTGT.MV_REFRESH", line 21
    ORA-06512: at line 2
    Any help anyone could provide would be greatly appreciated as every now and then, a COMPLETE refresh is unavoidable and using the ENABLE PARALLEL DML makes the refresh run a lot faster than without the ALTER SESSION.
    Gary

    This forum only is for questions relating to the use of OLAP Option. I would post your question on the database forum.
    Keith Laker
    Oracle Data Warehouse Product Management
    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

Maybe you are looking for

  • Using a DataRelation with a 2nd DataRelation

    Standard example.  Create a DataSet with 2 related tables, define a DataRealtion, and bind them to 2 dataGridViews.  As you walk the first grid view, the 2nd one shows the related rows.    DataRelation customerDataRelation = new DataRelation("UsefulR

  • How do I initialize a hard drive?

    How do I not only erase, but also initialize a MacOSX hard drive so that it not only erases the data, but also checks the blocks, and zero's out any bad blocks? My mouse froze yesterday, so I forced a restart, and now it only comes up in command line

  • Acrobat x pro doesn't recognize epson scanner

    Acrobat x pro doesn't recognize my epson perfection 1670 scanner. Other applications recognize this scanner. What can I do? All software and drivers are updated. Acrobat x pro ver10.1.4 Mac os x 10.8.1, mountian lion

  • Is it possible to create own soap envolpe and body ?

    Hi, I developed a web service and deployed it on Web Logic server and Glassfish server. But its soap envelope and soap body is different. Glassfish Request : <?xml version="1.0" encoding="UTF-8"?> <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/

  • How do I contact an Apple Employee other than Call?

    I forgot my Security Questions and the article on the site was misleading and I need to talk to someone about it.