Peformance of a Materialized view

Hi,
I have created materialized view the below
CREATE MATERIALIZED VIEW SUMMARY.V_OSFI_FEED_CORE_DATA_ADJ
TABLESPACE RCDW_CAD_SUM_1M_DAT01
PCTUSED    0
PCTFREE    0
INITRANS   2
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            MINEXTENTS       1
            MAXEXTENTS       UNLIMITED
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
NOCACHE
LOGGING
NOCOMPRESS
NOPARALLEL
BUILD DEFERRED
REFRESH FORCE ON DEMAND
WITH PRIMARY KEY
AS
/* Formatted on 2010/01/27 14:49 (Formatter Plus v4.8.8) */
SELECT orgn.month_end_date month_end_date,
       orgn.ntrl_k_odc_instrument ntrl_k_odc_instrument,
       orgn.processing_system processing_system,
       orgn.source_system source_system,
       DECODE (UPPER (adjstd.ssb_type_indicator),
               'NULL', NULL,
               NVL (adjstd.ssb_type_indicator, orgn.ssb_type_indicator)
              ) ssb_type_indicator,
       DECODE (UPPER (adjstd.basel_exposure_class),
               'NULL', NULL,
               NVL (adjstd.basel_exposure_class, orgn.basel_exposure_class)
              ) basel_exposure_class,
       DECODE (UPPER (adjstd.basel_exposure_subclass),
               'NULL', NULL,
               NVL (adjstd.basel_exposure_subclass,
                    orgn.basel_exposure_subclass
              ) basel_exposure_subclass,
       DECODE (UPPER (TRIM (adjstd.ccis_product_code)),
               'NULL', NULL,
               NVL (adjstd.ccis_product_code, orgn.ccis_product_code)
              ) ccis_product_code,
       orgn.warehouse_instrument_key warehouse_instrument_key,
       DECODE (UPPER (adjstd.instrument_status),
               'NULL', NULL,
               NVL (adjstd.instrument_status, orgn.instrument_status)
              ) instrument_status,
       DECODE (UPPER (adjstd.instrument_open_flag),
               'NULL', NULL,
               NVL (adjstd.instrument_open_flag, orgn.instrument_open_flag)
              ) instrument_open_flag,
       DECODE (UPPER (adjstd.instrument_dwo_flag),
               'NULL', NULL,
               NVL (adjstd.instrument_dwo_flag, orgn.instrument_dwo_flag)
              ) instrument_dwo_flag,
       DECODE (UPPER (adjstd.instrument_closed_flag),
               'NULL', NULL,
               NVL (adjstd.instrument_closed_flag,
                    orgn.instrument_closed_flag)
              ) instrument_closed_flag,
       DECODE (UPPER (adjstd.instrument_arrears_flag),
               'NULL', NULL,
               NVL (adjstd.instrument_arrears_flag,
                    orgn.instrument_arrears_flag
              ) instrument_arrears_flag,
       DECODE (UPPER (adjstd.instrument_npna_flag),
               'NULL', NULL,
               NVL (adjstd.instrument_npna_flag, orgn.instrument_npna_flag)
              ) instrument_npna_flag,
       DECODE (UPPER (adjstd.account_open_dt),
               'NULL', TO_DATE (NULL),
               NULL, orgn.account_open_dt,
               TO_DATE (adjstd.account_open_dt, 'dd-MON-YYYY')
              ) account_open_dt,
       DECODE (UPPER (adjstd.account_close_dt),
               'NULL', TO_DATE (NULL),
               NULL, orgn.account_close_dt,
               TO_DATE (adjstd.account_close_dt, 'dd-MON-YYYY')
              ) account_close_dt,
       DECODE (UPPER (adjstd.instrument_insured_ind),
               'NULL', NULL,
               NVL (adjstd.instrument_insured_ind,
                    orgn.instrument_insured_ind)
              ) instrument_insured_ind,
       DECODE
          (UPPER (adjstd.instrument_securitized_ind),
           'NULL', NULL,
           NVL (adjstd.instrument_securitized_ind,
                orgn.instrument_securitized_ind
          ) instrument_securitized_ind,
       DECODE (UPPER (adjstd.country_code),
               'NULL', NULL,
               NVL (adjstd.country_code, orgn.country_code)
              ) country_code,
       DECODE (UPPER (TRIM (adjstd.province)),
               'NULL', NULL,
               NVL (adjstd.province, orgn.province)
              ) province,
       COALESCE (adjstd.presec_outstanding_bal,
                 orgn.presec_outstanding_bal,
                 NULL
                ) presec_outstanding_bal,
       COALESCE (adjstd.postsec_outstanding_bal,
                 orgn.postsec_outstanding_bal,
                 NULL
                ) postsec_outstanding_bal,
       COALESCE (adjstd.presec_authorized_limit,
                 orgn.presec_authorized_limit,
                 NULL
                ) presec_authorized_limit,
       DECODE (UPPER (adjstd.interest_rate_type),
               'NULL', NULL,
               NVL (adjstd.interest_rate_type, orgn.interest_rate_type)
              ) interest_rate_type,
       COALESCE (adjstd.ltv, orgn.ltv, NULL) ltv,
       DECODE (UPPER (adjstd.arrears_cycle_type),
               'NULL', NULL,
               NVL (adjstd.arrears_cycle_type, orgn.arrears_cycle_type)
              ) arrears_cycle_type,
       COALESCE (adjstd.recovery_amt, orgn.recovery_amt, NULL) recovery_amt,
       COALESCE (adjstd.wrtoff_amt, orgn.wrtoff_amt, NULL) wrtoff_amt,
       COALESCE (adjstd.utilization_rate,
                 orgn.utilization_rate,
                 NULL
                ) utilization_rate,
       DECODE (UPPER (adjstd.pd_pool),
               'NULL', NULL,
               NVL (adjstd.pd_pool, orgn.pd_pool)
              ) pd_pool,
       COALESCE (adjstd.pd_value_pct, orgn.pd_value_pct, NULL) pd_value_pct,
       DECODE (UPPER (adjstd.lgd_pool),
               'NULL', NULL,
               NVL (adjstd.lgd_pool, orgn.lgd_pool)
              ) lgd_pool,
       COALESCE (adjstd.lgd_value_pct, orgn.lgd_value_pct,
                 NULL) lgd_value_pct,
       DECODE (UPPER (adjstd.ead_pool),
               'NULL', NULL,
               NVL (adjstd.ead_pool, orgn.ead_pool)
              ) ead_pool,
       COALESCE (adjstd.presec_precrm_ead,
                 orgn.presec_precrm_ead,
                 NULL
                ) presec_precrm_ead,
       COALESCE (adjstd.postsec_precrm_ead,
                 orgn.postsec_precrm_ead,
                 NULL
                ) postsec_precrm_ead,
       COALESCE (adjstd.postsec_postcrm_ead,
                 orgn.postsec_postcrm_ead,
                 NULL
                ) postsec_postcrm_ead,
       COALESCE (adjstd.expected_loss_amt,
                 orgn.expected_loss_amt,
                 NULL
                ) expected_loss_amt,
       COALESCE (adjstd.postsec_rwa, orgn.postsec_rwa, NULL) postsec_rwa,
       DECODE (UPPER (adjstd.risk_rating_system),
               'NULL', NULL,
               NVL (adjstd.risk_rating_system, orgn.risk_rating_system)
              ) risk_rating_system,
       DECODE (UPPER (adjstd.default_ind),
               'NULL', NULL,
               NVL (adjstd.default_ind, orgn.default_ind)
              ) default_ind,
       DECODE (UPPER (adjstd.LOB),
               'NULL', NULL,
               NVL (adjstd.LOB, orgn.LOB)
              ) LOB,
       DECODE (UPPER (adjstd.row_source),
               'NULL', NULL,
               NVL (adjstd.row_source, orgn.row_source)
              ) row_source,
       COALESCE (adjstd.postsec_authorized_limit,
                 orgn.postsec_authorized_limit,
                 NULL
                ) postsec_authorized_limit,
       COALESCE (adjstd.recovery_amt_calc,
                 orgn.recovery_amt_calc,
                 NULL
                ) recovery_amt_calc,
       adjstd.adj_cycle_id adj_cycle_id,
       orgn.curr_warehouse_inst_key curr_warehouse_inst_key,
       orgn.curr_ccis_prod curr_ccis_prod, adjstd.load_time load_time,
       adjstd.update_time update_time
  FROM summary.osfi_feed_core_data orgn, summary.ncr_adj_data adjstd
WHERE orgn.ntrl_k_odc_instrument = adjstd.ntrl_k_odc_instrument
UNION ALL
SELECT orgn.month_end_date, orgn.ntrl_k_odc_instrument,
       orgn.processing_system, orgn.source_system, orgn.ssb_type_indicator,
       orgn.basel_exposure_class, orgn.basel_exposure_subclass,
       orgn.ccis_product_code, orgn.warehouse_instrument_key,
       orgn.instrument_status, orgn.instrument_open_flag,
       orgn.instrument_dwo_flag, orgn.instrument_closed_flag,
       orgn.instrument_arrears_flag, orgn.instrument_npna_flag,
       orgn.account_open_dt, orgn.account_close_dt,
       orgn.instrument_insured_ind, orgn.instrument_securitized_ind,
       orgn.country_code, orgn.province, orgn.presec_outstanding_bal,
       orgn.postsec_outstanding_bal, orgn.presec_authorized_limit,
       orgn.interest_rate_type, orgn.ltv, orgn.arrears_cycle_type,
       orgn.recovery_amt, orgn.wrtoff_amt, orgn.utilization_rate,
       orgn.pd_pool, orgn.pd_value_pct, orgn.lgd_pool, orgn.lgd_value_pct,
       orgn.ead_pool, orgn.presec_precrm_ead, orgn.postsec_precrm_ead,
       orgn.postsec_postcrm_ead, orgn.expected_loss_amt, orgn.postsec_rwa,
       orgn.risk_rating_system, orgn.default_ind, orgn.LOB, orgn.row_source,
       orgn.postsec_authorized_limit, orgn.recovery_amt_calc, 0,
       orgn.curr_warehouse_inst_key curr_warehouse_inst_key,
       orgn.curr_ccis_prod curr_ccis_prod, SYSDATE, SYSDATE
  FROM osfi_feed_core_data orgn
WHERE NOT EXISTS (SELECT ntrl_k_odc_instrument
                     FROM ncr_adj_data
                    WHERE ntrl_k_odc_instrument = orgn.ntrl_k_odc_instrument);When i refresh the materialized view its taking 5 to 6 mins. I have used DBMS_ADVISOR.TUNE_MVIEW to tune the query, but it raised error as
ORA-13600: error encountered in Advisor
QSM-03113: Cannot tune the MATERIALIZED VIEW statement
QSM-02091: mv references a non-repeatable or session-sensitive expression
QSM-02164: the materialized view is BUILD DEFERRED
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
ORA-06512: at "SYS.PRVT_ACCESS_ADVISOR", line 202
ORA-06512: at "SYS.PRVT_TUNE_MVIEW", line 1232
ORA-06512: at "SYS.DBMS_ADVISOR", line 753
ORA-06512: at line 221
Can anyone suggest some methods to increase the peformance of the view.

Hi,
Here is the explain plan of the query,
Plan
SELECT STATEMENT  ALL_ROWSCost: 626  Bytes: 35,803,043  Cardinality: 144,937                                     
    18 PX COORDINATOR                                 
        17 PX SEND QC (RANDOM) PARALLEL_TO_SERIAL SYS.:TQ10002                            
            16 BUFFER SORT PARALLEL_COMBINED_WITH_PARENT Cost: 626  Bytes: 35,803,043  Cardinality: 144,937                         
                15 UNION-ALL PARALLEL_COMBINED_WITH_PARENT                    
                    7 HASH JOIN PARALLEL_COMBINED_WITH_PARENT Cost: 314  Bytes: 7,803  Cardinality: 17                 
                        4 BUFFER SORT PARALLEL_COMBINED_WITH_CHILD            
                            3 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT Cost: 3  Bytes: 3,859  Cardinality: 17         
                                2 PX SEND BROADCAST PARALLEL_FROM_SERIAL SYS.:TQ10000 Cost: 3  Bytes: 3,859  Cardinality: 17     
                                    1 TABLE ACCESS FULL TABLE SUMMARY.NCR_ADJ_DATA Cost: 3  Bytes: 3,859  Cardinality: 17 
                        6 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD Cost: 310  Bytes: 33,625,384  Cardinality: 144,937             
                            5 TABLE ACCESS FULL TABLE PARALLEL_COMBINED_WITH_PARENT SUMMARY.OSFI_FEED_CORE_DATA Cost: 310  Bytes: 33,625,384  Cardinality: 144,937         
                    14 HASH JOIN RIGHT ANTI PARALLEL_COMBINED_WITH_PARENT Cost: 312  Bytes: 35,795,240  Cardinality: 144,920                 
                        11 BUFFER SORT PARALLEL_COMBINED_WITH_CHILD            
                            10 PX RECEIVE PARALLEL_COMBINED_WITH_PARENT Cost: 1  Bytes: 255  Cardinality: 17         
                                9 PX SEND BROADCAST PARALLEL_FROM_SERIAL SYS.:TQ10001 Cost: 1  Bytes: 255  Cardinality: 17     
                                    8 INDEX FULL SCAN INDEX SUMMARY.INDEX_2 Cost: 1  Bytes: 255  Cardinality: 17 
                        13 PX BLOCK ITERATOR PARALLEL_COMBINED_WITH_CHILD Cost: 310  Bytes: 33,625,384  Cardinality: 144,937             
                            12 TABLE ACCESS FULL TABLE PARALLEL_COMBINED_WITH_PARENT SUMMARY.OSFI_FEED_CORE_DATA Cost: 310  Bytes: 33,625,384  Cardinality: 144,937          There is no index on the tables and it contains lakhs of records.

Similar Messages

  • Peformance on complete refresh of a Materialized View

    We are currently doing a complete refresh of a materialized view (35 mil rows) on a monthly basis. My question is would it be faster to disable all the indexes prior to refresh? if so, should we enable the indexes or simply rebuild and which would be faster? Below is the package we are calling to refresh the MV. Also, our platform is Oracle 11g1 Rac on Solaris 10. Thanks.
    DBMS_MVIEW.REFRESH(MVIEW_NAME, 'C', ATOMIC_REFRESH => FALSE, PARALLELISM=>16);

    Trace it and see.
    With ATOMIC_REFRESH set to FALSE, Oracle would be doing a TRUNCATE. See if it does a Direct Path Insert. (It should be doing so).
    In which case, Index maintenance is deferred to the end.
    Yet, Oracle builds "temporary" index segments when doing the insert and merges them later.
    You might still get a performance benefit from setting the indexes to UNUSABLE (or DROPping them) and then doing a REBUID/CREATE with NOLOGGING and a different degree of Parallelism.
    You'd have to test it yourself and see what the difference is.
    Hemant K Chitale

  • Materialized View with OLAP table function

    Hi,
    I am trying to materialize OLAP cubes into relational materialized views which works quite fine. After a few loadings in background in parallel with Database Jobs and DBMS_MVIEW package the peformance is getting poor. Steps I am performing:
    1. Generate materialized view as DEFERRED and COMPLETE refresh
    2. Generate database Jobs for refreshing views with DBMS_MVIEW.REFRESH function
    3. Running Jobs in background
    I have loading times the first time 10min after then over 4 hours. I also tried with ATOMIC_REFRESH=FALSE but the same result. Database is running in ARCHIVE LOGGING. Can this degrade the performance?
    Any ideas?
    Thanks,
    Christian

    Hi,
    yes thats correct. I am creating MVs in 10.2.0.3
    Here is an example:
    CREATE MATERIALIZED VIEW "FCRSGX"."MV_F_ICCC_C11"
    ORGANIZATION HEAP PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 COMPRESS NOLOGGING
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
    TABLESPACE "FCRSGX_CONSO_RELATIONAL"
    BUILD DEFERRED
    USING INDEX
    REFRESH COMPLETE ON DEMAND
    USING DEFAULT LOCAL ROLLBACK SEGMENT
    DISABLE QUERY REWRITE
    AS SELECT ENTITY, REVE_ICC, RP_ICC, MV_ICC, PERIOD, MEASURE, AMOUNT, R2C
    FROM TABLE(OLAP_TABLE('FCRSGX.CONSODATA DURATION SESSION',
    DIMENSION ENTITY as varchar2(8) FROM ENTITY
    DIMENSION REVE_ICC as varchar2(8) FROM REVE_ICC
    DIMENSION RP_ICC as varchar2(8) FROM RP_ICC
    DIMENSION MV_ICC as varchar2(8) FROM MV_ICC
    DIMENSION PERIOD as varchar2(8) FROM GMONTH
    DIMENSION MEASURE as varchar2(30) FROM EXPR
    MEASURE AMOUNT as number FROM ICCC.C11
    LOOP CMPE.ICCC.C11
    ROW2CELL R2C '))
    WHERE OLAP_CONDITION(r2c, 'lmt entity to CMPE.ICCC.C11')=1
    AND OLAP_CONDITION(r2c, 'lmt reve_icc to CMPE.ICCC.C11')=1
    AND OLAP_CONDITION(r2c, 'lmt mmonth to sapload.per eq y')=1
    AND OLAP_CONDITION(r2c, 'lmt gmonth to charl(mmonth) ')=1
    AND OLAP_CONDITION(r2c, 'lmt rp_icc to CMP.ICCC.C11 ')=1
    AND OLAP_CONDITION(r2c, 'lmt mv_icc to CMP.ICCC.C11 ')=1
    AND OLAP_CONDITION(r2c, 'lmt expr to ''F.ICCC.C11'' ')=1
    MODEL
    DIMENSION BY(ENTITY,REVE_ICC,RP_ICC,MV_ICC,PERIOD,MEASURE)
    MEASURES(AMOUNT,R2C)
    RULES UPDATE SEQUENTIAL ORDER()
    ;

  • Refresh of materialized views slow

    Hi,
    This relates to a datawarehouse, used for a data migration (Oracle 11g).
    To refresh a set of materialized views I am using DBMS_MVIEW.REFRESH.
    However, it seems that refreshing the views is much slower( about 4 to 5 times slower) than dropping and re-creating them.
    Any thoughts on this?
    To speed up the refresh method, I truncate beforehand and this seems to help the peformance, but not by much.
    So, basically when I run:
    TRUNCATE TABLE MY_MVIEW;
    EXECUTE DBMS_MVIEW.REFRESH ('MY_MVIEW','C',PARALLELISM=>8,ATOMIC_REFRESH=>false);
    this is still about 3 times slower then;
    DROP MATERIALIZED VIEW MY_MVIEW;
    CREATE MATERIALIZED VIEW "MY_MVIEW"
    PARALLEL 8
    BUILD IMMEDIATE
    USING INDEX
    REFRESH FORCE ON DEMAND
    ENABLE QUERY REWRITE
    AS SELECT * FROM MY_TAB;
    Cheers.

    843217 wrote:
    So, basically when I run:
    TRUNCATE TABLE MY_MVIEW;
    EXECUTE DBMS_MVIEW.REFRESH ('MY_MVIEW','C',PARALLELISM=>8,ATOMIC_REFRESH=>false);
    this is still about 3 times slower then;
    DROP MATERIALIZED VIEW MY_MVIEW;
    CREATE MATERIALIZED VIEW "MY_MVIEW"
    PARALLEL 8
    BUILD IMMEDIATE
    USING INDEX
    REFRESH FORCE ON DEMAND
    ENABLE QUERY REWRITE
    AS SELECT * FROM MY_TAB;You use USING INDEX clause, that's why it is slower.
    But why don't use a fast refresh?
    your query quite simple and it allows to use fast refresh, not complete. Create MView log for MY_TAB and refresh only new/modified/deleted records.

  • Refresh/Update data in a materialized view

    Hi,
    I have question about the data in a materialized view and how it is refreshed. My mat view has all my dimension-ids and my (for my specialize needs) aggregated measures from my fact table. I used the mat view wizard to create my view - which works perfectly. But now I wonder if I have to create some sort of mapping(?) or some sort of trigger to refresh the data in the mat view. Or is the data automatically refreshed when I start my fact table mappings. I use OWB 11gR2
    thx

    MVs have properties for refresh - you an refresh based on schedules or when dependent data is committed or manually.
    Cheers
    David

  • 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

  • How to get Materialized View to ignore unused columns in source table

    When updating a column in a source table, records are generated in the corresponding materialized view log table. This happens even if the column being updated is not used in any MV that references the source table. That could be OK, so long as those updates are ignored. However they are not ignored, so when the MV is fast refreshed, I find it can take over a minute, even though no changes are required or made. Is there some way of configuring the materialized view log such that the materialized view refresh ignores these updates ?
    So for examle if I have table TEST:
    CREATE table test (
    d_id NUMBER(10) PRIMARY KEY,
    d_name VARCHAR2(100),
    d_desc VARCHAR2(256)
    This has an MV log MLOG$_TEST:
    CREATE MATERIALIZED VIEW LOG ON TEST with rowid, sequence, primary key;
    CREATE MATERIALIZED VIEW test_mv
    refresh fast on demand
    as
    select d_id, d_name
    from test;
    INSERT 200,000 records
    exec dbms_mview.refresh('TEST_MV','f');
    update test set d_desc = upper(d_desc) ;
    exec dbms_mview.refresh('TEST_MV','f'); -- This takes 37 seconds, yet no changes are required.
    Oracle 10g/11g

    I would love to hear a positive answer to this question - I have the exact same issue :-)
    In the "old" days (version 8 I think it was) populating the materialized view logs was done by Oracle auto-creating triggers on the base table. A "trick" could then make that trigger become "FOR UPDATE OF <used_column_list>". Now-a-days it has been internalized so such "triggers" are not visible and modifiable by us mere mortals.
    I have not found a way to explicitly tell Oracle "only populate MV log for updates of these columns." I think the underlying reason is that the MV log potentially could be used for several different materialized views at possibly several different target databases. So to be safe that the MV log can be used for any MV created in the future - Oracle always populates MV log at any update (I think.)
    One way around the problem is to migrate to STREAMS replication rather than materialized views - but it seems to me like swatting a fly with a bowling ball...
    One thing to be aware of: Once the MV log has been "bloated" with a lot of unneccessary logging, you may perhaps see that all your FAST REFRESHes afterwards becomes slow - even after the one that checked all the 200000 unneccessary updates. We have seen that it can happen that Oracle decides on full table scanning the MV log when it does a fast refresh - which usually makes sense. But after a "bloat" has happened, the high water mark of the MV log is now unnaturally high, which can make the full table scan slow by scanning a lot of empty blocks.
    We have a nightly job that checks each MV log if it is empty. If it is empty, it locks the MV log and locks the base table, checks for emptiness again, and truncates the MV log if it is still empty, before finally unlocking the tables. That way if an update during the day has happened to bloat the MV log, all the empty space in the MV log will be reclaimed at night.
    But I hope someone can answer both you and me with a better solution ;-)

  • Materialized View to run only once in a year...

    Hi everybody...
    I want to create a materialized view which will run only once in a year and specifically some minutes after 00:00 a.m. on new year's day,
    so i created the following:
    CREATE MATERIALIZED VIEW <mv_name>
    BUILD IMMEDIATE
    REFRESH START WITH TO_DATE('01/01/2007 00:15:00','DD/MM/RRRR HH24:MI:SS')
    NEXT SYSDATE+366
    I have two notes:
    1) how to declare the refresh to be done the first new year's day after the day it'll be created , i mean not static date (01/01/2007)
    2)some years are leap and some are not , so in order to run every new year's day how should i transform the above..????
    3)is there any view which displays the next run of a materialized view..???
    the view DBA_MV_REFRESH_TIMES displays the last refresh of mv's...
    I use Oracle 10.2.0.1 on XP ...
    Thanks , a lot
    Simon

    1).
    use the expression that evaluates to next january first.
    SQL> select sysdate, add_months(trunc(sysdate, 'yyyy'), 12) from dual ;
    SYSDATE     ADD_MONTHS(
    19-JUN-2006 01-JAN-2007
    1 row selected.
    SQL>2). for this also use the same expression that will evaluate to the january first of the year after that.

  • Is it possible to refresh the table from a Materialized view

    Hi,
    Is it possible to update the underlying table on which a Materialized view is created when some changes in a Materialized view is done.Is this reverse compatibility possible in Materialized View?
    Thanks in Advance,
    V.Dennis

    If you created the materialized view as UPDATEABLE then changes to it should automatically be relected in the underlying table. If this is not occurring I suggest you check the replication jobs. You probably have a stack of errors in DEFERROR.
    Cheers, APC

  • The data of my materialized view....in the while

    Hello
    We have problems with materialized views
    We have one wich re-build each a short period of time
    ¿Can i avoid the data to dissapear in the time process of refresh?
    Is so annoing to our clients to see that "from time to time" the data just dissapear for one period of time -the time while the materialized view is refreshing-
    Thank you in advance
    Bruno. Madrid. Spain

    > Is so annoing to our clients to see that "from time to time" the data just dissapear for
    one period of time -the time while the materialized view is refreshing-
    Have a similar problem. And dealing with large data volumes that makes the DELETE of the MV a very undesirable feature. Not as much a the resource footprint required, but the time it takes to do this - and the very tight processing windows that exist.
    The solution is a self-rolled and very likely not ideal for most - but it works well enough for us in production.
    No MV. Create a partition table. Create a staging table. Do a manual "full refresh" of the staging table (TRUNCATE and direct path INSERT). Follow this by a partition exchange with the partition table (no validation and including indexes). The result is that the data is replaced in the partitioned table within a second - no long running and expensive DELETE. End-users not effected by having a truncate pulling the data from beneath their reports.

  • Exporting data from a materialized view in Oracle 10g

    Can anybody tell me how to export data to a remote server and import data in that remote server without using ftp utility. Actually I want to export the data from a materialized view to the remote server and import the same in the remote server.
    If everything works well, I'll put the exporting and importing in a cronjob.
    Please let me know how can I do that if that's possible .
    Any reply would be appreciated.
    Thanks.

    Here is what I'm trying to do.
    I created materialized views using multiple base tables in my local server and the base tables got populated using a long process.
    Now I want to copy those data alone to some remote server since it doesn't have any base tables in it. For now, the remote server should depends on the localserver's data. I'm going to use the remote server's data for some testing purposes.
    I know it is easy to create mat.views in the remote server but it doesn't have I don't want to do that now. I just want to copy the snapshots from my local server to the remote server.
    Please let me know how to do that.
    Thanks.

  • Issue with creation of a materialized view

    Hi,
    I have a SQL query that works fine.
    But when I create a materialized view using the query, a few columns in the MV do not get populated at all.
    What could be the issue here?
    regards
    Prem

    Hi,
    Thanks for the reply. Here is the code.
    CREATE MATERIALIZED VIEW EDW.MV_OPPTY_ACTIVITY_AGG
    TABLESPACE EDW_DIM_DAT
    NOCACHE
    LOGGING
    NOCOMPRESS
    NOPARALLEL
    BUILD IMMEDIATE
    REFRESH COMPLETE ON DEMAND
    WITH PRIMARY KEY
    AS
    select
    OPPTY_ID OPPTY_ID,
    OPPORTUNITY_KEY OPPORTUNITY_KEY,
    oppty_number oppty_number ,
    SALES_CONSULTANT_HIST_KEY SALES_CONSULTANT_HIST_KEY ,
    company_add_source_key company_add_source_key,
    SALES_CONSULTANT_ID SALES_CONSULTANT_ID,
    ACTIVITY_TYPE ACTIVITY_TYPE ,
    activity_DATE activity_DATE ,
    LAST_MODIFIED_DATE LAST_MODIFIED_DATE ,
    CUSTOMER_FLAG CUSTOMER_FLAG,
    SALES_EMPLOYEE_HIST_KEY,
    milestone_KEY,
    oppty_milestone_name_hist stage_name,
    oppty_milestone_id_hist stage_id,
    milestone_prob prob_to_close,
    start_date oppty_start_date,
    oppty_close_date oppty_close_date,
    end_date oppty_end_date,
    sum(DURATION) TOTAL_DURATION,
    sum (CASE WHEN ACTIVITY_type IN ('CU14', 'CU15', 'CU16', 'CU17',
    'CU18', 'CU19', 'CU20', 'CU21') THEN DURATION ELSE 0 END ) CQM_DURATION,
    sum (CASE WHEN ACTIVITY_type = 'CU01' THEN DURATION ELSE 0 END ) TRADE_SEM_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU02' THEN DURATION ELSE 0 END ) RFP_RFI_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU03' THEN DURATION ELSE 0 END ) INFO_GATH_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU04' THEN DURATION ELSE 0 END ) PREP_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU05' THEN DURATION ELSE 0 END ) PRES_DEMO_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU06' THEN DURATION ELSE 0 END ) POC_DURATION,
    sum ( CASE WHEN ACTIVITY_type = 'CU07' THEN DURATION ELSE 0 END ) PRE_CUST_SUPP_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU08' THEN DURATION ELSE 0 END ) POST_CUST_SUPP_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU09' THEN DURATION ELSE 0 END ) PARTNER_SUPP_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU10' THEN DURATION ELSE 0 END ) TRAVEL_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU11' THEN DURATION ELSE 0 END ) KEYCODES_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU12' THEN DURATION ELSE 0 END ) SI_SUPP_DURATION,
    sum ( CASE WHEN ACTIVITY_type = 'CU13' THEN DURATION ELSE 0 END ) CHANNEL_SUPP_DURATION,
    sum( CASE WHEN ACTIVITY_type = 'CU23' THEN DURATION ELSE 0 END ) MIGRATION_DURATION ,
    max(LICENSE_USD) LICENSE_USD ,
    MAX(LICENSE_LOCAL) LICENSE_LOCAL,
    MAX(maintAINANCE_usd) maintAINANCE_usd,
    MAX(maintAINANCE_LOCAL) maintAINANCE_LOCAL,
    MAX(TRAINING_USD) training_usd,
    MAX(TRAINING_LOCAL) training_LOCAL,
    MAX(CONSULTING_USD) consulting_usd,
    MAX(CONSULTING_LOCAL) consulting_LOCAL,
    MAX(RENEWALS_USD) renewals_usd ,
    MAX(RENEWAL_local) RENEWAL_local,
    max(LOBANALYTICS2_LOCAL) epm_local,
    max(LOBDATAINTEGRATION2_LOCAL) eim_local,
    max(IDD_AMOUNT_LOCAL) idd_local,
    max(ONDEMAND_AMOUNT_LOCAL) ondemand_local,
    max(LOBANALYTICS2_usd) epm_usd,
    max(LOBDATAINTEGRATION2_usd) eim_usd,
    max(IDD_AMOUNT_usd) idd_usd,
    max(ONDEMAND_AMOUNT_usd) ondemand_usd
    FROM edw.sales_consulting_activity_fct t1 ,
    select
    o.oppty_id_number,
    o.oppty_id,
    O.OPPORTUNITY_KEY,
    LICENSE_USD LICENSE_USD ,
    LICENSE_LOCAL LICENSE_LOCAL,
    o.FYM_USD maintAINANCE_usd,
    o.FYM_LOCAL maintAINANCE_LOCAL,
    o.TRAINING_USD training_usd,
    o.TRAINING_LOCAL training_LOCAL,
    o.CONSULTING_USD consulting_usd,
    o.CONSULTING_LOCAL consulting_LOCAL,
    o.RENEWAL_USD renewals_usd ,
    o.RENEWAL_local RENEWAL_local ,
    o.LOBANALYTICS2_LOCAL,
    o.LOBANALYTICS2_usd,
    o.LOBDATAINTEGRATION2_LOCAL,
    o.IDD_AMOUNT_LOCAL,
    o.ONDEMAND_AMOUNT_LOCAL,
    o.LOBDATAINTEGRATION2_usd,
    o.IDD_AMOUNT_usd,
    o.ONDEMAND_AMOUNT_usd
    from edw.opportunity_hist_fact o
    where o.SOURCE_SYSTEM='SFDC'
    and upper(status)='ACTIVE'
    and o.last_modified_date = (select max(last_modified_date )from edw.opportunity_hist_fact o2 where o.opportunity_key = o2.opportunity_key))T2,
    ( Select activity_key,OPPTY_ID_NUMBER, MIL.milestone_KEY,MIL.milestone_name oppty_milestone_name_hist,milestone_id
    oppty_milestone_id_hist, milestone_prob,start_date,oppty_close_date,end_date FROM
    EDW.opportunity_hist_fact OPP,
    edw.milestone MIL,
    edw.sales_consulting_activity_fct act WHERE
    ACTIVITY_DATE >=start_date (+) and activity_date <=opp.last_modified_date(+)
    and OPP.OPPTY_ID_NUMBER (+) =act.OPPTY_NUMBER
    and OPP.milestone_key =MIL.milestone_key(+) ) T3
    where t1.oppty_NUMBER (+) =T2.OPPTY_ID_NUMBER
    and t1.activity_key=t3.activity_key
    --and oppty_number ='279749'
    GROUP BY OPPTY_ID,
    oppty_number,
    OPPORTUNITY_KEY,
    SALES_CONSULTANT_HIST_KEY ,
    company_add_source_key,
    SALES_CONSULTANT_ID,
    SALES_EMPLOYEE_HIST_KEY,
    ACTIVITY_TYPE ,
    ACTIVITY_DATE ,
    LAST_MODIFIED_DATE,
    CUSTOMER_FLAG,
    milestone_KEY,
    oppty_milestone_name_hist,
    oppty_milestone_id_hist,
    milestone_prob,
    start_date,
    oppty_close_date,
    end_date;
    Regards,
    Prem

  • Select query in materialized view with two dblinks

    Hi All,
    We have oracle 10g On windows.
    We are trying to create materialized view. Scenario is we have base table on other database and we are creating mview on different database.
    Basa database have two schema's and i am selecting records from that two schema's using two private db links.
    But when i am tryin gto create mview its not getting created. After 15 hrs. its still showing creation command and not finished.
    Query is :-
    Is it good practice to have two db links in select query of materialized view.

    Billy  Verreynne  wrote:
    Chanchal Wankhade wrote:
    Is it good practice to have two db links in select query of materialized view.Same db link being used twice, or two different db links?
    If the former, you ideally want the local Oracle db to send the join to the remote database, and for the remote database to drive the join between those 2 tables. There is a hint (<i>driving_site</i>) that can be used - or the join query can be defined on the remote database as a view, and the local materialised view can then use that remote view.
    If you have 2 different db links and joining across these - usually a bad idea to perform distributed database joins. There are lots of limitations as to how the tables can be joined. Worse case, full table scans of both remote tables, pulling all the rows from the 2 remote database tables to the local database, and joining these on the local database.
    I have seen some severe performance issues in the past as a result of distributed joins. I'll rather use 2 materialised views for pulling both distributed tables's data locally, and then do the join on local data (using indexes, partition pruning, etc)Hi Billy,
    My scenario is i have two database database A and database B. Database A is having two schema's SCOTT AND HR. SCOTT schema have select privileges on HR schema.
    DB LINK is between Database B to Database A. name is db.link.B.A.oracle.com.
    What if i priovide while creating materialized view, the schema name before the table name in database B for this particuler table so it will pick up the table from that schema using same DB LINK(db.link.B.A.oracle.com.) that i am using to fetch records from SCOTT schema.
    Above schnario is like two base schema's and one db link using two schema.

  • Leave a distinct value in a materialized view on two tables

    Hi and thank you for reading,
    I have the following problem. I am creating a materialized view out of two tables, with "where a.id = b.id".
    The resulting materialized view list several values twice. For example, one customer name has several contact details and thus the customer name is listed several times. Now I would like to join each customer name with just ONE contact detail, how can I do that? (Even if I would loose some information while doing this).
    Thanks
    Evgeny

    Hi,
    You can do this
    SELECT   deptno, empno, ename, job, mgr, hiredate, sal, comm
        FROM emp_test
    ORDER BY deptno;
        DEPTNO      EMPNO ENAME      JOB              MGR HIREDATE          SAL       COMM
            10       7782 CLARK      MANAGER         7839 1981-06-09       2450          
            10       7839 KING       PRESIDENT            1981-11-17       5000          0
            10       7934 MILLER     CLERK           7782 1982-01-23       1300          
            20       7566 JONES      MANAGER         7839 1981-04-02       2975          
            20       7902 FORD       ANALYST         7566 1981-12-03       3000          
            20       7876 ADAMS      CLERK           7788 1987-05-23       1100          
            20       7369 SMITH      CLERK           7902 1980-12-17        800          
            20       7788 SCOTT      ANALYST         7566 1987-04-19       3000          
            30       7521 WARD       SALESMAN        7698 1981-02-22       1250        500
            30       7844 TURNER     SALESMAN        7698 1981-09-08       1500          
            30       7499 ALLEN      SALESMAN        7698 1981-02-20       1600        300
            30       7900 JAMES      CLERK           7698 1981-12-03        950          
            30       7698 BLAKE      MANAGER         7839 1981-05-01       2850          
            30       7654 MARTIN     SALESMAN        7698 1981-09-28       1250       1400
    14 rows selected.
    SELECT CASE
              WHEN ROW_NUMBER () OVER (PARTITION BY deptno ORDER BY empno) =
                                                                         1
                 THEN deptno
           END deptno,
           empno, ename, job, mgr, hiredate, sal, comm
      FROM emp_test;
        DEPTNO      EMPNO ENAME      JOB              MGR HIREDATE          SAL       COMM
            10       7782 CLARK      MANAGER         7839 1981-06-09       2450          
                     7839 KING       PRESIDENT            1981-11-17       5000          0
                     7934 MILLER     CLERK           7782 1982-01-23       1300          
            20       7369 SMITH      CLERK           7902 1980-12-17        800          
                     7566 JONES      MANAGER         7839 1981-04-02       2975          
                     7788 SCOTT      ANALYST         7566 1987-04-19       3000          
                     7876 ADAMS      CLERK           7788 1987-05-23       1100          
                     7902 FORD       ANALYST         7566 1981-12-03       3000          
            30       7499 ALLEN      SALESMAN        7698 1981-02-20       1600        300
                     7521 WARD       SALESMAN        7698 1981-02-22       1250        500
                     7654 MARTIN     SALESMAN        7698 1981-09-28       1250       1400
                     7698 BLAKE      MANAGER         7839 1981-05-01       2850          
                     7844 TURNER     SALESMAN        7698 1981-09-08       1500          
                     7900 JAMES      CLERK           7698 1981-12-03        950          
    14 rows selected.Edited by: Salim Chelabi on 2009-09-14 08:13

  • Use of db sequence in a materialized view

    Hi,
    Will it be possible to use a database sequence in a materialized view?
    The materialized view is to return the result set of query that joins multiple tables. One of the columns in the result set - the to-be-created materialized view - is null and requires a sequence.
    Will it be possible to include a db sequence in the query?
    Example:
    create materialized view example_mview
    as
    select example_sequence.nextval, table1.'*', table2.'*'
    from example_table1 table1, example_table2 table2
    where table1.id=table2.id

    What is the purpose of such numbering? To number each row?
    If so - then use ROWNUM as 1st column.
    SQL>with ddd
           as
           (select 333 COL from dual union all select 5444 COL from dual)
           select rownum,COL from ddd;ROWNUM COL
    1 333
    2 5444

Maybe you are looking for

  • Flashing red Light on Photosmart D5160

    I have a 3-4 year old Photosmart which know suddenly comes with flashing red light when i try to print. In the display it says ERR and there are two commas or something on the bottom right. It does not match any of the problems which i can find on hp

  • BPEL Database Adapter data to B2B TP

    Hi SOA/BPEL Experts In BPEL How we are going to Map my Data base data ie which i got from Database Adapter to the Partner Link Adapter Service Trading Partner Data for ex EDI, X12 V4010 210's. My Database data which i want to send to the Partner <---

  • OSB Proxy Service routing

    Hi, I have a simple Proxy Service which consumes messages from a remote endpoint queue (source queue). The Proxy Service simply routes consumed messages to a Business Service which puts messages into another remote endpoint queue (destination queue).

  • How to setup IOS DHCP server for redundancy?

    Hi The customer has 2 core (cat6). Plan to enable DHCP service on them for IP phones. How to setup them so there is a redundancy for DHCP service? Thanks in advance!

  • Active X and something machine?

    My cousin has a web cam and it will not work and he thinks i need to get active X and something machine? i dont really remember but there are so many java's i dont know what to pick... can someone help me? am i even looking for the right things? wher