Plan query for hierarhial queries inlude materialized views?

I have this problem;
I have a tree with more levels . In nodes of this tree I have a I have a measure . For leafs I have MV . What's happend with non-leaf nodes? Querying this measure for non-leafs nodes use MV from leafs?
Thanks in advance,
Aurel

Hello Daniel,
Even this problem seems a olap one , I think is choosing an execution plan one. Please have patience :)
I have a 10.2.0.3 Oracle Database and I want to build an OLAP (ROLAP more exactly) application for one client of the firm I work for.
I have 2 dimensions , time_dim and products_dim and a cube(sales) with these two dimensions and a fact table .
Aggregation on products dimension is a little dificult.
I have three tables : products,hierarchy and productsXhierarchy
Hierarchy has a hierarchy
create table Hierarchy(
     id number,
     name varchar2(30),
     idOfParent number,
     path varchar2(30))
obviously path column is redundat but this structure is legacy.
Data look like bellow
217158 name1
234154 name2 217158 name1
345671 name3 234154 name1 -> name2
134567 name4 345671 name1 -> name2 -> name3
134568 name5 345671 name1 -> name2 -> name3
134569 name6 345671 name1 -> name2 -> name3
Products table is
create table Products(
     idProduct number,
     nameOfProduct varchar2(30),
Data look like
10001 nameofproduct
The last table is an intersection table of the first two tables
create table productsXhierarchy{
     id number,
     idhierarchy number,
     idProduct number)
data looks like
1345 134567 10001
1346 134567 10002
1347 134568 10002
1348 134568 10002
1349 134569 10002
Unfortunatelly hierarchy table is a large table , about 8000 records .
There is applicable a solution with materialized view in this case? I though to build MVs only for products ie rows in Products table
My question is : for an intermediate node in hierarchy ie rows in Hierarchy table , lets say name3 row , for calculating sum of sales for this category optimizer will choose to use MVs for products in this category (ie products in m4,m5,m6 categories - 1345,1346,1347,1348,1349)?
Thanks for your patience for reading this,
Aurel

Similar Messages

  • Map Viewer Query Rewriting for Dynamic themes and  Materialized Views.

    Hi,
    I am usng a WMS request to render FOI points in my map.
    Internally query rewrite is happening in Mapviewer for this dynamic theme and my data points query is getting converted as
    select FROM
    ( select status, shape from MatView.MyTab where id = '3' )
    WHERE MDSYS.SDO_FILTER(shape, MDSYS.SDO_GEOMETRY(2003, 4283, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 3), MDSYS.SDO_ORDINATE_ARRAY(144.948120117188,-37.8162934802451,144.950866699219,-37.8141237016045)), 'querytype=WINDOW') = 'TRUE'
    here the rewritten query is not correct and is throwing exceptions in mapviewer log
    How can I make this query to be written correctly.
    (My orginal query before rewrite is: select status,shape from MatView.MyTab where id='3' )
    I am using a materialised view : MatView is a materialized view.
    When I used normal tables, the query is re written correctly.But for this materialized view this is happening.
    How can I correct the error?
    Is this has something to do with some Spatial Indexing in Materialised view or Query Rewriting for materialized view?
    Edited by: 841309 on Mar 10, 2011 11:04 PM

    Oops!
    The Materialized view was not accessible from the schema I tried :)
    And so when I gave permissions,it formed the correct query.
    So if permission is not there,map viewer will rewrite the query in a wrong way! New information.

  • Is it any option for Incremental Refreshing of Materialized Views..

    Hi All,
    Is anyone have any idea about Incremental refrshing of Materialized views.
    I mean i dont want to every time full refershing of MV its taking huge time.I am looking any incremental refrshing options for MViews.
    Is it any options available n Oracle 9i/10g ?
    Thanks n advance.
    Anwar

    Use theREFRESH FAST ON COMMIT option
    Example Steps
    1. Create Materialized View Log
    CREATE MATERIALIZED VIEW LOG ON table_name
    WITH ROWID
         Col1
         Col2
         Col...
    INCLUDING NEW VALUES
    2. Create the Materialized View using the above[b] table_name in the SELECT
    CREATE MATERIALIZED VIEW mv_name
    REFRESH FAST ON COMMIT
    WITH ROWID
    AS
    SELECT xxxxx
    Read more on this from SQL Reference Manual

  • Spatial vs. materialized views/query rewrite

    Dear all,
    we are trying to use Spatial (Locator) functionality together with performance optimization using materialized views and query rewrite, and it does not seem to work. Does anybody has experience with this?
    The problem in more detail:
    * There is a spatial attribut (vom Typ GEOMETRY) in our table;
    * we define a materialized view on that table;
    * we run a query that could be better answered using the materialized view with query rewrite;
    *the optimizer does not choose the plan using the materialized view, query rewrite does not take place;
    This happenes, even if neither the materialized view, nor the query contains the spatial attribut.
    The explanation given by the procedure DBMS_MVIEW.Explain_Rewrite is:
    "QSM-01064 query has a fixed table or view Cause: Query
    rewrite is not allowed if query references any fixed tables or views"
    We are using Oracle 9R2, Enterprise Edition, with locator. Nevertheless, it would also be interesting, if there is any improvement in 10g?
    A more complicated task, using materialized views to optimize spatial operations (e.g., sdo_relate) would also be very interesting, as spatial joins are very expensive operations.
    Thanks in advance for any comments, ideas!
    Cheers,
    Gergely Lukacs

    Hi Dan,
    thanks for your rapid response!
    A simple example is:
    alter session set query_rewrite_integrity=trusted;
    alter session set query_rewrite_enabled=true;
    set serveroutput on;
    /* Creating testtable */
    CREATE TABLE TESTTABLE (
    KEY1 NUMBER (4) NOT NULL,
    KEY2 NUMBER (8) NOT NULL,
    KEY3 NUMBER (14) NOT NULL,
    NAME VARCHAR2 (255),
    X NUMBER (9,2),
    Y NUMBER (9,2),
    ATTR1 VARCHAR2 (2),
    ATTR2 VARCHAR2 (30),
    ATTR3 VARCHAR2 (80),
    ATTR4 NUMBER (7),
    ATTR5 NUMBER (4),
    ATTR6 NUMBER (5),
    ATTR7 VARCHAR2 (40),
    ATTR8 VARCHAR2 (40),
    CONSTRAINT TESTTABLE_PK
    PRIMARY KEY ( KEY1, KEY2, KEY3 ));
    /* Creating materialized view */
    CREATE MATERIALIZED VIEW TESTTABLE_MV
    REFRESH COMPLETE
    ENABLE QUERY REWRITE
    AS SELECT DISTINCT ATTR7, ATTR8
    FROM TESTTABLE;
    /* Creating statistics, just to make sure */
    execute dbms_stats.gather_table_stats(ownname=> 'TESTSCHEMA', tabname=> 'TESTTABLE', cascade=>TRUE);
    execute dbms_stats.gather_table_stats(ownname=> 'TESTSCHEMA', tabname=> 'TESTTABLE_MV', cascade=>TRUE);
    /* Explain rewrite procedure */
    DECLARE
    Rewrite_Array SYS.RewriteArrayType := SYS.RewriteArrayType();
    querytxt VARCHAR2(1500) :=
    'SELECT COUNT(*) FROM (
    SELECT DISTINCT
    ATTR8 FROM
    TESTTABLE
    i NUMBER;
    BEGIN
    DBMS_MVIEW.Explain_Rewrite(querytxt, 'TESTTABLE_MV', Rewrite_Array);
    FOR i IN 1..Rewrite_Array.count
    LOOP
    DBMS_OUTPUT.PUT_LINE(Rewrite_Array(i).message);
    END LOOP;
    END;
    The message you get is:
    QSM-01009 materialized view, string, matched query text
    Cause: The query was rewritten using a materialized view, because query text matched the materialized view text.
    Action: No action required.
    i.e. query rewrite works!
    /* Adding geometry column to the testtable -- not to the materialized view, and not to the query! */
    ALTER TABLE TESTTABLE
    ADD GEOMETRYATTR mdsys.sdo_geometry;
    /* Explain rewrite procedure */
    DECLARE
    Rewrite_Array SYS.RewriteArrayType := SYS.RewriteArrayType();
    querytxt VARCHAR2(1500) :=
    'SELECT COUNT(*) FROM (
    SELECT DISTINCT
    ATTR8 FROM
    TESTTABLE
    i NUMBER;
    BEGIN
    DBMS_MVIEW.Explain_Rewrite(querytxt, 'TESTTABLE_MV', Rewrite_Array);
    FOR i IN 1..Rewrite_Array.count
    LOOP
    DBMS_OUTPUT.PUT_LINE(Rewrite_Array(i).message);
    END LOOP;
    END;
    The messages you get are:
    QSM-01064 query has a fixed table or view
    Cause: Query rewrite is not allowed if query references any fixed tables or views.
    Action: No action required.
    QSM-01019 no suitable materialized view found to rewrite this query
    Cause: There doesn't exist any materialized view that can be used to rewrite this query.
    Action: Consider creating a new materialized view.
    i.e. query rewrite does not work!
    If this works, the next issue is to use materialized views for optimizing spatial operations, e.g., a spatial join. I can supply you with an example, if necessary (only makes sense, I think, after the first problem is solved).
    Thanks in advance for any ideas, comments!
    Cheers,
    Gergely

  • How to alter the materialized view defintion with -- For update clause

    My db version is 9.2.0.3
    My orginal materialized view difination does not have "for update " clause.
    how can i alter the mview defination to inclused and exclude the "for update" clause.
    I dont want to drop and recreate the mview with for update clause. But I what to change the existing definition.
    Please suggest.
    Thanks
    Naveen.

    I already have the view definition in place. I want to change the exising defination, by adding the "for update " clause. Is it possible with any " alter mview ... " syntax.
    Below is my existing syntax. I don't what to drop and recreate. Just want to alter the existing definition , with for update clause.
    create materialized view test
    pctfree 0
    tablespace DATA storage (pctincrease 0)
    build immediate refresh start with sysdate next (trunc(sysdate+1) +1/24)
    with primary key
    disable query rewrite
    as select * from test@isource;
    Please suggest!
    Thanks
    Naveen
    Edited by: user12096071 on Apr 8, 2010 2:56 PM

  • Materialized View Log - Compress Clause for List Partition

    Hi All,
    In Syntax diagram it states that Compress Clause for List Partition of Materialized View Log is valid , but when we run any script with compress clause for list partition on Materialized view log then Database throws error as ORA-14020: this physical attribute may not be specified for a table partition
    So in any chance we can have the compress clause for the partition of materialized view log.
    Thanks in advance,
    Manu.

    The "CREATE MATERIALIZED VIEW LOG" syntax refers to the "Table Partitioning" section of the CREATE TABLE documentation.
    The "Table Partitioning" section refers to "table_partition_description" which then refers to "table_compression". "table_compression" then states that you can specify compression for entire table in the physical_properties clause and for range partition / list partition in the "table_partition_description". The Restrictions section on Table Compression says "You cannot define table compression explicitly for hash partitions or hash and list subpartitions" which implies that you can define partition for list partitions.
    Moreover, error 14020 lists valid options for Range or Composite Range and for Hash partitoins -- which implies that all other Table physical attributes are applicable for List partitions. (But then, is Compression a physical attribute -- it is really part of "physical properties" not "physical attributes").
    I think that the documentation isn't explicit enough and needs to be fixed.
    N.B : Referencing the 10.2 documentation.
    Hemant K Chitale
    Edited by: Hemant K Chitale on Feb 1, 2010 4:12 PM

  • Materialized VIews Query

    Hi,
    I want to Insert a record in my table every time materilized view brings in a new record . Is this possible , if yes anyone please suggest solution.
    Thanks
    Aali

    Hi,
    check this link for TRIGGER on MV,
    Materialized View Trigger does not fire
    Also did you try creating a trigger on the TABLE which will INSERT into the TABLE where you want it to be inserted.
    Thanks

  • Executing the saved query for views -Need Help

    How can i run get the query for the saved search in views and execute it to view the results ?Can some one help on this pl
    Thanks!

    Hi,
    I am not able to get your requirement. Share in little details.
    As of my understanding, you want to get the query which is being executed.
    Regards,
    Gyan

  • Equivalent of Materialized Views in SQL Server

    Hi
    we are migrating  Oracle Database to SQL Server 2012 and is looking for solution, equivalent to Materialized Views in Oracle.
    we had tried to implement indexed View, but that was not possible, because the MVs have outer joins, subqueries, aggregate functions and also there is no column in it which can act as a Primary Key.
    Please Help to get a solution for this issue.
    Regards
    Joyasree Mondal

    >use tempdb
    >drop table t
    >go
    >create table t(id int, constraint pk_t primary key (id))
    >
    >go
    >insert into t(id)
    >select top 1000 cast( cast( newid() as binary(4) ) as int)
    >from sys.objects o, sys.columns c
    >go 100
    >
    >
    >select id
    >from t with (index=pk_t, tablockx)
    >
    >
    >select id
    >from t with (index=pk_t, nolock)
    Still the same order.
    >> No, its always in the key order like I've shown here.
    > You are extrapolating from a single example.
    Actually, this information doesn't even come from my exampleS (there were quite a few so far). Its written in the article you posted here. My examples are meant to confirm that and explain why the ORDER BY clause is redundant in some cases.
    > I have.  ORDER BY in a view used to always return ordered results.  Then it didn't.
    Examples? References?
    >GROUP BY without an ORDER BY used to always return ordered results.  Then it didn't.  Many queries have >change the result ordering when you get a parallel plan.
    Now you finally admit ordered results would always be returned, even without an order by clause. We are in the right track it appears. The reason for this change of behavior is a variation in the logical operator used by the query optimizer, and not the
    way the engine reads pages from disk.
    In the beginning of times there was stream aggregate, an operator that would require its input to be sorted. And this is how a GROUP BY clause would ensure results were always ordered.
    But then his ugly cousin came and messed things up. He doesnt need an ordered input so yeah, order would be random. AGAIN, there are still ways of enforcing order here, through query hints, without requiring an order by clause, so this changes nothing.
    You have confirmed that for a given operator, results will always be ordered. Your own argument has, once again, proven my point.
    > Right.  But there are different _kinds_ of scans.  An ordered scan, where SQL Server reads rows based on the logical order of the index is just one kind. 
    It only won't scan in key order (by scheduling reads) if you change the transaction isolation level and hope for the worse. Because the key order scan is the best performing way of reading pages, this behavior (although possible) wasan't even observed in
    the example with NOLOCK/TABLOCK (known to cause allocation-order scans in larger tables) you posted above.
    > Other kinds include the parallel scan, the reverse scan,
    References?
    > the merry-go-round scan,
    Only applies to table scans, not indexes.
    http://technet.microsoft.com/en-us/library/ms191475%28v=SQL.105%29.aspx
    > And the allocation-order (or unordered) scan. 
    Only if you specify TABLOCK or NOLOCK query hints, which I haven't done. This is something that goes without saying, it's irrelevant to an indexed view scenario such as this one.
    Some people have also said it will perform an allocation-order scan if the index is too fragmented in SQL Server 2005, but as of 2012 it (probably) won't, as I have shown here. There is also no document anywhere in the internet (you are free to search for
    it), that would point us otherwise. If you have access to additional information, I would be more than happy if you could share it with us.
    Reference: http://sqlmag.com/database-development/quaere-verum-clustered-index-scans-part-iii
    > And don't take my word for it.  Take Conor Cunningham's:
    >If you need order in your query results, put in an ORDER BY.  It's that simple.  Anything else is like >riding in a car without a seatbelt.
    >No Seatbelt - Expecting Order without ORDER BY
    Again, with all due respect, did you read your own article? Did you read what I said earlier about having multiple I/O threads as a whole other situation? If you add new variables, OF COURSE the results will be different. Parallelism was disabled in the
    server I performed these tests on, but still you can control this by query hints, and you can enforce execution plans by using plan gudes.
    Its like I always say - it's always about the 0.001% of situations, the exceptions, rather than the general rule.
    Tell Mr Connor to add MAXDOP 1 to his querys OPTION clause and see if results are still unordered lol
    References:
    http://msdn.microsoft.com/en-us/library/ms190417.aspx
    http://msdn.microsoft.com/en-us/library/ms181714.aspx
    http://technet.microsoft.com/en-us/library/ms188611%28v=sql.105%29.aspx
    http://blogs.msdn.com/b/conor_cunningham_msft/archive/2008/08/27/no-seatbelt-expecting-order-without-order-by.aspx
    Imagining uncontrollable factors that would get an ordered input to be retrieved in an unordered manner is one of SQL Server's myths. There are a whole other people around who think the same way because of some experiences they had when they didn't know
    how to control the execution plan, and adding an order by clause is a very popular and easy shortcut to a complex problem. "In the worst cases it will just be redundant", they say. What they like to forget is that sorting has an often high cost,
    and it can be avoided by taking advantage of indexes.

  • Materialized view and Order by clause

    Hi all. I'd like to have some information regarding the order by clause used in a materialized view.
    I'm using Oracle 9.2 and Win2003 server. I have a common view (my_common_view) on which a materialized view is based (my_materialized_view). Materialized view is built for fast refresh and is created in this way:
    create materialized view my_materialized_view as
    select * from my_common_view
    order by 1,2,3;
    My question is: if I query this materialized view without adding an order by clause in the statement, I will obtain always an ordered result set? So, is it useful to include the order by clause in the materialized view script or the order by has to be include in the statement used for quering the materialized view (for example like this: select * from my_materialized view order by ...)?
    Thank you very much.
    Ste.

    SQL> create table t
      2  (x int)
      3  /
    Table created.
    SQL> create view vw
      2  as
      3  select *
      4    from t
      5   order by x
      6  /
    View created.
    SQL> select *
      2    from v$version
      3  /
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
    PL/SQL Release 9.2.0.7.0 - Production
    CORE    9.2.0.7.0       Production
    TNS for IBM/AIX RISC System/6000: Version 9.2.0.7.0 - Production
    NLSRTL Version 9.2.0.7.0 - Production
    SQL>

  • Materialized view excessive logging.  SOS

    The refresh of our materialized view is causing excessive logging. I altered the materialized view to NOLOGGING but it did not have any effect, not sure why?
    We either need to change the refresh time from 3 minutes to every 15 minutes(which is a bummer, data would be more stale) or give up on the materialized view.
    The quantity of archive logs has more than doubled since we adding this materialized view and the file system partition filed up last night, halting activity inside the database!
    Any suggestions?

    The refresh is not set for direct path inserts.Good. Now you have something you can change to help resolve the issue.
    The MV does not have any indexes.So the logging issue you describe is purely caused by deletes from, and inserts into the MV during a complete refresh.
    You can use the advice given by Alex above, and use atomic_refresh => false. Before you say it cannot be done because the users will not have access to the data during refresh, you might need to get creative. If you use query rewrite, for example, users would have access to data from the base tables while the MV is being refreshed. Their queries may be slower for a while, but they will still get data. If waiting 3 minutes or so is unacceptable for the queries that sneak in during a refresh, you can consider the following. Use query rewrite and have 2 materialized views, one of which can refresh while the other is available. After refreshing one, disable query rewrite on the older one.
    We cannot perform a fast refresh due to the query required to build the view.I'll take your word on it, although I have come across this situation many times where MVs that were thought to be impossible to fast refresh actually can be made to do it. Again, you might need to get creative. Sometimes you can do this by having MVs built on other MVs.
    Also, consider using MVs on prebuilt tables. You get additional control over how to refresh the MV this way. You can build your own custom refresh process that might help you do your own "fast refresh" by just applying the delta to your data (insert a few rows, update a few aggregates, perhaps). You can even do things like partition swapping so you can build your refreshed data in a separate table and then swap it with the MV partition (even if it is all in one partition).

  • Issue with Materialized View ORA-08103: object no longer exists

    I have a materialized view which gets refreshed(COMPLETE Refresh) every 2 minutes. However there are few scheduled programs which queries this materialized view, some of the queries in the scheduled program take longer to run. When the materialized view refresh time overlaps with this query executing from the program i get this error: ORA-08103: object no longer exists.
    I know that COMPLETE refresh doing TRUNCATE + INSERT is causing the issue, could someone suggest a workaround for this. But i need to do a COMPLETE refresh.

    Why would a TRUNCATE cause an "object no longer exists" ?
    Which job encounters this error ? The MV Refresh job or the programs that are querying the MV ? How does it resolve ? Automatically -- meaning that the next refresh/query does not raise the error ?

  • Need advise : Risks of using  materialized views

    Hi -
    I need some advise on whether using a materilzied view can help in teh folloiwng scenario.
    Scenario : You have a large tables which has sy 60 million rows, This is a demand management application which accesses this data at various aggregate levels (It is not using any OLAP functionality). The worksheets that is used to display the data takes up hours to execute on.
    To solve teh above scenario I created partitions on the base table say by time and the on top I created some materialized views. This gave me tremendoud gain in performance for the worksheets.
    Question is : Will Materialzied views help in situations say where the user changes the data in the worksheet and another user tries to query the changes will the materialized view be able to show the changes or do I need enforce a fast refresh. all the standard option of enabling query rewrite and fast refresh are enabled. The parameter for query_rewrite_integrity is set to Trusted.
    Please advise what could be teh pitfalls in managing such huge data where some of it changes infrequently.

    Hi Arch,
    Will Materialzied views help in situations say where the user changes the data in the worksheet and another user tries to query the changes will the materialized view be able to show the changes or do I need enforce a fast refresh.That depends on your "stale tolerance":
    http://www.dba-oracle.com/t_materialized_view_fast_refresh_performance.htm
    pitfalls in managing such huge data where some of it changes infrequently. If it does not change frequently, then it's just a matter of extra disk space for the materializations. I have more notes here:
    http://www.dba-oracle.com/t_finding_materialized_view_contents.htm
    Hope this helps. . .
    Don Burleson
    Oracle Press author
    Author of “Oracle Tuning: The Definitive Reference”
    http://www.dba-oracle.com/bp/s_oracle_tuning_book.htm

  • Error when Create Materialized View

    Hi
    When I tried to create MV show me error :
    SQL> @CRIA_MV_ARC_BW.SQL
    AND INDUSTRIAL.CD_FABRICA = SUBSTR(ARC.DS_ARC, 1, 3)
    ERROR at line 88:
    ORA-01031: insufficient privilegesI am using Oracle 9.02 and there are Grant for all Tablles , my query of creation is:
    CREATE MATERIALIZED VIEW CLIBGF.MV_ARC_BW
    NOCACHE
    LOGGING
    NOPARALLEL
    BUILD IMMEDIATE
    REFRESH FORCE
    START WITH TO_DATE('26-nov-2009 02:00:00','dd-mon-yyyy hh24:mi:ss')
    NEXT trunc(sysdate) + 1/12
    ENABLE QUERY REWRITE
    AS
    SELECT     MAX(NVL((SELECT  DECODE(A.T$CDNG$O,'F',DECODE(TRIM(B.T$CALC$O),'S','C',A.T$CDNG$O),A.T$CDNG$O)
                     FROM TRITON.TTDFAT995501 A, TRITON.TTDFAT996501 B
                    WHERE A.T$OCOM$O + 0 = ARC.CD_UNIDADE_EXPEDIDORA
                      AND A.T$NDOC$O = NOTAS.CD_NOTA
                      AND (A.T$OCOM$O = B.T$OCOM$O AND A.T$NREF$O = B.T$NREF$O)
                                        AND ROWNUM =1),
                   0)) NEGOCIO,
           ARC.CD_CLIENTE CD_CLIENTE,
           CLIENTE.T$NAMA DS_CLIENTE,
           ARC.CD_ARC,
           ARC.CD_STATUS,
           ARC.CD_STATUS || ' - ' || STATUS.DS_STATUS STATUS,
           TO_CHAR(ARC.DT_EMISSAO, 'DD/MM/YYYY') DT_EMISSAO,
           TO_CHAR(ACAO_INV.DT_REALIZADO, 'DD/MM/YYYY') DT_REALIZADO_INVESTIGACAO,
           ARC.CD_MARCA || ' - ' || MARCA.T$DSMA$O MARCA,
           ARC.CD_PRODUTO CD_PRODUTO,
           EMBALAGEM.T$CDAC$O || ' - ' || EMBALAGEM.T$DESC$O DS_EMBALAGEM,
           SUBSTR(ARC.DS_ARC, 1, 3) CD_COMPANHIA_PRODUTORA,
            ARC.CD_MOTIVO_RECLAMACAO CD_MOTIVO_RECLAMACAO,
            MOTIVO.DS_ITEM DS_MOTIVO_RECLAMACAO,
           DECODE(ARC.FL_PROCEDENCIA, 0, 'PROCEDENTE', 1, 'IMPROCEDENTE', ' ') PROCEDENCIA,
           SUM(NVL((SELECT SUM(NVL(T$IQUA$O, 0))
                     FROM TRITON.TTDFAT995501 A, TRITON.TTDFAT996501 B
                    WHERE A.T$OCOM$O + 0 = ARC.CD_UNIDADE_EXPEDIDORA
                      AND A.T$NDOC$O = NOTAS.CD_NOTA
                      AND (A.T$OCOM$O = B.T$OCOM$O AND A.T$NREF$O = B.T$NREF$O)),
                   0)) NR_QUANTIDADE_VENDIDA,
               ARC.NR_QUANTIDADE_AFETADA NR_QUANTIDADE_AFETADA,     
           ARC.NR_QUANTIDADE_AFETADA_REAL NR_QUANTIDADE_AFETADA_REAL,
           DS_JUSTIFICATIVA DSJUST
      FROM ARCTB_ARC                 ARC,
           ARCTB_NOTAS               NOTAS,
           ARCTB_TABELA_MOTIVO       MOTIVO,
           ARCTB_ACAO_IMEDIATA       ACAO_INV,
           ARCTB_ACAO_IMEDIATA       ACAO_IME,
           ARCTB_STATUS              STATUS,
           TRITON.TTCCOM010501       CLIENTE,
           TRITON.TTCCOM936501       CIDADE,
           TRITON.TTIITM001810       D,
           TRITON.TTIITM983501       PRODUTO,
           TRITON.TTFGLD010806       CC,
           TRITON.TTCCOM983501       MARCA,
           TRITON.TTCCOM000501       CIA,
           TRITON.TTIITM982501       NAT,
           SEI.SIBTB_MULTIMARCA      MULTIMARCA,
           SEI.SIBTB_DIRETORIA_DEPTO DIRETORIA,
           TRITON.TTCCOM994501       USUARIO,
           ARCTB_GERENCIA_INDUSTRIAL INDUSTRIAL,
           TRITON.TTIITM984501       EMBALAGEM
    WHERE ARC.CD_ARC = NOTAS.CD_ARC(+)
       AND ARC.CD_ARC = ACAO_INV.CD_ARC(+)
       AND ACAO_INV.CD_TIPO_ACAO(+) = 0
       AND ACAO_INV.CD_ACAO_IMEDIATA(+) = 999
       AND ARC.CD_ARC = ACAO_IME.CD_ARC(+)
       AND ACAO_IME.CD_TIPO_ACAO(+) = 1
       AND ACAO_IME.CD_ACAO_IMEDIATA(+) = 999
       AND ARC.CD_CLIENTE = CLIENTE.T$CUNO(+)
       AND CLIENTE.T$ESTA$L = CIDADE.T$ESTA$L(+)
       AND CLIENTE.T$CDMU$L = CIDADE.T$MUNI$L(+)
       AND TRIM(REPLACE(ARC.CD_PRODUTO, '-', '')) =
           TRIM(REPLACE(D.T$ITEM(+), '-', ''))
       AND TRIM(REPLACE(ARC.CD_PRODUTO, '-', '')) =
           TRIM(REPLACE(PRODUTO.T$ITEM$O(+), '-', ''))
       AND PRODUTO.T$PROC$O = NAT.T$PROC$O(+)
       AND EMBALAGEM.T$CDAC$O(+) = PRODUTO.T$CDAC$O
       AND ARC.CD_MOTIVO_RECLAMACAO = MOTIVO.CD_ITEM(+)
       AND ARC.CD_MARCA = MARCA.T$CDMA$O(+)
       AND SUBSTR(ARC.DS_ARC, 1, 3) = CIA.T$NCMP(+)
       AND ARC.CD_STATUS = STATUS.CD_STATUS(+)
       AND TRIM(ARC.CD_CENTRO_CUSTO) = TRIM(CC.T$DIMX(+))
       AND CC.T$DTYP(+) = 2
       AND CC.T$SUBL(+) = 0
       AND ARC.CD_DEPTO_MULTIMARCA = MULTIMARCA.CD_MULTIMARCA(+)
       AND ARC.CD_DEPTO = DIRETORIA.CD_DEPTO(+)
       AND ARC.CD_USUARIO = TRIM(USUARIO.T$CDUS$O(+))
       AND ARC.CD_STATUS IS NOT NULL
       AND ARC.CD_MOTIVO_RECLAMACAO = MOTIVO.CD_ITEM(+)
       AND INDUSTRIAL.CD_FABRICA = SUBSTR(ARC.DS_ARC, 1, 3)
       GROUP BY TO_CHAR(ARC.DT_EMISSAO, 'YYYY'),
              TO_CHAR(ARC.DT_EMISSAO, 'MM'),
              ARC.CD_ARC,
              ARC.DS_ARC,
              ARC.DS_SUPERVISOR,
              ARC.CD_STATUS,
              STATUS.DS_STATUS,
              TO_CHAR(ARC.DT_EMISSAO, 'DD/MM/YYYY'),
              TO_CHAR(ACAO_INV.DT_ORIGINAL, 'DD/MM/YYYY'),
              TO_CHAR(ACAO_INV.DT_REALIZADO, 'DD/MM/YYYY'),
              TO_CHAR(ACAO_IME.DT_ORIGINAL, 'DD/MM/YYYY'),
              TO_CHAR(ACAO_IME.DT_REALIZADO, 'DD/MM/YYYY'),
              TO_CHAR(ARC.DT_PROCEDENCIA, 'DD/MM/YYYY'),
              TO_CHAR(ARC.DT_RECEBIMENTO, 'DD/MM/YYYY'),
              TO_CHAR(NVL(ARC.DT_APROVACAO_INDUSTRIAL,
                          ARC.DT_APROVACAO_COMERCIAL),
                      'DD/MM/YYYY'),
              ARC.CD_CLIENTE,
              CLIENTE.T$NAMA,
              CIDADE.T$DSCA$L,
              ARC.CD_MARCA,
              MARCA.T$DSMA$O,
              ARC.CD_PRODUTO,
              D.T$SEAK,
              EMBALAGEM.T$CDAC$O || ' - ' || EMBALAGEM.T$DESC$O,
              NAT.T$DESC$O,
              ARC.NR_LOTE,
              ARC.DT_FABRICACAO,
              SUBSTR(ARC.DS_ARC, 1, 3),
              CIA.T$CITY,
              ARC.CD_MOTIVO_RECLAMACAO,
              MOTIVO.DS_ITEM,
              DECODE(ARC.FL_PROCEDENCIA,
                     0,
                     'PROCEDENTE',
                     1,
                     'IMPROCEDENTE',
              ARC.DS_DISPOSICAO,
              ARC.CD_CENTRO_CUSTO,
              CC.T$DESC,
              ARC.NR_QUANTIDADE_AFETADA,
              DS_JUSTIFICATIVA,
              DS_DISPOSICAO,
              CD_RESPONSAVEL_CAUSA,
              ARC.NR_QUANTIDADE_AFETADA_REAL,
              ARC.DT_ATENDIMENTO,
              MOTIVO.CLASSIFICACAO,
              ARC.DS_COORDENADOR,
              ARC.FL_ATENDIMENTO,
              TO_CHAR(ARC.DT_ATENDIMENTO, 'DD/MM/YYYY'),
              ARC.DS_COORDENADOR_INVESTIGACAO,
              INDUSTRIAL.REGIAO
    ORDER BY ARC.CD_ARC DESC;
    Edited by: muttleychess on Nov 25, 2009 10:25 AM

    Please see my privilege
    GRANTEE PRIVILEGE ADM
    CLIBGF CREATE TABLE NO
    CLIBGF CREATE ANY VIEW NO
    CLIBGF CREATE SNAPSHOT NO
    CLIBGF SELECT ANY TABLE NO
    CLIBGF CREATE ANY TRIGGER NO
    CLIBGF CREATE ANY SNAPSHOT NO

  • Materialized View Log not empty

    Hello all
    I have an oracle database (11g version), connecting via dbLink to another DB (10g version), and using it's tables as masters for fast refresh materialized views.
    To make it simple: I have master DB, with master table X, and Materialized View Log MLOG$_X.
    Then, I have replicate DB, with dblink pointing to Master, and Materialized View MV_X, using X.
    The materialized view is refreshed fast, on demand.
    The problem is, the MV log is never getting empty... how can I solve this issue?
    /* code for creating MView */
    CREATE MATERIALIZED VIEW "MY_USER"."SI_BANK" ("ID", "NAME", "ACRONYM")
      ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 163840 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE "USERS"
      BUILD IMMEDIATE
      USING INDEX
      REFRESH FAST ON DEMAND START WITH sysdate+0 NEXT SYSDATE + 1
      WITH PRIMARY KEY USING DEFAULT LOCAL ROLLBACK SEGMENT
      USING ENFORCED CONSTRAINTS DISABLE QUERY REWRITE
      AS SELECT ibanco id, nbanco name, nsigla acronym FROM USER.tgtbanc0@DB_LINK;
    /* code for refresh group*/
    BEGIN
      DBMS_REFRESH.MAKE ( name => 'si2p_grp',
      list => '', next_date => 'SYSDATE +1' , interval => 'SYSDATE + 1', implicit_destroy => FALSE, rollback_seg => '', push_deferred_rpc => TRUE, refresh_after_errors => FALSE);
    END;
    /* ADD MATERIALIZED VIEWS TO GROUP */
    BEGIN
        DBMS_REFRESH.ADD ( name => 'si2p_grp', list => 'SI_BANK', lax => TRUE);
    END;
    Thank you for any help

    One MV log serve to many materialized views. Check dba_registered_mviews on master DB to see how many MViews you have build on you master table X.
    After MV (materialized view) is refreshed than all data logged in MVlog for this MV are deleted. But new are recorded when DML are performed against table X.
    If you can stop DML on table X for some period of time then do MV refresh and then you can see that MVlog is empty.

Maybe you are looking for