Materialised view construct

Hi all,
I have some queries that do a lot of calculations based on year passed from front-end.
I am unable to figure out how could i use a materialised view so that calaculations should be done on current data rather than the entire data.
As calculations are done based on date passed from front-end,How to convert such queries to a materialised view?
Here is a sample query :
select mjcd,desc1,
bm.amt,
nvl(sum(case when to_char(v_date,'RRRR')||
    lpad(to_char(v_date,'MM'),2,'0')='200710'
     then gross_amt end),0)monthly_amt,
nvl(sum(gross_amt),0)progressive
   from v_billent be,mjhd mj
,v_bm bm
   where v_date>='01-MAR-07' and v_date<='30-OCT-07'
   and mjcd>='2011'
and bm.fin_year='20072008'
  and mj.mjcd=be.src_mjcd(+)
  and bm.h_code(+)=mj.mjcd
   group by mjcd,desc1
,bm.amtorder by 1
Kindly guide how can I use advantage of a materialised view?
Thanks

Materialized view are greatly used to increase the performance of pre existing aggregate queries.
See a small example below.
SQL> create table t
  2  as
  3  select * from all_objects
  4  /
Table created.
SQL> exec dbms_stats.gather_table_stats('SYSADM','T')
PL/SQL procedure successfully completed.Now i want to execute a query like this.
SQL> explain plan for
  2  select object_type, count(1)
  3    from t
  4  group by object_type
  5  /
Explained.
SQL> set linesize 250
SQL>
SQL> select * from table(dbms_xplan.display)
  2  /
PLAN_TABLE_OUTPUT
Plan hash value: 47235625
| Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT   |      |    21 |   168 |   374   (7)| 00:00:05 |
|   1 |  HASH GROUP BY     |      |    21 |   168 |   374   (7)| 00:00:05 |
|   2 |   TABLE ACCESS FULL| T    |   117K|   914K|   358   (2)| 00:00:05 |
9 rows selected.Lets say over a period of time the data in table T has increased so much and
i am facing a big performance problem. so to over come that i create a Materialized
view.
SQL> create materialized view t_mv
  2  enable query rewrite
  3  as
  4  select object_type, count(1)
  5    from t
  6  group by object_type
  7  /
Materialized view created.Now when is issue the same query see what happens
SQL> delete from plan_table
  2  /
4 rows deleted.
SQL> explain plan for
  2  select object_type, count(1)
  3    from t
  4  group by object_type
  5  /
Explained.
SQL> select * from table(dbms_xplan.display)
  2  /
PLAN_TABLE_OUTPUT
Plan hash value: 139569370
| Id  | Operation                    | Name | Rows  | Bytes | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT             |      |    31 |   744 |     3   (0)| 00:00:01 |
|   1 |  MAT_VIEW REWRITE ACCESS FULL| T_MV |    31 |   744 |     3   (0)| 00:00:01 |
Note
PLAN_TABLE_OUTPUT
   - dynamic sampling used for this statement
12 rows selected.
SQL>instead of picking from my base table T it goes for the materialized view T_MV.
And check out the cost it got reduced drastically.
There is lot more than what i have said about materialized view. You can read the doc
for more info.

