Performance issue accessing Materialized Views

Hi All
I am extracting source data from Materialized View through DBLink which is having record count of 1500000 rows.
But its taking lot of time(Approx. 30-45 min) during loading.
Is there any other way to load the data in a faster way??
regards
Gourisankar

Hi,
I take it the simple 'Select from "materialized view' doesn't take this long. This could be down to the issue when issuing an 'INSERT' statement using a database link, even if you use the Optimizer hint 'DRIVING_SITE' does not help. The problem is that when issuing an INSERT statement using a DB LINK the filtering of records does not happen on the far side of the link. All the data is moved across the link to the target db, and then filtered etc.
One way to get round this is to use a pipelined function to run your select to get your values, then call the pipeline function via ODI.
Still use the DIRVING_SITE optimizer hint in the pipelined function when selecting your data.
Cheers
Bos

Similar Messages

  • Performace issue on MATERIALIZED view

    Hi Gurus,
    Need help to understand perfoamance issue on MATERIALIZED view. I have created mat view on some big table of 76GB. Mat view is of 25 GB.
    I have refreshed mat view before running report. In OEM it ish showng going for full table scan and estimated time is of 2 hrs where full tablescan on base table on which mat view is created is of 20 Mins . I am using fast refresh on demand .
    We are using Oracle 10.2.0.4 on Sun Sprac 64bit 10 platform and version.
    Could you please let me know what could be the reason why mat views are performing poor ?
    Thanks & Regards

    You have MLOG created on your master table, right?
    OK, then check DBA_MVIEWS. Look for LAST_REFRESH_TYPE, If everything is OK, i should be FAST.
    If everything is OK by now, the problem can be the nature of master table. If there is great amount of changes in master table, set periodic job which will do refresh often (since 'often' is fuzzy word, it can be every 5, 10, 30 minutes...). Incremental refresh will perform beter if there is small amount of changes in MLOG table!
    You can check your MLOG table. If it is huge (size in MB) and there is only few records in it, try to realocate the space issuing "ALTER TABLE MLOG$_table_name;"
    Hope something will be helpfull...
    Best regards

  • 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!

  • HTML Article performance issues in Adobe Viewer on iPad

    I have created a HTML Article using DPS but when I come to view it on Adobe Viewer in iPad the content does not scroll smoothly and the content is cut off and cropped (the whole page is not displayed), it is very judery and struggles to render the HTML below 'the fold' so to speak.
    I have tried both options for importing HTML into DPS and both have the same performance/lag isuues.
    I have a video in my HTML that seemed to be causing an issue where the video streaming was struggling to be pulled through, so I have treid YouTube and Vimeo video streaming and the performance/display issue is not resolved. I then tried embbeding an mp4 directly using HTML5 to see if it was a connection/bandwidth issue and the problem still exists. However the videos do play, its just the fact that the container is cropped in half.
    Sometimes the whole HTML article renders but then when you swipe back up the page it struggles to render the content above? Also then when you swipe back down the page the content is also cropped that was visible before?
    I have reviewed every available discussion on the Adobe Community and other resources but all the fixes mentioned do not have any effect.
    If anybody can assist or has been experiencing the same issues any advise would be welcome.
    Oh, the HTML Article contains some JS too, it does function correctly but I was wondering if JS causes problems? Just a thought.

    Well, I think I may have found the answer so I thought I would share with the Community incase anyone else experiences the same type of issues.
    After testing another peice of HTML that also included video streaming and heavy JavaScript, I narrowed the issue down to my JS. I had two Nivo Slider Carousels that were the route of the performance issues.
    The other test HTML Article scrolls smoothly and the video pulls in as intended, although once in a while there is a slight delay in the page scrolling up and down but this is hardly noticeable.
    I hope this may be of some help to other's in the future?

  • Issue in Materialized view

    Hi,
    Am facing the below issue while creating MV,
    create materialized view log on a;
    cretae materialized view log ob b;
    create materialized view
    refresh fast on commit
    as
    select a.x,a.y,b.z
    from a,b
    where
    a.i=b.i and
    a.bill_dt > trunc(add_months(sysdate,-12),'month');
    And am getting ORA-12054 Kindly suggest me how can achive this?
    Thanks,
    Siva

    I don't really have a good idea, sorry.
    If an MV can be partitioned, then maybe monthly partitioning on the MV could be an option. But I guess (I do not know for certain) that an MV would not support dropping old partions.
    An alternative solution (but it is somewhat a kludge) would be an MV that refreshes complete every night (no refresh fast on commit, no MV logs.) Then you create a view that selects from the MV all data before today and uses union all to a select that queries the base tables for todays data. It will not be as fast to query as an MV refresh on commit, but it might be fast enough?
    I do not see another way - but maybe some other forum user has a good idea? ;-)

  • 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 ?

  • Performance Issue with PAY_BALANCE_VALUES_V View in Oracle R12

    Dear all ,
      We have recently upgraded from 11i(11.5.10.2) to R12(12.1.3). We are facing one Issue with slow performance of the queries where PAY_BALANCE_VALUES_V is used. We have so many reports & logic in Payroll which uses this View.
    In 11i this works fine, however in R12 it takes very long time. There are no configuration changes we have done from 11i to R12.
    Is there any way to optimize the performance or alternate way to retrieve the Balances Data in Payroll ?
    Any heads up would be highly Appreciated.
    Thanks,
    Razi

    Hi Razi,
    The balance related performance issue is written in the following note.
    Note:1494344.1 UK Payslip Generation - Self Service Program Takes Much Time To Complete (Performance Issue)
    This issue was fixed in HR_PF.B RUP6 or patch:14376786. Did you apply this patch? If not, I suggest you apply it.
    Also, HR_PF.B RUP6 has some balance related performance issues.
    If you already have applied HR_PF.B RUP6, I suggest you log a SR with SQL trace.
    Thanks,
    Hideki

  • Issue with materialized view and fast refresh between Oracle 10g and 11g

    Hi all,
    I've hit a problem when trying to create a fast-refreshable materialized view.
    I've got two databases, one 10.2.0.10, another 11.2.0.1.0, running on 32-bit Windows. Both are enterprise edition, and I'm trying to pull data from the 10g one into the 11g one. I can happily query across the database link from 11g to 10g, and can use complete refresh with no problem except the time it takes.
    On the 10g side, I've got tables with primary keys and m.v. logs created, the logs being of this form ...
    CREATE MATERIALIZED VIEW LOG ON table WITH PRIMARY KEY INCLUDING NEW VALUES
    On the 11g side, when I try to create an m.v. against that ...
    CREATE MATERIALIZED VIEW mv_table REFRESH FAST WITH PRIMARY KEY AS SELECT col1, col2 FROM table@dblink;
    ... I get an ORA-12028 error (materialized view type is not supported by master site).
    After running the EXPLAIN_MVIEW procedure it shows this;
    REFRESH_FAST_AFTER_INSERT not supported for this type mv by Oracle version at master site
    A colleague has managed to build a fast-refresh m.v. from the same source database, but pulling to a different one than I'm using; his target is also 10g, like the (common) source, so I've no idea why I'm getting the 'not supported' message whilst he isn't.
    I've been able, on previous projects, to do exactly what I'm trying to achieve but on those someone with more knowledge than me has configured the database!
    I'm now stumped. I'm also no DBA but despite that it's been left to me to install the new 11g database on the 32-bit Windows server from scratch, so there are probably a couple of things I'm missing. It's probably something really obvious but I don't really know where to look now.
    If anyone can give me any pointers at all, I'd be really grateful. This question is also duplicated in the Replication forum but hasn't had any replies as yet, so I'm reproducing it here in hope!
    Thanks in advance,
    Steve

    Hi Steve,
    You should have a look at metalink, Doc ID 1059547.1
    If that does not help, there may be something else in Mater note ID 1353040.1
    Best regards
    Peter

  • Help with Performance issue with a view

    Hi
    We developed a custom view to get the data from gl_je_lines table with source as Payables. We are bringing the data for the last year and current year till date ie., from 01-JAN-2012 to SYSDATE. This view is in a package body, which is called from a concurrent program to write the data to a outbound file.
    The problem I am facing is that this view is fetching around 72 lakhs of records for the above date range and the program is running for a long time and completes abruptly with out any result. Can anyone please let me know if there is an alternative to this. I checked the view query and there seems to be not much scope to improve the performance.
    Will inserting al this data into a Global Temporary Table will help? Please revert at the earliest as this solution is very urgent for our clients.
    Message was edited by: 988490e8-2268-414d-b867-9d9a911c0053

    This is the view query:
    select GCC.SEGMENT1 "EMPRESA",
           GCC.SEGMENT2 "CCUSTO",
           GCC.SEGMENT3 "CONTA",
           GCC.SEGMENT4 "PRODUTO",
           GCC.SEGMENT5 "SERVICO",
           GCC.SEGMENT6 "CANAL",
           GCC.SEGMENT7 "PROJECT",
           GCC.SEGMENT8 "FORWARD1",
           GCC.SEGMENT9 "FORWARD2",
           FFVT.DESCRIPTION "CONTA_DESCR",
           ltrim(substr(XRX_CONSOLIDATION_MAPPING('XDMO_LOCAL_USGAAP_LEGAL_ENTITY',
                                                  'XDMO_REPORT_USGAAP_LEGAL_COMPANY',
                                                  GCC.SEGMENT1,
                                                  GCC.SEGMENT3),
                        1,
                        80)) "LEGAL_COMPANY",
           ltrim(substr(XRX_CONSOLIDATION_MAPPING('XDMO_LOCAL_USGAAP_ACCOUNT',
                                                  'XDMO_REPORT_USGAAP_FIN_ACCOUNT',
                                                  GCC.SEGMENT3,
                                                  GCC.SEGMENT3),
                        1,
                        80)) "GRA",
           ltrim(substr(XRX_CONSOLIDATION_MAPPING('XDMO_LOCAL_USGAAP_BUDGET_CENTER',
                                                  'XDMO_REPORT_USGAAP_RESPONSIBILITY',
                                                  GCC.SEGMENT2,
                                                  GCC.SEGMENT3),
                        1,
                        80)) "RESP",
           ltrim(substr(XRX_CONSOLIDATION_MAPPING('XDMO_LOCAL_USGAAP_PRODUCT',
                                                  'XDMO_REPORT_USGAAP_TEAM',
                                                  GCC.SEGMENT4,
                                                  GCC.SEGMENT3),
                        1,
                        80)) "TEAM",
           ltrim(substr(XRX_CONSOLIDATION_MAPPING('XDMO_LOCAL_USGAAP_ACCOUNT',
                                                  'XDMO_REPORT_USGAAP_FIN_ACCOUNT',
                                                  GCC.SEGMENT3,
                                                  GCC.SEGMENT3),
                        164,
                        80)) "GRA_DESCR",
           GJH.NAME "IDLANC",
           GJS.USER_JE_SOURCE_NAME "ORIGEM",
           GJC.USER_JE_CATEGORY_NAME "CATEGORIA",
           GJL.DESCRIPTION "DESCRICAO",
           decode(GJH.JE_SOURCE, 'Payables', GJL.REFERENCE_2, '') "INVOICE_ID",
           decode(GJH.JE_SOURCE, 'Payables', GJL.REFERENCE_5, '') "NOTA",
           decode(GJH.JE_SOURCE, 'Payables', GJL.REFERENCE_1, '') "FORNECEDOR",
           GJH.DEFAULT_EFFECTIVE_DATE "DTEFET",
           to_char(GJB.POSTED_DATE, 'DD-MON-YYYY HH24:MI:SS') "DTPOSTED",
           GJH.CURRENCY_CONVERSION_TYPE "TPTAX",
           substr(GCC.SEGMENT9, 8, 1) "TAXA",
           GJH.CURRENCY_CONVERSION_DATE "DTCONV",
           -- nvl(GJL.ACCOUNTED_DR,0)-nvl(GJL.ACCOUNTED_CR,0)       "VALOR",
           -- added as per ITT #517830
           nvl(GJL.ENTERED_DR, 0) - nvl(GJL.ENTERED_CR, 0) "VALOR",
           GJH.CURRENCY_CODE "MOEDA",
           --  decode(gcc.segment9, '00000000', 0, '00000001', nvl(GJL.ACCOUNTED_DR,0)-nvl(GJL.ACCOUNTED_CR,0)) "VALOR_FUNCIONAL",
           -- added as per ITT #517830
           (nvl(GJL.ACCOUNTED_DR, 0) - nvl(GJL.ACCOUNTED_CR, 0)) "VALOR_FUNCIONAL",
           GSOB.CURRENCY_CODE "FUNCIONAL",
           GJH.PERIOD_NAME "PERIODO",
           GJB.STATUS "STATUS",
           GSOB.SHORT_NAME "LIVRO",
           GJL.LAST_UPDATE_DATE "JL_LAST_UPDATE_DATE",
           GJH.LAST_UPDATE_DATE "JH_LAST_UPDATE_DATE",
           GJB.LAST_UPDATE_DATE "JB_LAST_UPDATE_DATE",
           GJL.JE_HEADER_ID "JE_HEADER_ID",
           GJL.JE_LINE_NUM "JE_LINE_NUM"
      from GL.GL_JE_LINES   GJL,
           GL.GL_JE_HEADERS GJH,
           GL.GL_JE_BATCHES GJB,
           --GL.GL_SETS_OF_BOOKS                    GSOB, ---As GL_SETS_OF_BOOKS table dropped in R12 so replaced with GL_LEDGERS table,Commented as part of DMO R12 Upgrade-RFC#411290.
           GL.GL_LEDGERS               GSOB, ---Added as part of DMO R12 Upgrade-RFC#411290.
           GL.GL_JE_SOURCES_TL         GJS,
           GL.GL_JE_CATEGORIES_TL      GJC,
           GL.GL_CODE_COMBINATIONS     GCC,
           APPLSYS.FND_FLEX_VALUES_TL  FFVT,
           APPLSYS.FND_FLEX_VALUES     FFV,
           APPLSYS.FND_FLEX_VALUE_SETS FFVS
    where GJL.CODE_COMBINATION_ID = GCC.CODE_COMBINATION_ID
       and GJL.JE_HEADER_ID = GJH.JE_HEADER_ID
       and GJH.JE_BATCH_ID = GJB.JE_BATCH_ID
          --and GJB.SET_OF_BOOKS_ID = GSOB.SET_OF_BOOKS_ID    ---Changing the mappings between the tables GL_JE_HEADERS and GL_JE_BATCHES As column SET_OF_BOOKS_ID of table GL_JE_BATCHES dropped in R12,Commented as part of DMO R12 Upgrade-RFC#411290.
       and GJH.LEDGER_ID = GSOB.LEDGER_ID ---Added as part of DMO R12 Upgrade-RFC#411290.
       and GJH.JE_SOURCE = GJS.JE_SOURCE_NAME
       and GJH.JE_CATEGORY = GJC.JE_CATEGORY_NAME
       and GCC.SEGMENT3 = FFV.FLEX_VALUE
       and FFV.FLEX_VALUE_ID = FFVT.FLEX_VALUE_ID
       and FFV.FLEX_VALUE_SET_ID = FFVS.FLEX_VALUE_SET_ID
       and FFVS.FLEX_VALUE_SET_NAME = 'XDMO_LOCAL_USGAAP_ACCOUNT'
       and GSOB.SHORT_NAME in ('XBRA BRL LOCAL GAAP', 'XBRA BRL USGAAP')
       and gcc.chart_of_accounts_id = gsob.chart_of_accounts_id
       and gjh.actual_flag = 'A'
    DB VErsion: 11.2.0.3.0
    The problem I am facing is that the above query fetches huge data and I want to know if there is anyway to improve the performance of this query. You are right that view is stored in DB. I am using this view query in a cursor to fetch the records

  • About Performance issue

    Hi All,
    I have a table which is very frequently used for transcational purposes (like Insert,Delete,Update) from Oracle apps database.
    I have created a view based on this table only and this view is referenced by another database very frequently using DB Link.
    Will there be any performance issue either on view or on table since table is getting used same time in Select queries and also in transcations (like Insert,Delete,Update) from different databases?
    is it better to create to Materilized view or normal view for this purpose (Since Mview can be refreshed daily once).
    Please suggest..
    Thanks

    Lakshmi V wrote:
    Hi All,
    I have a table which is very frequently used for transcational purposes (like Insert,Delete,Update) from Oracle apps database.
    I have created a view based on this table only and this view is referenced by another database very frequently using DB Link.
    Will there be any performance issue either on view or on table since table is getting used same time in Select queries and also in transcations (like Insert,Delete,Update) from different databases?Yes and No.... or It Depends.
    Oracle doesn't have a problem querying tables whilst inserts, deletes or updates are taking place on them. The database engine is designed to be multi-transactional, so things won't hold up a query against the data. The only thing that will slow it down really is the I/O which is primarily related to disc access, so if the physical server is doing a lot of I/O to process the inserts/updates and deletes, then the query may get slowed down as a result of that, but it really depends on the hardware and how the data is spread on the discs.
    is it better to create to Materilized view or normal view for this purpose (Since Mview can be refreshed daily once).You could if your business process allows for snapshots of data rather than near-real-time, that's entirely your choice. It won't necessarily help improve the I/O, though it may.
    Without your database version, table structures, and details of your hardware, explain plans, test cases etc. there's no correct answer to give you.
    Personally, I wouldn't bother with the Materialized view unless I needed to look at a snapshot of the data, or I needed to perform queries using different search clauses from normal such that I needed some different indexes that I didn't want to apply to the base table. I certainly wouldn't consider it just to try and improve performance and take the querying away from the transactional data.

  • 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

  • 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

  • Error on creation of Materialized view

    Hi all, how are u? :-D
    Well, I´m trying to use MATERIALIZED VIEW with refresh fast,
    when first I grant permissions on the table action to an user,
    after I create the MATERIALIZED VIEW LOG on the master and, finally,
    I create the MATERIALIZED VIEW on the target.
    -- using other_user:
    GRANT SELECT, INSERT, UPDATE, DELETE ON action TO an_user;
    CREATE MATERIALIZED VIEW LOG ON action
       WITH PRIMARY KEY;
    -- using an_user:
    CREATE MATERIALIZED VIEW vw_action
    REFRESH FAST
    START WITH sysdate
    NEXT TRUNC(sysdate) + 1/24
    AS SELECT * FROM other_user.action;But, when I perform the CREATE MATERIALIZED VIEW the following error occurs:
    ERROR at line 5:
    ORA-12018: following error encountered during code generation for "AN_USER"."VW_ACTION"
    ORA-00942: table or view does not exist
    When I execute the query SELECT * FROM other_user.action, the data are returned.
    What can it to be?
    What´s the problem in this case?
    Thank you very much!
    []´s

    Hi Nicolas,
    Well, I´m using Oracle 9.2.0.1 with Linux Red Hat.
    I tryid without synonym and with synonym too, but...
    I´m gonna to search for a solution.
    And I´m gonna to try use the action recommended by oracle:
    ORA-12015 cannot create a fast refresh materialized view from a complex query
    Cause: Neither ROWIDs nor primary key constraints are supported for complex queries.
    Action: Reissue the command with the REFRESH FORCE or REFRESH COMPLETE option or create a simple materialized view.thank you very much!
    []´s

  • Fast Refresh Materialized View - failure

    Okay, this issue currently has me stumped. I searched the world wide web and still cannot seem to identify the cause of this issue.
    Here is the scenario:
    I created a materialized view log for the source table (let's say table1) found at DB1.
    I then create a materialized view (fast refresh, with logging) at a remote database (let's say DB2). The query for the MV is basic: select * from schema1.table1@db1_link;
    I set the materialized view to refresh every 30 seconds (for testing purposes).
    This creates a dbms job that executes every 30 seconds. The materialized view gets created successfully. I purposely enter new data into table1. The materialized view log for table1 successfully captures these changes. However, the materialized view found at DB2 does not get refreshed (updated) successfully.
    In fact, the dbms job errors-out. It keeps failing and failing. After 16 times, it gets marked as 'broken.'
    The error message is as such:
    RDBA WARNING: ORA-12012: error on auto execute of job 1472
    RDBA WARNING: ORA-00604: error occurred at recursive SQL level 3
    RDBA WARNING: ORA-01017: invalid username/password; logon denied
    RDBA WARNING: ORA-02063: preceding line from db1
    RDBA WARNING: ORA-06512: at "SYS.DBMS_SNAPSHOT", line 820
    RDBA WARNING: ORA-06512: at "SYS.DBMS_SNAPSHOT", line 877
    RDBA WARNING: ORA-06512: at "SYS.DBMS_IREFRESH", line 683
    RDBA WARNING: ORA-06512: at "SYS.DBMS_REFRESH", line 195
    RDBA WARNING: ORA-06512: at line 1
    The strange thing is, that the error supposedly claims invalid username/password. But I've used the db links successfully before & the username/password is not invalid. Has anyone encountered this issue before?

    Justin,
    From reading earlier posts about issues with materialized views, I remember reading something about materialized views (fast refreshable) not working with sysdate. What did you mean by such a statement? (I would copy & paste it here, but I am unable to find it at the moment).
    The reason I am curious, is the fact that I am setting my MV to refresh every 30 seconds let's say (for testing). At this moment - it starts failing & failing & failing.

  • Erro perforing Fast Refresh of Materialized View.

    Hi Experts,
    We are facing serious problem while refreshing materialized views using fast refresh option in ORACLE..
    For the very first time we are performing Complete refresh of data from DB1 to DB2 for few tables.Ongoing we are performing Fast Refresh.
    Sometimes the fast refresh works fine without any error and sometimes it fails with the below error.
    ERROR at line 1:
    ORA-32320: REFRESH FAST of "CIR"."C_BO_COMM" unsupported after cointainer table
    PMOPs
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 803
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 860
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 841
    ORA-06512: at line 1we came to know the folowing.
    // *Cause:
      A Partition Maintenance Operation (PMOP) has been performed on the materialized view,
      and no materialized view supportsfast refersh after container table PMOPs.
    // *Action:
                   Use REFRESH COMPLETE.
         Note: 
                   you can determine why your materialized view does not support fast refresh after PMOPs using
                   the DBMS_MVIEW.EXPLAIN_MVIEW() API.Please let u know what action to be taken to avoid this.
    Please note that this error is not repeated always. Some times REFRESH FAST is happening and some times it is throwing error.
    Appreicate your earliest reply.
    Thank you.
    Edited by: User71408 on Sep 4, 2008 11:40 PM
    Edited by: User71408 on Sep 4, 2008 11:43 PM
    Edited by: User71408 on Sep 5, 2008 12:38 AM

    9i doesn't support fast refresh after truncate. Read the metalink note 275325.1
    You should be sure no truncate has been executed, or use complete refresh.
    Nicolas.

Maybe you are looking for