Materialzed view rewrite

Hi
http://download.oracle.com/docs/cd/B28359_01/server.111/b28313/qradv.htm#CHDFIAGB
In the following section
Materialized View Delta Joins
A materialized view delta join is a join that appears in the materialized view but not the query. All delta joins in a materialized view are required to be lossless with respect to the result of common joins. A lossless join guarantees that the result of common joins is not restricted. A lossless join is one where, if two tables called A and B are joined together, rows in table A will always match with rows in table B and no data will be lost, hence the term lossless join. For example, every row with the foreign key matches a row with a primary key provided no nulls are allowed in the foreign key. Therefore, to guarantee a lossless join, it is necessary to have FOREIGN KEY, PRIMARY KEY, and NOT NULL constraints on appropriate join keys. Alternatively, if the join between tables A and B is an outer join (A being the outer table), it is lossless as it preserves all rows of table A.
why we need lossless joins?
why we need non duplicating joins?
does we need both to perform query rewrite or anyone of them
thanks
Nick

Assume you have a query that ends up looking like:
select * from A where ...and there is a materialized view looking like:
select A.*, B.* from A, B where ...If the join from A to B causes rows from A to appear multiple times (imagine A is "orders" and B is "order_lines" then the materialized will give you the wrong result. This answers the bit about duplicates.
If the join from A to B causes rows from A to disappear (imagine A is the order_lines and B is the orders this time, but there is a predicate on B in the materialized view that restricts the views to 'completed' orders) then you get the wrong result. This answers the bit about lossless joins.
You might also want to read the following blog item from Oracle's optimizer group about "join elimination" as the sample principle applies.
http://optimizermagic.blogspot.com/2008/06/why-are-some-of-tables-in-my-query.html
Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
http://www.jlcomp.demon.co.uk
"The greatest enemy of knowledge is not ignorance,
it is the illusion of knowledge." (Stephen Hawking)

Similar Messages

  • Materialzed Views

    What is the use of materialzed views ?

    select count(sequence#) * XXX
    from v$archived_log where trunc(first_time) = trunc(sysdate)
    XXX needs to be replaced by the size of your redo logs (select bytes from v$log).
    This will be approximate, but pretty close. Change "sysdate" in the where clause by the date you want to use.

  • Error in creation of materialzed view.

    Hello All,
    I am trying to create a materialized view on a pre-built table. But the MV does not get created and gives an error ORA-12014. Following are the
    codes for MV logs and MV I am using:
    CREATE materialized VIEW log ON table_1
    WITH rowid,
    sequence (columns .. );
    CREATE materialized VIEW log ON table_2
    WITH rowid,
    sequence (columns .. );
    CREATE materialized VIEW mv_name (columns .. ) ON prebuilt TABLE
    WITH reduced PRECISION USING no INDEX refresh fast ON demand USING DEFAULT local ROLLBACK segment USING enforced CONSTRAINTS disable query rewrite AS
    SELECT columns ..
    FROM table_1
    UNION ALL
    SELECT columns ..
    FROM table_2
    Please let me know all the possible ways to solve this error.
    Thanks and regards

    user13160054 wrote:
    Hello All,
    I am trying to create a materialized view on a pre-built table. But the MV does not get created and gives an error ORA-12014. Following are the
    codes for MV logs and MV I am using:
    CREATE materialized VIEW log ON table_1
    WITH rowid,
    sequence (columns .. );
    CREATE materialized VIEW log ON table_2
    WITH rowid,
    sequence (columns .. );
    CREATE materialized VIEW mv_name (columns .. ) ON prebuilt TABLE
    WITH reduced PRECISION USING no INDEX refresh fast ON demand USING DEFAULT local ROLLBACK segment USING enforced CONSTRAINTS disable query rewrite AS
    SELECT columns ..
    FROM table_1
    UNION ALL
    SELECT columns ..
    FROM table_2
    Please let me know all the possible ways to solve this error.
    Thanks and regards
    12014, 00000, "table '%s' does not contain a primary key constraint"
    // *Cause:  The CREATE MATERIALIZED VIEW LOG command was issued with the
    //          WITH PRIMARY KEY option and the master table did not contain
    //          a primary key constraint or the constraint was disabled.
    // *Action: Reissue the command using only the WITH ROWID option, create a
    //          primary key constraint on the master table, or enable an existing
    //          primary key constraint.

  • How to create materialized view based on a view?

    Hi,
    I hope this is not very far fetched idea.
    I have a very complex view and I would like to replicate it 'in place' that is I would like to make a materialized view that is based on this view complex view. I would like to use this materialized view (i.e table) to query data instead of using the original view, since it takes Oracle some 10-15 seconds to execute my query on the original view and I am not allowed to create indexes on most of the tables that are included in the original view.
    Can this be done?
    Best regards,
    Tamas Szecsy

    The best way to do this is to create a materialzed view based on the underlying code of the original view. If you don't have this handy, issue the following in sqlplus:
    select text
    from user_views
    where view_name = 'NAME_OF_VIEW'
    You can then cut and paste the sql statement into your create materialized view statement.
    Please note, you will probable have to set the long parameter to a higher value to reveal the complete statement for example:
    SQL> set long 2048

  • How to create materialized view based on a synonym

    Hi all,
    I am trying to create simple materialized view based on a synonym and that synonym is pointing a view in other database (using dblink). I am getting table or view not found error . I am able to select synonym if i use select but not in materialized view. Please help me.
    Thanks,

    The best way to do this is to create a materialzed view based on the underlying code of the original view. If you don't have this handy, issue the following in sqlplus:
    select text
    from user_views
    where view_name = 'NAME_OF_VIEW'
    You can then cut and paste the sql statement into your create materialized view statement.
    Please note, you will probable have to set the long parameter to a higher value to reveal the complete statement for example:
    SQL> set long 2048

  • Materialized views Error

    Hi,
    I have installed oracle 11g expression edition. I am trying to create materialized view like this
    create materialized view test_mv
    build immediate
    refresh fast on commit
    enable query rewrite
    as
    select product.category, sum(sales.netsales) from product, sales where product.productid=sales.productid group by
    product.category order by product.category;
    I am getting the following error:
    SQL Error: ORA-00439: feature not enabled: Materialized view rewrite
    I have updated the init file in the following path:
    # Materialized views for query rewrite
    QUERY_REWRITE_ENABLED=TRUE
    Path: C:\oraclexe\app\oracle\product\11.2.0\server\config\scripts (where exactly it is installed.). Pls let me know what is the problem? I am unable to trace it.
    regards
    chandra kanth.

    The Oracle Error Message brings it to the point nicely :-)
    $ oerr ORA 00439
    00439, 00000, "feature not enabled: %s"
    // *Cause:  The specified feature is not enabled.
    // *Action: Do not attempt to use this feature.The feature is only available with Enterprise Edition - not with your free-of-charge XE.
    See here for the Feature Availability by Edition
    http://docs.oracle.com/cd/E11882_01/license.112/e10594/editions.htm#CJACGHEB
    Kind regards
    Uwe Hesse
    "Don't believe it, test it!"
    http://uhesse.com

  • Refresh materialized view on fast refresh

    Hi,
    I want to create a fast refresh on a materialized view but i kept getting ORA-12015: cannot create a fast refresh materialized view from a complex query. When I did a complete refresh on the materialzed view, it completed. I have create a materialized view log for the table. In my materialized view script, I have included a user defined function. Does db version 10g have the capability to do a fast refresh?
    Thanks

    What is the query you are using for the MV?
    The error message says it all... "cannot create a fast refresh materialized view from a complex query"
    If your query is complex then you will have to perform complete refreshes.
    One way around can be to fast refresh all tables in the query then create a view on them based on the 'complex' query. Admittedly this is only a workaround in certain scenarios.
    Check out the documentation...
    http://68.142.116.70/docs/cd/B19306_01/server.102/b14226/repmview.htm#sthref422

  • Streams on materialized view table vs. local table

    We are in a situation where we temporarily need to implement Streams on several materialized view tables. During development and testing I've noted that a local table with streams implemented on it yields 50% faster performance on apply than the materialized view tables. Can anyone tell me (1) why this is, it doesn't make sense since data is being retrieved from a buffered queue not the tables, and (2) a work around to this to improve performance on the mv tables. Any hellp would be appreciated.

    Can't give you an answer why. I would suggest that you try (1) creating the materialzed views on prebuilt tables and (2) add parallelism to the apply process(es)

  • Refeshing the Materialized view

    Hi,
    I could not refresh the materialized view manually.
    here is the command i am using.
    execute DBMS_REFRESH.MAKE(
         name => 'my_customer',
         list => 'VIEW_MY_CUST_ALL',
         next_date => sysdate,
         interval => 'sysdate+1/48');
    execute DBMS_REFRESH.REFRESH(
         name => 'my_customer');
    ========i am getting following error ===========
    SQL> ed
    Wrote file afiedt.buf
    1 execute DBMS_REFRESH.MAKE(
    2 name => 'my_customer',
    3 list => 'VIEW_MY_CUST_ALL',
    4 next_date => sysdate,
    5* interval => 'sysdate+1/48')
    SQL> /
    execute DBMS_REFRESH.MAKE(
    ERROR at line 1:
    ORA-00900: invalid SQL statement
    ========================
    --Thanks
    Raman

    Does the materialized view exist and is it valid?
    Fast refreshable materialzed views don't like SYSDATE, either :(

  • Import views from dumpfile

    i have created a dumpfile with expdp from a schema that had tables, views and procedures. I want to restore only the schema's views , not the tables with impdp.- These are regular views, not materialzed views. What is the impdp syntax for importing views?
    Thanks
    Oracle 10G
    Hp-ux 11.23

    run your regular impdp command but add:
    include=view
    This will include only views.
    Dean

  • ORA-00439 error when deploying a simple dimension

    Hello,
    I am using Oracle Warehouse Builder 11g SE to try to implement a simple data warehouse.
    I have created the dimensions and cube using ROLAP, defined simple mappings and added process flow and was now trying to deploy the objects.
    When i try to deploy a dimension using the Control Centre it fails with the error message:
    LOCATION_DIM Create Error ORA-00439: feature not enabled: Materialized view rewrite
    I have been looking at the ddl script created for the dimension and can see nothing which indicates that materialized view or query rewrite should be used.
    The sql script is shown here:
    WHENEVER SQLERROR EXIT FAILURE;
    CREATE OR REPLACE VIEW "RDW".LOCATION_DIM_v AS
    SELECT *
    FROM RDW.LOCATION_DIM
    WHERE DIMENSION_KEY >= 0
    CREATE DIMENSION LOCATION_DIM
    LEVEL "CITY" IS "RDW"."LOCATION_DIM"."CITY_ID"
    LEVEL "STORE" IS "RDW"."LOCATION_DIM"."STORE_ID"
    HIERARCHY "STANDARD" (
    "STORE" CHILD OF
    "CITY"
    ATTRIBUTE "CITY" DETERMINES ( "RDW"."LOCATION_DIM"."CITY_CITYID", "RDW"."LOCATION_DIM"."CITY_CITYNAME" )
    ATTRIBUTE "STORE" DETERMINES ( "RDW"."LOCATION_DIM"."STOREID", "RDW"."LOCATION_DIM"."STORE_CITYID", "RDW"."LOCATION_DIM"."STORENAME", "RDW"."LOCATION_DIM"."STORE_CITYNAME" )
    am I missing something here?
    Edited by: owb_user on Feb 9, 2010 9:03 AM

    Hi,
    it seems like DB init parameter "query_rewrite_enabled" is set to its default: FALSE. Check out this article on the same on how to avoid this error:
    Note.1019100.102     ORA-00439 When Trying To Create Materialized View With Enable Query Rewrite
    Regards

  • Recommendations;;; Please help me

    We would like to build necessary monitors around fast refresh that we are doing for one product.
    To start, we have a counter table in database 1 which gets refreshed to database 2 via a dblink from database 1 periodically, every 15 minutes.
    we have a materialzed view log table created to capture the incremental in database 1, which helps in fast refresh.
    We would like to be sure we get alerted and anticipate of any overlap or taking longer time to refresh. The objetcive is to be proactive.
    Could you please share the recommendations to best monitor.
    database 1 is in 11gR2 , Enterprise Edition (11.2.0.1)
    database 2 is in 11gR2, Standard Edition One (11.2.0.1)
    Thanks,

    DUPLICATE
    do NOT multi-post
    need recommendations

  • Improving Performance of Group By clause

    I'm a developer who needs to create an aggreagate, or roll-up, of a large table (tens of millions of rows) using a group by clause. One of the several items I am grouping by is a numeric column called YEAR. My DBA recommended I create an index on YEAR to improve the performance of the group by clause. I read that indexes only are used when referenced in the where clause, which I do not need. Will my DBA's reccomendation help? Can you recommend a technique? Thank you.

    When you select millions of rows, grouped or not, the database has to fetch
    each of them, so an index on the group column isn't useful.
    If you have a performance problem that cannot be solved through an index on
    columns used in your where-clause, perhaps a materialzed view with the
    dimension(s) of your group clause will help.

  • Business Intelligence and Analysis capabilities on XML content

    On page 99 of Oracle XML DB Basic Demonstration pdf doc it si said: "Even though Business Intelligence, such as rollup and cube, are not XML aware they are able to process XML content exposed through a relational view"
    is this true ? if so, how can i create a cube and/or
    dimension from XML content exposed through a relational view ?
    Unfortunately, Oracle 9i does not allow me to build materialzed views from XML content (Oracle objects)
    Thanks in advance,

    The intention of the documentation maybe that anything you can query using SQL, you can expose as XML. For instance, you could create an analytic workspace, expose it through views, query the views through SQL, and return the results as XML.

  • Business Intelligent and Analysis capabilities on XML content

    On page 99 of Oracle XML DB Basic Demonstration pdf doc it si said: "Even though Business Intelligence, such as rollup and cube, are not XML aware they are able to process XML content exposed through a relational view"
    is this true ? if so, how can i create a cube and/or
    dimension from XML content exposed through a relational view ?
    Unfortunately, Oracle 9i does not allow me to build materialzed views from XML content (Oracle objects)
    Thanks in advance,

    Thanks for your reply,
    The problem is that Oracle 9i, as far as i know, cannot build materialized views from XML data. The only thing i've been able to achieve are simple relational views and indexes.
    So, is it possible to build DW structures (cubes, dimensions,hierarchies, etc) using Oracle 9i from standard views instead of tables ? I believe not (or at least i haven't been able to)
    Thanks again

Maybe you are looking for

  • How can I get software from a disc onto my macbook air which does not have a disc drive.?

    I have  macbook air with no disc drive. However, I recently was given some cookbook software as a gift and it is in disc form. Wondering if there is an easy way to get this new software onto my mac. Was hoping I could upload the software to another P

  • Installing ram into my macbook pro

    so i was wondering if i have the ability to upgrad my current ram from 4GB to 16GB (2x gb ram cards) i know certain models of the mac book pro simply wont function when upgraded, or atleast thats what ive seen personally. I know i could install it my

  • Monthly Aggregate Values are Not matching between Two Reports

    Hi, I have two custom reports (Pivot Table View) _1) National Report_ This report renders data for the 10/11 Season (From 04/01/2010 To 03/31/2011). It includes Monthly Aggregate as well as 10/11 Season Grand Total. This report shows the correct info

  • Monitoring two instruments in one vi

    I have two instruments that I want to controll (with LabVIEW) and monitor their output. What is the best programmatic way to do this? Use two parallel while loops?

  • Looking for examples/help on using Ethernet with Keithley 2701 DMM

    All of the example code utilizing their IVI driver is based on GPIB or RS232. I specifically bought the 2701 to utilize the Ethernet port, but cannot find CVI examples on how to do this. Can anyone point me to an ethernet example using their driver a