Similar Messages

  • Same Code in ordinary view and Materialised View is performing differentl

    I am currently working on a Data Warehouse Project hooked off the back of an accounting system. It takes data from an old system and data from a new system and uses both for Corporate Reporting.
    For Historical and Legacy Reporting reasons it is necessary to keep the Transaction Codes in the system at three characters. so anything that occurs that is less than three characters is padded to the left with zero's.
    The line of code that does this is ...
    CAST(LPAD(TRIM(TransactionCode),3,0) AS VARCHAR2(3)) AS TransactionCode
    There are then 2 Views.
    The first is a Materialised View, this contains 21 days worth of data for short term reporting and manipulation. In here this code seems to work perfectly.
    The second is an ordinairy real time View that spans all data available, within here the Transaction Codes are not padded, but remain at their random 1 or 2 digit lengths.
    In both views the field is defined as a VARCHAR2(3)
    This is not a data issue, as the 21 days will fall within the ordinairy view and there are no examples in the ordinary view of this working.
    The only thing that I can think of is if the character that is used for padding in the LPAD statement needs to be in quotes, I will try this, but I dont get why this would work in a Materialised View and not a View.
    Can anyone shed any light on why this might occur ???
    Many Thanks in advance
    Regards
    Craig Golby
    Dignitas Ltd
    http://www.dignitas.ltd.uk

    I am currently working on a Data Warehouse Project hooked off the back of an accounting system. It takes data from an old system and data from a new system and uses both for Corporate Reporting.
    For Historical and Legacy Reporting reasons it is necessary to keep the Transaction Codes in the system at three characters. so anything that occurs that is less than three characters is padded to the left with zero's.
    The line of code that does this is ...
    CAST(LPAD(TRIM(TransactionCode),3,0) AS VARCHAR2(3)) AS TransactionCode
    There are then 2 Views.
    The first is a Materialised View, this contains 21 days worth of data for short term reporting and manipulation. In here this code seems to work perfectly.
    The second is an ordinairy real time View that spans all data available, within here the Transaction Codes are not padded, but remain at their random 1 or 2 digit lengths.
    In both views the field is defined as a VARCHAR2(3)
    This is not a data issue, as the 21 days will fall within the ordinairy view and there are no examples in the ordinary view of this working.
    The only thing that I can think of is if the character that is used for padding in the LPAD statement needs to be in quotes, I will try this, but I dont get why this would work in a Materialised View and not a View.
    Can anyone shed any light on why this might occur ???
    Many Thanks in advance
    Regards
    Craig Golby
    Dignitas Ltd
    http://www.dignitas.ltd.uk

  • RDB, Oracle 9i and Materialised Views

    Hi all,
    I have a RDB 7.1.5.9.1 and an Oracle 9.0.1.4.0 database and the data from the RDB has to be available for queries in Oracle Discoverer. There is a 1Gb (fixed) line between the databases. I have created a database link and that is working fine.
    The RDB is used 24h a day and it is very important that there are no performance problems. I do not think that a 1-on-1 recreation of the data model of the RDB in the Oracle database (with the use of the database link) is the answer. The advantage is of course that the data is always up to date, but when multiple queries are started in Oracle Discoverer I think we have a problem. And the users are used to the fact that the data is not refreshed during the day, so that isn’t an issue.
    So I was thinking of using Materialised Views. Because RDB doesn’t understand Materialised View Logs I can only do a complete refresh of these Materialised Views in Oracle. I can spread the time in which these are refreshed, but I only got about 1 hour (from 7 AM to 8 AM) to refresh about 1200Mb (that is not a lot), but in the future there will be an increase in the amount that has te be refrshed.
    Does anybody know what a complete refresh will do to the performance of the RDB?
    And what happens if someone is querying on a Materialised View during a refresh?
    Of course, any other ideas are more then welcome. I am also considering the use of triggers in the RDB to INSERT-UPDATE-DELETE the data in Oracle and the use of LogMinor, although this last option is a tricky one because the Redo-statements contain rowid’s except from the INSERT statements.
    Thanks!

    in oracle9i database you can create materialized views with logs option but it works only under certain conditions. there is another option in oracle9i database of materialized views in which you can use time refresh.you specify time period after which your database refrsh automatically.
    Yes freshing of materialized view cause performance cost on the server but it is only for time based refresh.as well as concern to the queries their is no problem with them when m-vies is in refresh state.oracle's own infrastructure can handel it.

  • Materialised view not getting refreshed.

    Hi All
    I have created a Materialised view which looks at the master tables in another database... using a DB link. I use to have the refresh force option in the materialised view.. I recieve no error messages when I create DB link, create Mview and I can refresh the Mview manually.. but the auto refresh is not happening... for some reason.. Database version is 10.2.0.1 Standard Edition on Solaris 10 OS.
    Below are the scripts I have used to create DB link and MView... Please do let me know if I am missing any detail.. in particular.. what could be the issue/miss here thats avoiding the auto refresh of MView.
    Thank you in advance.
    Sarat.
    DB LINK :
    create public database link FBS_DB_LINK.REGRESS.RDBMS.DEV.US.ORACLE.COM connect to FBSUSER20 identified by <pwd> using 'FBSTEST'
    Materialized View :
    CREATE MATERIALIZED VIEW TWPERFUSER.CASE_DETAILS
                    PCTFREE 10 PCTUSED 0 INITRANS 2 MAXTRANS 255
                    STORAGE(
                                    INITIAL 64 K
                                    MINEXTENTS 1
                                    MAXEXTENTS UNLIMITED
                                    PCTINCREASE 0
                                    BUFFER_POOL DEFAULT
    TABLESPACE USERS
    LOGGING
    NOCACHE
    NOPARALLEL
    USING INDEX     PCTFREE 10 INITRANS 1 MAXTRANS 255
                    STORAGE(
                                    BUFFER_POOL DEFAULT
    REFRESH FORCE
                    WITH ROWID
    USING DEFAULT LOCAL ROLLBACK SEGMENT
    DISABLE QUERY REWRITE AS
    select  frc.reg_case_id,fp.provider_id,fptm.name,fp.provider_name,flam.authority_name,fp.creation_date,fp.multicentre_flag,
                                                    fp.commercial_for_profit_flag,fp.three_month_programmes_flag,frcsm.long_form,frcsm.short_form
                                    from
                                                    fbs_provider@FBS_DB_LINK fp,
                                                    fbs_provider_type_mst@FBS_DB_LINK fptm,
                                                    fbs_reg_case@FBS_DB_LINK frc,
                                                    fbs_reg_case_status_mst@FBS_DB_LINK frcsm,
                                                    fbs_address@FBS_DB_LINK fa,
                                                    fbs_local_authority_mst@FBS_DB_LINK flam
                                    where
                                                          frc.provider_id = fp.provider_id
                                           and    fp.provider_type_id = fptm.provider_type_id
                                           and    fp.address_id = fa.address_id
                                           and    fa.local_authority_id = flam.local_authority_id

    Hi,
    REFRESH FORCE
    As per my knowledge
    REFRESH COMPLETE NEXT <date>
    else check for the job status
    select job, what, last_date, last_sec, this_date, this_sec, next_date, next_sec, failures, broken from user_jobs ;
    Thanks
    Pavan Kumar N

  • Should I use materialised view?

    I am using the following sql in my code. This takes a long time to execute and I need to tune this. Please review and suggest if I should be using a materialized view instead.
    Main Select statement for interest calculation
    SELECT          intratechgcur.SECURITY, intratechgcur.srl_no, intratechgcur.schg_type,
         CASE WHEN intratechgcur.effective_date < ADt_Start_Date THEN ADt_Start_Date
                             ELSE intratechgcur.effective_date END AS start_date,
         CASE WHEN intratechgcur.effective_date < ADt_End_Date
                             AND NVL(intratechgnext.effective_date, ADt_End_Date) > ADt_End_Date THEN ADt_End_Date
                             ELSE NVL(intratechgnext.effective_date, ADt_End_Date) END AS end_date,
                        intratechgcur.rate, intratechgcur.face_value, intratechgcur.listing_int, intratechgcur.comm_prod_int,
                        intratechgcur.sec_create_int, intratechgcur.int_type, intratechgcur.interest_key, intratechgcur.margin,
                        intratechgcur.FLOOR, intratechgcur.cap, intratechgcur.reset_freq, intratechgcur.cmpd_y_n, intratechgcur.cmpd_freq,
                        intratechgcur.comp_type, intratechgcur.int_day, intratechgcur.int_day_1, intratechgcur.int_day_2, intratechgcur.int_dtls_yn
    FROM               v_intratechg intratechgcur, v_intratechg intratechgnext
    WHERE               intratechgcur.SECURITY          = AS_Security
    AND          intratechgcur.effective_date < ADt_End_Date
    AND               intratechgnext.SECURITY          (+)= intratechgcur.SECURITY
    AND               intratechgnext.srl_no          (+)= intratechgcur.srl_no + 1
    ORDER BY      intratechgcur.SECURITY, intratechgcur.effective_date, intratechgcur.srl_no ;
    The code for the view V_intratechg is;
    CREATE OR REPLACE VIEW V_INTRATECHG AS
    SELECT     security,
         schg_type,
         effective_date,
         SUM(1) over (PARTITION BY security ORDER BY security, effective_date ASC, schg_type ASC) AS srl_no,
         face_value,
         rate,
         listing_int,
         comm_prod_int,
         sec_create_int,
         int_type,
         interest_key,
         margin,
         FLOOR,
         cap,
         NVL(reset_freq, 'DAILY') AS reset_freq,
         NVL(cmpd_y_n, 'N') AS cmpd_y_n,
         NVL(cmpd_freq, 'DAILY') AS cmpd_freq,
         NVL(comp_type, 'N') AS comp_type,
         int_day, int_day_1, int_day_2, int_dtls_yn
    FROM
         (SELECT     security.security, 'IM' AS schg_type,
              GREATEST(security.prv_int_dt, NVL(security.allot_date, security.prv_int_dt),
              NVL(security.first_int_date,security.prv_int_dt)) AS effective_date,
              DECODE(intday.int_day_1, 'ACD', NVL((SELECT interest_amt FROM securityschddtls A WHERE security.security = A.security
              AND A.adhoc_schd_date > GREATEST(security.prv_int_dt, NVL(security.allot_date, security.prv_int_dt),
              NVL(security.first_int_date,security.prv_int_dt))
              AND a.rectype ='L' AND A.ADHOC_SCHD_DATE = (SELECT MIN(ADHOC_SCHD_DATE) FROM securityschddtls
    WHERE      securityschddtls.adhoc_schd_date > GREATEST(security.prv_int_dt, NVL(security.allot_date, security.prv_int_dt), NVL(security.first_int_date,security.prv_int_dt))
         AND securityschddtls.security = A.security AND securityschddtls.rectype='L')),
              NVL(secchg.rate, security.interest)), NVL(secchg.rate, security.interest)) AS rate,
              NVL(secchg.face_value, security.face_value) AS face_value,
              NVL(secchg.listing_int, security.listing_int) AS listing_int,
              NVL(secchg.comm_prod_int, security.comm_prod_int) AS comm_prod_int,
              NVL(secchg.sec_create_int,security.sec_create_int) AS sec_create_int,
              NVL(secchg.int_type, security.int_type) AS int_type,
              NVL(secchg.interest_key, security.interest_key) AS interest_key,
              NVL(secchg.margin, security.margin) AS margin,
              NVL(secchg.FLOOR, security.FLOOR) AS FLOOR,
              NVL(secchg.cap, security.cap) AS cap,
              NVL(secchg.reset_freq, security.reset_freq) AS reset_freq,
              NVL(secchg.cmpd_y_n, security.cmpd_y_n) AS cmpd_y_n,
              NVL(secchg.cmpd_freq, security.cmpd_freq) AS cmpd_freq,
              NVL(secchg.comp_type, security.comp_type) AS comp_type,
              NVL(secchg.int_day, security.int_day) AS int_day, intday.int_day_1,
              intday.int_day_2, 'Y' AS int_dtls_yn
              FROM          security, assetype, intday, securityschddtls secdtls,
                        (SELECT     secchg.security AS security, secchg.call_date AS effective_date,
                        NVL(secchg.rate,0) AS rate, secchg.face_value,
                        SUM(1) over (PARTITION BY secchg.security ORDER BY secchg.security,
                        secchg.call_date ASC) AS srl_no,
                        NVL(secchg.listing_int,0) AS listing_int, NVL(secchg.comm_prod_int,0) AS comm_prod_int,
                        NVL(secchg.sec_create_int,0) AS sec_create_int,
                        secchg.int_type, secchg.interest_key,
                        nvl(secchg.margin,0) as margin, nvl(secchg.FLOOR,0) as floor,
                        nvl(secchg.cap,0) as cap, secchg.reset_freq,
                        secchg.cmpd_y_n, secchg.cmpd_freq, secchg.comp_type, secchg.int_day FROM          secchg) secchg
              WHERE          security.asset_type     = assetype.asset_type
                   AND          security.int_day          = intday.int_day
                   AND          assetype.int_y_n           = 'Y'
                   AND          security.rectype          = 'L'
                   AND          assetype.rectype          = 'L'
                   AND          intday.rectype               = 'L'
                   AND          secchg.security (+)= security.security
                        AND          secchg.srl_no (+)= 1
                        AND          secdtls.security (+)= security.security
                        AND          secdtls.srl_no (+)= 1
                        AND          secdtls.rectype (+)= 'L'
              UNION ALL
              SELECT     schedules.security,
                   DECODE(schedules.schd_past_yn, 'Y', 'RP', 'RS') AS schg_type,
                   DECODE(intday.int_day_1, 'ACD',security_cashflow.start_date,security_cashflow.inflow_date) AS effective_date,
                   --commented by vijai
                   -- DECODE(intday.int_day_1, 'ACD', intschdamt.amount, NVL(intratechg.rate,security.interest)) AS rate,
                   DECODE(intday.int_day_1, 'ACD', intschdamt.amount,decode(security_cashflow.start_Date,intratechg.value_Date, intratechg.rate, security.interest)) as rate,
                   decode(nvl(schedules.tot_face_value - schedules.cum_face_value,security.face_value),0,security.face_value,schedules.tot_face_value - schedules.cum_face_value,security.face_value) AS face_value,
                   NVL(intratechg.listing_int,security.listing_int) as listing_int,
                   NVL(intratechg.comm_prod_int,security.comm_prod_int) as comm_prod_int,
                   NVL(intratechg.sec_create_int,security.sec_create_int),
                   NVL(intratechg.int_type,security.int_type) as int_type,
                   nvl(intratechg.interest_key,security.interest_key) as interest_key,
                   nvl(intratechg.margin,security.margin) as margin,
                   nvl(intratechg.FLOOR,security.floor) as floor,
                   nvl(intratechg.cap,security.cap) as cap,
                   nvl(intratechg.reset_freq,security.reset_freq) as reset_freq,
                   nvl(intratechg.cmpd_y_n,security.cmpd_y_n) as cmpd_y_n,
                   nvl(intratechg.cmpd_freq,security.cmpd_freq) as cmpd_freq,
                   nvl(intratechg.comp_type,security.comp_type),
                   nvl(intratechg.int_day,security.int_day),
                   intday.int_day_1, intday.int_day_2,
                   DECODE(intratechg.security, NULL, 'N', 'Y') AS int_dtls_yn
              FROM     v_schedules schedules, security, intday, intratechg, v_schedules intschdamt, security_cashflow
              WHERE     schedules.security          = security.security
              AND          schedules.red_yn      = 'Y'
              AND          security.int_day               = intday.int_day
              AND          security.rectype               = 'L'
              AND          intday.rectype                    = 'L'
              AND          intratechg.security (+)= schedules.security
              AND          intratechg.value_date(+)= schedules.schd_date
              AND          intratechg.rectype     (+)= 'L'
              AND          intschdamt.security (+)= schedules.security
              AND          intschdamt.schd_date (+)= schedules.schd_date
              AND          intschdamt.red_yn (+)= 'N'
              AND           security_cashflow.inflow_type      = 'INT'
              AND           security_cashflow.inflow_date     = schedules.schd_date
              AND           security.security               = security_cashflow.security
              AND           schedules.security          = security_cashflow.security
              UNION ALL
              SELECT     intratechg.security, 'IR' AS schg_type,
                   intratechg.value_date AS effective_date,
                   NVL(intratechg.rate,security.interest),
                   security.face_value,
                   NVL(intratechg.listing_int,security.listing_int),
                   NVL(intratechg.comm_prod_int,security.comm_prod_int),
                   NVL(intratechg.sec_create_int,security.sec_create_int),
                   nvl(intratechg.int_type,security.int_type),
                   nvl(intratechg.interest_key,security.interest_key),
                   nvl(intratechg.margin,security.margin),
                   nvl(intratechg.FLOOR,security.floor),
                   nvl(intratechg.cap,security.cap),
                   nvl(intratechg.reset_freq,security.reset_freq),
                   nvl(intratechg.cmpd_y_n,security.cmpd_y_n),
                   nvl(intratechg.cmpd_freq,security.cmpd_freq),
                   nvl(intratechg.comp_type,security.comp_type),
                   nvl(intratechg.int_day,security.int_day),
                   intday.int_day_1, intday.int_day_2, 'Y' AS int_dtls_yn
              FROM     intratechg, security, intday
              WHERE     intratechg.security          = security.security
              AND     security.int_day               = intday.int_day
              AND     intratechg.rectype          = 'L'
              AND     security.rectype               = 'L'
              AND     intday.rectype                    = 'L'
              AND     NOT EXISTS     (SELECT     1 FROM          v_schedules schedules
                             WHERE          schedules.security     = intratechg.security
                             AND          schedules.schd_date     = intratechg.value_date
                             AND          schedules.red_yn          = 'Y'))
              ORDER BY security, srl_no
    The code for the view V_schedules is;
    CREATE OR REPLACE VIEW V_SCHEDULES AS
    SELECT schdall.security,
              schdall.schd_date,
              schdall.schd_type,
              schdall.percent,
              schdall.units_o,
              schdall.units_n,
              schdall.amount,
              schdall.sequences,
    schdall.act_sch_dt,
         schdall.security_n,
              schdall.prior_act,
         schdall.red_amount,
              schdall.ben_refer,
         schdall.round_method,
    schdall.round_dec,
    schdall.average_y_n,
         schdall.schd_past_yn,
         CASE WHEN schd_type IN(sysschd.red, sysschd.disred) THEN 'Y' ELSE 'N' END AS red_yn,
         SUM( CASE WHEN schd_type IN(sysschd.red, sysschd.disred) THEN schdall.red_amount ELSE 0 END)
                                  over(PARTITION BY schdall.security) AS tot_face_value,
    SUM( CASE WHEN schd_type IN(sysschd.red, sysschd.disred) THEN schdall.red_amount ELSE 0 END)
                                  over(PARTITION BY schdall.security
                                       ORDER BY schdall.security, schdall.schd_date ASC) AS cum_face_value,
         SUM( CASE WHEN schd_type IN(sysschd.red, sysschd.disred) THEN schdall.red_amount ELSE 0 END)
                                       over(PARTITION BY schdall.security
                                       ORDER BY schdall.security, schdall.schd_date DESC) AS to_be_redeemed ,
              SUM(CASE WHEN schd_type =sysschd.INT THEN 0 ELSE 1 END)
                                       over(PARTITION BY schdall.security,schdall.schd_date,schd_type)
                             AS no_of_schd
    FROM
                   (SELECT      schedules.security_o AS security,
                                  schedules.schd_date,
                                  schedules.schd_type,
                                  schedules.percent,
                                  schedules.units_o,
                                  schedules.units_n,
                                  schedules.amount,
                                  schedules.sequences,
                                  schedules.act_sch_dt,
                                  schedules.security_n,
                                  schedules.prior_act,
                                  schedules.red_amount,
                                  schedules.ben_refer,
                                  schedules.round_method,
                                  schedules.round_dec,
                                  schedules.average_y_n,
                                  DECODE(schedules.schd_type,'RED','Y','Y') AS schd_past_yn
              FROM           schdpast schedules
              WHERE           prior_act = 'A'
              AND                rectype = 'L'
              UNION ALL
              SELECT           schedules.security_o AS security,
                                  schedules.schd_date,
                                  schedules.schd_type,
                                  schedules.percent,
                             schedules.units_o,
                   schedules.units_n,
                             schedules.amount,
                        schedules.sequences,
                        schedules.act_sch_dt,
                   schedules.security_n,
                   schedules.prior_act,
                        schedules.red_amount,
                        schedules.ben_refer,
                   schedules.round_method,
                   schedules.round_dec,
                   schedules.average_y_n,
                        'N' AS schd_past_yn
              FROM           schedules
              WHERE           prior_act = 'A'
              AND                rectype = 'L'
              AND                Process_date IS NULL ) schdall,
              (SELECT           MAX(redschdtype) AS red,
                             MAX(disredtype) AS disred,
                                  MAX(intschdtype) AS      INT
                                  FROM sysparamschd
              WHERE rectype = 'L') sysschd
    ORDER BY security, schd_date, schd_type

    Too much SQL... makes me eyes hurt.
    I think you're running down the wrong alley here. The very first and fundamental principle of performance tuning is identifying the performance problem. Saying that there is a problem is not identifying the actual problem.
    You cannot run down the alley with a knife looking for a performance problem to kill if you do not know how it looks like. Good that you are running though - the old Klingon saying of "a running warrior can slit more throats" hold very true. :-)
    Why is the existing SQL slow? You first need to identify that. Sure, a materialised view can make the end-query much faster as it has no longer to do all the work - that has now been done in batch by a DBMS_REFRESH job updating and maintaining that materialised view. But that work is still done... so have you actually fixed the cause of the performance problem, or merely hid it by addressing the symptoms?
    How does one find and identify the underlaying performance problem with too-much-SQL-that-makes-Billy's-eyes-hurt? Software Engineering 101. Take any complex problem. Break it down into lots of smaller little problems. Solve each on in turn.
    Take the SQL, break it down into simpler pieces and check each for performance issues. Look at the execution plan and cost. Determime if you (via the physical db design) are providing optimal I/O paths to the CBO in order for it to get to the required data with as little I/O as possible.
    Once you deal with the facts, you can make an informed decision or whether or not a materialised view will actually fix the cause of the performance problem.

  • What is the use of materialised view in ORACLE

    Hi All,
    What is the use of Materialised view in ORACLE.Can anyone please help me out by giving a real time example in banking application (How MV is used in banking applications).
    Thanks & Regards,
    SB2013

    SB2013 wrote:
    What is the use of Materialised view in ORACLE.Can anyone please help me out by giving a real time example in banking application (How MV is used in banking applications).http://docs.oracle.com/cd/E11882_01/server.112/e25789/schemaob.htm#CNCPT411
    Just add for example in a banking application at the end of each paragraph
    E.g.
    >
    In data warehouses, you can use materialized views to compute and store data generated from aggregate functions such as sums and averages, for example in a banking application

  • OLAP on 11g and Materialised Views with Multiple Value-Based Hierarchies

    Hello OLAPians
    I am trying to setup Orable BIEE to report on an OLAP cube with pre-aggregated data. As OBIEE is not able to hook into the OLAP directly i have to create an SQL cubeview.
    Currently i am on a 10g OLAP environment and am using the oracle sample SQL cubeview generator to create an SQLview of my cube.
    The cube itself has multiple dimensions and these dimensions have multiple VALUE-based (ragged) hierarchies and dimension members can be shared across hierarchies also.
    Initially i had a problem running the view generator plugin because there is a bug within it that does not finish if there are multiple value-based hierarchies present. I was able to get around this by manually editing the limitmap for the cubeview and manually creating the SQL view.
    The question that i want to ask is how robust is the 11g materialised views with multiple value-based hierarchies and the sharing of dimension members across different hierarchies?
    Has anyone successfully been able to create a cubeview and import it into OBIEE without the hassle of manually editing the limitmap?
    A problem arises with the value-based setup whereby if the client creates a newer depth in the ragged hierarchy, i need to manually create the limitmap and the cube-view over again, and then re-map the BI Administration mappings.

    The simple answer to your question,
    how robust is the 11g materialised views with multiple value-based hierarchies...?is that materialized views are not supported on top of value-based hierarchies in 11g. The reason is that it is not possible to write a reasonable SQL statement that aggregates a fact over a value-based hierarchy. Such a SQL statement is necessary if we want to create a rewritable MV on top of the cube.
    But I suspect this is not what you are really asking. If you are trying to set up OBIEE on top of the cube in 10g using the view generator, then you will probably want to use the "ET VIEWS" that are generated automatically in 11g. These are generated whether or not you enable materialized views on top of your cube. I am not aware of any issues with the generated value-based hierarchy view support in 11g. Members may be shared between value hierarchies and you will not need to generate or modify limit maps.

  • Materialised view runs for ever ...

    Hi
    I'd appreciate if someone could shine some light on an issue I'm having with a materialised view.
    I inherited this when I came into my current project, so before you ask me why tables are not partitioned or why a MV is being used for such a scenario, the answer is I don't know!!
    Anyway ... I'm using "Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod" running on SUSE ...
    There are a number of normalised tables two of which contain in the region of 400million rows each and tend to grow at the rate of 27000 rows per day.
    There's a materialised view (for the purposes of providing fast interactive reporting) that is setup as a normal join between 4 tables; the above two and the other two are just basic dictionary type lookups each containing around 100 or so rows.
    SELECT .... FROM LargeTable1, LargeTable2, Lookup3, Lookup4 WHERE Lookup3.ID=LargeTable1.LID and LargeTable2.ID=LargeTable1.ID and LargeTable2.LID=Lookup4.ID ;
    Running a FULL refresh on the MV failes with a 'ora-01555 snapshot too old' error after about 5 days!! Then takes around the same amount of time to rollback. Can't do a FAST refresh, I think because logs and/or mv indecies are out of sync.
    Table space is 63% full and undo space is set to auto-extend.
    I've tried /*+RULE */ but that doesn't seem to make a huge difference.
    Why does it take so long? Why does it fail? What can I do to speed it up?
    Thanks in advance for your assistance.
    Edited by: 883758 on Sep 7, 2011 2:16 PM

    You should approach this as a SQL tuning exercise, without the ability to change the query itself.
    Are table statistics up to date? Look at the execution plan – does it look reasonable for you? Are there any indexes that can help? (I am thinking covering indexes on the large tables …)
    Iordan Iotzov
    http://iiotzov.wordpress.com/

  • Error in refreshing materialised view

    Could anyone help me with this error?
    When I am trying to refresh this materialised view, I am getting this error.
    Materialised view is built properly.
    BEGIN dbms_mview.refresh('ITAM.ITAM_SW_LICENSES_ASSIGNED_MV', 'C'); END;
    ERROR at line 1:
    ORA-12008: error in materialized view refresh path
    ORA-04030: out of process memory when trying to allocate 56 bytes
    (callheap,qerrmbv[]: qerrmObnd)
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2566
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2779
    ORA-06512: at "SYS.DBMS_SNAPSHOT", line 2748
    ORA-06512: at line 1
    Thanks in advance.

    Hi
    Try like this...
    SQL> exec dbms_snapshot.refresh('<SNAPSHOT_NAME>','C'); 
    snapshot_name means materialized view nameKPR

  • Insufficient priv error when creating a materialised view using DB link!!!!

    Hi,
    I have a two databases db1 and db2.
    I have created a database link from db2 to access user1 schema in db1.
    When i try to create a materialised view by accessing user1 table using user 'user2' in db2 database, i get error "ORA-1031: Insufficient Privilege".
    The user2 has the priviliges "create view", "create any view", "create materialised view" etc.
    I am able to select data, of the table using the database link, but creating materialised view gives this error.
    I want to know if the user "user1" should be granting any privilige to user2, if so how is it possible as user2 dosent exist in db1!
    i.e should i give command something like "grant select on user1.table to user2@db2"(this dosent work as it says user2@db2 dosent exist, obviously as its taking user2@db2 as a username in db1 schema)
    or is this a problem with user2 priviliges in db2 database, if so what are all the priviliges that have to be given to user2 in db2 schema.
    regards,

    Hi,
    User from db1 can not assign any privs to user on db2 database. If user from db1 want to access any object from db2 database, then on local level user2 on db2 should have all the acess to required object. Then you can use user2 on db2 using dblink from db1 user to access those objects residing on remote database.
    If user1 from db1 can grant privs to user2 on db2 database on any objects on db2 database then it is highly security issue. This is not permitted.
    Regards
    e.g.
    conn userx@db2
    grant select on userx.table1 to user2;
    conn user2@db2
    select count(*) from userx.table1;
    conn user1@db1
    select count(*) from userx.table1@db2_dblink;
    Edited by: skvaish1 on Apr 29, 2010 3:57 PM

  • Making more archieve file while refreshing materialised view

    Hi experts,
    i have created a materialised view and index on that, while refreshing it is making more archive files,
    how to stop making archieve while refreshing the Materialised view.
    i also opted nologging option on that,

    Hi experts,
    i have created a materialised view and index on that, while refreshing it is making more archive files,
    how to stop making archieve while refreshing the Materialised view.
    i also opted nologging option on that,

  • Materialised view

    Hi
    i have a problem with one of the materialized view created by a user.
    This materialised view includes a select statement.The select statement usually takes 5 mins.When i create the materialised view and run it for the first time,it runs in 5 min as the select statement.But later on it takes 45 min or even higher to perform the task.sometimes i need to manually abort it.
    The basic syntax created like this
    CREATE MATERIALIZED VIEW oracle
    TABLESPACE oracle
    NOCACHE
    LOGGING
    NOCOMPRESS
    NOPARALLEL
    BUILD IMMEDIATE
    REFRESH FORCE ON DEMAND
    WITH PRIMARY KEY
    AS
    select statement );
    The select statement pulls data from another oracle database with the database link.

    There are some factors you should consider:
    1. As long as table is not local, you should consider network traffic.
    2. Transactional activity on the remote database may produce a lot of consistent reads, which adversely influence performance.
    3. How the execution plan from your query works.
    I suggest you to restate the way you are working with your materialized view, you may want to consider Materialized View Replication instead. This provides more control and fault tolerance mechanisms.
    ~ Madrid

  • Materialised Views

    Oracle Version 9.2.0.2
    I'm trying to improve what is currently terrible performance with BI Beans!! I have 1 fact table with 3 dimensions, and 1 hierarchy, stored in a simple star schema.
    I've defined my metatdata using OEM.
    Reading the 9i OLAP Users Guide, you must create materialised views that are specifically for use by the OLAP API. Use the DBMS_ODB package.
    I run all 4 procedures and sucessfully generate scripts to create MV on the fact and dimensions. However, when I attempt executing the line...
    execute cwm2_olap_cube.set_mv_summary_code('SECTOR', 'CR2_DATA_CUBE', 'ROLLUP')
    I get an error that the following file is missing...
    library file /opt/oracle/product/Ora9iAS_infra/lib/libamd.so
    Anybody have any ideas, or advice about creating materialised views for the OLAP API. Are there any patches that need to be applied to 9.2.0.2, specifically for OLAP?
    Thanks in advance
    Dylan.

    I managed to generate the MV scripts using DBMS_ODB procedures, and create the actual MV in the database using these scripts. However, performance has not improved. Working with my DBA I can see that the SQL generated by the BI Beans does not utilise the MV!!!
    The query is running against the lowest level data, no query rewrite appears to have been completed.
    I generated my metadata using the Enterprise Manager (simplest approach), and I am now trying to recreate my metadata using the CWM2 procedures, in the hope that this will correctly link the materialized views with metadata, and that query rewrite will occur.
    However I am having problems with the cwm2_olap_table_map.map_facttbl_levelkey procedure.
    cwm2_olap_table_map.map_facttbl_levelkey'SECTOR', 'CR2_DATA_CUBE', 'SECTOR', 'CR2_DATA', 'LOWEST LEVEL', 'DIM:COUNTERPARTY/HIER:COUNTERPARTY_HIER/GID:COUNTERPARTY_CIS_CODE/LVL:CIS_CODE/COL:COUNTERPARTY_CIS_CODE;');
    ERROR at line 1:
    ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "OLAPSYS.CWM2_OLAP_TABLE_MAP", line 143
    ORA-06512: at line 1
    Can someone explain to me in simple terms, what the GID and COL parameters should contain? e.g. foreign key on dimension table etc.
    Also... the manual suggests that each dimension specification must be in the following form:
    DIM:dimname /HIER:hiername /GID:columnname /LVL:levelname/COL:columnname;
    What if I have no hierarchy on a dimension?
    Thanks in advance
    Dylan.

  • Materialised Views and Redo

    Hi,
    I am using Oracle 10.2.0.3 enterprise edition
    Since we put in two materialised views and 2 jobs to refresh the materialised views every 5 minutes the database has been creating a lot of redo. Around about 2GIG every hour.
    We have tried to recreate the materialised views as nologging so that they don't produce redo but this doesn't seem to have made any difference. Is the materialised view nologging setting being superceded by the tablespace logging setting?

    The NOLOGGING command would apply to creating the materialized view log.
    - Inserting records into the materialized view log will generate redo.
    - Doing a refresh will also generate redo.
    Are you scertain that you really need to refresh every 5 minutes ?

  • Is Snapshot and Materialised view are the same?

    Can you please help me on this...
    I am using oracle 10G enterprise edition...
    Thanks in advance..

    Re: Is Snapshot and Materialised view are the sameYes

Maybe you are looking for

  • How to calculate start date and last date for current week

    Dear All. i want to calculate the start of the current week as well as the last date of the current week, our week start from Saturday and ends of Friday i.e. Saturday is the first day of the week and Friday is the last day of the week. How can i ach

  • External hard drive not showing up on desktop or in finder

    I just upgraded to 10.5 and then to 10.5.2 and now I'm not able to use my new Maxtor external HD. I don't see the icon on the desktop, it doesn't show up in the in the sidebar of the finder window, and sometime it does/doesn't show up in disk utiliti

  • Player in browser

    My player associated with my browseris currently not working. I work for an online radio station and was using my bb to listen Live to the broadcast www.Kmn1061.com through the flash player on the website. Currently... I'm getting nothing! The page w

  • Best Practice/Validation for deploying a Package to Azure

    Before deploying a package to Azure, What kind of best practice/Validation can be done to know the Package compatibility with Azure Enviroment?

  • Dropping first product from vendor punch-out catalog

    Hi, We are having classic scenario implemented with GOA on SRM server 5.5 and support pack 9 with CCM2.0. Currently we are facing an issue for one vendor punch-out catalog. When we are choosing multiple products from vendor catalog,it is dropping fir