Subquery in materialized view

I have this subquery in a materialized view.
(SELECT COUNT(*)
    FROM product_statistics_units psu
    INNER JOIN scenes_identity_fact sif
    ON (trunc(sif.date_acquired) = trunc(psu.scene_date))
    AND ((SELECT satellite_sensor_key
        FROM lu_satellite sat
        WHERE psu.satellite = sat.satellite
        AND psu.sensor_id = sat.sensor_id) = sif.satellite_sensor_key)
    AND ((SELECT wrs_key
        FROM worldwide_reference_system wwrs
        WHERE psu.wrs_path = wwrs.wrs_path
        AND wwrs.wrs_row
        BETWEEN psu.wrs_starting_row
        AND psu.wrs_ending_row) = sif.wrs_key)
    WHERE psu.date_unit_shipped IS NOT NULL)
    AS times_sold,When I try to create the view, I get this error
ORA-22818: subquery expressions not allowed here
The subquery works fine as a stand-alone query, but when put in the SELECT statement for the materialized view is when I get the error. Also if I comment out the two AND clauses in the join, it works ok.
I am fairly new to oracle and sql, but I have been tasked with creating this materialized view. Any help you guys can give me would be greatly appreciated.

Oracle is VERY fussy about what it will/won't allow in materialized view creation. You hit one of the limitations. Try recoding the sub-query as a table join since its doing correlation and see if that works.
Also do not put comments ("--" or " "/* */") in the MV SQL; I've had trouble trying to self-document the SQL in that way.

Similar Messages

  • Help regarding Materialized view ( subquery expression not allowed here )

    Hi all,
    while creating materialized view i got following error
    ORA- 22818
    subquery expression not allowed here
    following is my query
    CREATE  MATERIALIZED VIEW MV_NAV_REC
    BUILD IMMEDIATE
    REFRESH COMPLETE ON DEMAND
    as
    select folio_no FOLIONO,CHKDIGIT as Check_Digit,sch_code SCHEMECODE, sysdate as FOLIODATE ,
         (select case when count(distinct SUBBROKERCODE) =1 then to_char(max(SUBBROKERCODE)) else 'Multiple Broker' end   from transaction_st
         where folio_no = tst.folio_no
         group by  folio_no)  ARN_Number ,
         (select sum(case when tran_type in ('PURCHASE','SWITCH IN') then UNITS else 0 - UNITS end ) from transaction_st
         where folio_no = tst.folio_no AND SCH_CODE = tst.sch_code
         group by  folio_no,sch_code)  NUM_UNITS_NEW ,
    --SUM (case when tran_type NOT in ('REDEMPTION','SWITCH OUT') THEN UNITS ELSE 0 - UNITS END )  AS  Num_Units,
         (select sum(case when tran_type in ('PURCHASE','SWITCH IN') then AMOUNT else 0 - AMOUNT end ) from transaction_st
         where folio_no = tst.folio_no AND SCH_CODE = tst.sch_code
         group by  folio_no,SCH_CODE) as NUM_AMOUNT_NEW ,
    --SUM (case when tran_type NOT in ('REDEMPTION','SWITCH OUT') THEN AMOUNT ELSE 0 -AMOUNT  END )  AS  Scheme_Amount,
    sum(  CASE WHEN upper(tran_type) NOT in ('REDEMPTION','SWITCH OUT') THEN
                 units * (select nav_rs from nav_rec where nav_rec.sch_code = tst.sch_code and nav_rec."Date" = /*trunc(sysdate)*/to_date('23/03/2009','dd/mm/yyyy'))
               ELSE  (0 - units) * (select nav_rs from nav_rec where nav_rec.sch_code = tst.sch_code and nav_rec."Date" = /*trunc(sysdate)*/to_date('23/03/2009','dd/mm/yyyy')) END  ) Scheme_Valuation ,
    null as SCHEMEPHRASEID ,
    null as "Prefered Mode of SOA",
    (  select sum(      case when upper(tran_type) NOT in ('REDEMPTION','SWITCH OUT') THEN AMOUNT ELSE 0 - AMOUNT END  ) from transaction_st t where t.folio_no = tst.folio_no group by folio_no )  as Folio_Amount,
                   select sum(CASE when upper(tran_type) NOT in ('REDEMPTION','SWITCH OUT') THEN
                                              units * ( select nav_rs from nav_rec where nav_rec.sch_code = ts.sch_code and nav_rec."Date" = /*trunc(sysdate)*/to_date('23/03/2009','dd/mm/yyyy'))
                                  ELSE
                                      (0 - units) * ( select nav_rs from nav_rec where nav_rec.sch_code = ts.sch_code and nav_rec."Date" = /*trunc(sysdate)*/to_date('23/03/2009','dd/mm/yyyy')) END     
                                  )  from transaction_st ts where ts.folio_no =tst.folio_no  group by ts.folio_no
    ) as Folio_Valuation
    from transaction_st   tst 
    group by folio_no ,sch_code,CHKDIGIT
    order by folio_no , SCH_CODE
    please help me

    Hi,
    You cannot use scalar subqueries in a materialized view.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:4110947624538#22981269011674
    edit
    From 10g doc:
    ORA-22818: subquery expressions not allowed here
    Cause: An attempt was made to use a subquery expression where these are not supported.
    Action: Rewrite the statement without the subquery expression.
    (http://download.oracle.com/docs/cd/B19306_01/server.102/b14219/e19400.htm#sthref6020)
    Edited by: hoek on Jun 10, 2009 7:56 AM

  • Materialized view is giving error ORA-22818 subquery expressions

    Hi all,
    i want to create one materilized view which will be combination of two tables and also having column sdatetime that is select from dual .
    CREATE MATERIALIZED VIEW E_VPN_MEMHISTORY
    PCTFREE 5 PCTUSED 60
    STORAGE (INITIAL 512K NEXT 1024K)
    REFRESH Fast
    AS SELECT (SELECT TO_CHAR(SYSDATE-1,'YYYYMMDDHH24MISS') FROM DUAL)sDateTime,m.sid,m.number,m.nAccUsg1,t.NACC1 FROM teacher m,student t where m.npid=t.npid and m.name=t.name(+);
    ORA-22818: subquery expressions not allowed here
    Cause: An attempt was made to use a subquery expression where these are not supported.
    Action: Rewrite the statement without the subquery expression.
    so what is the solution so that sdatetime should be there in view and it should be fast refresh.
    please suggest its urgent
    Edited by: 996962 on 10 Apr, 2013 9:20 AM

    >
    please suggest its urgent?:|
    Well, if you put it that way:
    I hereby suggest it's urgent....
    HTH!
    Seriously now, please read:
    {message:id=9360002}
    And the message should be clear:
    ORA-22818: subquery expressions not allowed here
    Cause: An attempt was made to use a subquery expression where these are not supported.
    Action: Rewrite the statement without the subquery expression.

  • Materialized view ....subquery expression not allowed

    Hi,
    I have been assigned to create a materialized view using the following subquery.
    When I executed it is giving error ora-22818:subquery expressions not allowed here. The same query is good for view but not MV.
    Can anybody help me in writing MV for my query.
    select rownum as ROWNUMBER,f.id Folder_ID, concatyear(f.id) year_name,
    (select nvl(fr.requestor,fr.requested_by) from fts_folder_request fr where
    fr.folder_id=f.id and fr.status=0 ) Pending_Requestor,
    (select nvl(fr.requestor,fr.requested_by)
    from fts_folder_request fr,fts_folder_checkout_history fch where
    fr.folder_id=f.id and fch.folder_requested=fr.id and fch.return_date is null) CheckOut_To from fts_folder f;
    Thanks in advance.

    Any help in creating MV for my query.It contains subquery expressions that have to be avoided in MV.
    select rownum as ROWNUMBER,f.id Folder_ID, concatyear(f.id) year_name,
    (select nvl(fr.requestor,fr.requested_by) from fts_folder_request fr where
    fr.folder_id=f.id and fr.status=0 ) Pending_Requestor,
    (select nvl(fr.requestor,fr.requested_by)
    from fts_folder_request fr,fts_folder_checkout_history fch where
    fr.folder_id=f.id and fch.folder_requested=fr.id and fch.return_date is null) CheckOut_To from fts_folder f;
    Thanks.
    Message was edited by:
    user617694

  • Subquery in a Materialized View

    I have a requirement where we have to build a summary view to show a customer's latest transaction. There can be several million customers so I am thinking if a Materialized view that gets refreshed once every day is a good option here. This is a Datawarehouse application where the records get appended once every day. I would like a summarized materialized view that is dropped and refreshed every day morning.
    Here is the query that gets the latest order amount for each of the customer:
    SELECT cu.cust_name,
    od.order_amount
    FROM customers cu,
    orders od
    WHERE cu.cust_id = od.cust_id
    and od.order_date =
    (select max(order_date) from orders od
    where od.cust_id = cu.cust_id)
    My questions are:
    1) Is the materialized view a snapshot? Or does it go against the underlying table every time the MV is accessed, much like a regular view?
    2) I would like a snapshot type of solution here. Since there could be 100 million orders for 1 million customers, a summary snapshot of 1 million records would perform much better IMO. Correct me if I got it wrong.
    Thank you in advance for your help.

    Users query will be explicitly against the Mview.
    After doing some reading on the MView, I am more inclined to think that Mview is not an ideal solution for my requirement here.
    SELECT cu.cust_name,
    od.order_amount,
    MAX(od.order_date) over (PARTITION BY od.cust_id) max_date
    FROM customers cu,
    orders od
    WHERE cu.cust_id = od.cust_id
    The orders is a 20+ million records table. I thought by using a Mview that holds the maximum order date will avoid going to the orders table when users want to see that is the latest order date for a customer. However, the report requirements are such that the users will want to see what is the maximum order date within a certain date range. If this being the case, there is no point in using an Mview.
    Once again, pl correct me if my understanding is not correct.

  • Create materialized view get ora-00998 error cause by subquery

    hi all,
    my create statement as follow,
    create materialized view MV_DM_DIM_DEALER01
    Build deferred
    Refresh complete
    ON DEMAND
    Enable query rewrite
    as
    select a.dealer_no,a.sk_period from DM_DIM_DEALER a
    where A.SK_PERIOD=201210 and a.dealer_no in (select dealer_No from dm00_fav_dealer)
    ORA-00998: must name this expression with a column alias
    so what's the problem?
    thx all

    >
    my create statement as follow,
    create materialized view MV_DM_DIM_DEALER01
    Build deferred
    Refresh complete
    ON DEMAND
    Enable query rewrite
    as
    select a.dealer_no,a.sk_period from DM_DIM_DEALER a
    where A.SK_PERIOD=201210 and a.dealer_no in (select dealer_No from dm00_fav_dealer)
    ORA-00998: must name this expression with a column alias
    so what's the problem?
    >
    Well since the error is 'ORA-00998: must name this expression with a column alias' you might try naming your expressions with aliases
    select a.dealer_no dealer_no,a.sk_period sk_period from DM_DIM_DEALER a

  • How to create a materialized view on a subqueried view

    Hi,
    I have a view with subquery. This view is accessed by users frequently. I want to improve its performance by materialiezed view technology. Unfortunately, my view includes a subquery. does anyone have an idea how to create a materialiezed view on a subqueried view?
    Copper

    Oracle 9.2.0.4
    SQL,
    select
    action,
    id,
    id0,
    bl_ticker,
    report_type,
    published_date,
    version,
    decode(rating,'SBUY','Strong Buy',initcap(rating)) rating,
    nvl(fairvalue,(select fairvalue from ard_published_v2_log where id=(select max(id) from ard_published_v2_log where bl_ticker=a.bl_ticker and id<a.id and fairvalue is not null))) fairvalue,
    pricing_date,
    price,
    update_date,
    nid
    from
    select * from ard_published_v2_log
    union select * from nemo_published_history_corr where (action is null or action<>'D')
    minus select * from ard_published_v2_log where action='D'
    minus select * from ard_published_v2_log where id in (select id0 from ard_published_v2_log where id0 is not null)
    minus select * from ard_published_v2_log where id in (select id0 from nemo_published_history_corr where action='D')
    minus select * from ard_published_v2_log where id in (select id0_new from nemo_fillup_id0 where apply=1)
    minus select * from ard_published_v2_log where id>0 and rating='N/A' and price is null-- and nid is null
    ) a
    order by id desc

  • Creating a Materialized View from different agregate queries

    I want to create a materialized view. The problem is that doing so can get sticky. The view should have one row, with each column representing the return of an aggregate function on the base table. Here is a query that returns this kind of result:
    select
         (select count(rowid) from pasta) "PASTA_ROWS",
         (select count(salt) from pasta where salt='F') "SALT_IS_FEMALE_ROWS"
    from dual;
    You can see that by selecting the subqueries from dual, I get the return to be in seperate columns. The problem is that when I try creating a Materialized view, I get an error.
    ERROR at line 8:
    ORA-22818: subquery expressions not allowed here
    So, is there a simple SQL query that will return the values I am asking for, in seperate columns, but will not make the materialized view produce an error?
    Thanks,
    Edward
    For your reference, here is a describe of the pasta table:
    SQL> desc pasta
    Name Null? Type
    CHEESE NUMBER(4)
    TOMATO VARCHAR2(20)
    SALT VARCHAR2(1)
    OREGANO VARCHAR2(20)
    OLIVE_OIL VARCHAR2(40)

    Edward:
    Something like this should work:
    SELECT COUNT(*) PASTA_ROWS,
           SUM(DECODE(salt,'F',1,0)) SALT_IS_FEMALE_ROWS
    FROM pastaTTFN
    John

  • Error While Creating Materialized View

    Hello,
    I am getting error ORA-22818: subquery expressions not allowed here while creating materialized view. I am using Oracle9i Enterprise Edition Release 9.2.0.1.0. Below pasted is my SQL Script.
    Any help is highly appreciable.
    Thanks
    *********SQL************
    select distinct(id),NAME,(select count(GRADE) from employees where
    nationality like '%US%'and id=a.organization_id and grade=a.grade
    group by ID,GRADE) US,(select count(GRADE) from employees where
    nationality not like '%US%' and organization_id=a.organization_id and grade=a.grade
    group by ORGANIZATION_ID,GRADE) NON_US,grade from employees a
    where grade is not null
    group by GRADE,ID,name
    order by to_number(grade) desc

    Hi,
    This is a documented restriction on MVs. You cannot have a scalar express (i.e a select statement) in the select list.
    You can get round this by joining your select count(grade).. expression in as an inline view in your FROM clause. Or you can create a normal view without the scalar expression, create your MV as a select from this view, then re-define your view to contain the query you want.
    Hope that helps,
    Rod West

  • Unable to create a Materialized View

    I have this query to generate continous dates for the given number of months (12 in this case).
    (SELECT ADD_MONTHS(TO_DATE('2007-01-01', 'yyyy-mm-dd'), rownum - 1) Transaction_Date_Month
      FROM DUAL
              CONNECT BY level <= 12)I am using this query alongside with another query to get some results. I want to put the whole query what i have in a "Materialized View". But it is not allowing me to create the materialized view becuase of using "rownum". So how can i avoid "rownum" for getting all the dates and also use it in Materialized View.

    Why do you want to create this a materialized view?
    I presume the date changes dynamically somehow otherwise you'd want to use a table
    What is the actual date range you want to use?
    Would you be better off using a materialized subquery using WITH?
    WITH subq_months AS
    (SELECT /*+materialize */ADD_MONTHS(TO_DATE('2007-01-01', 'yyyy-mm-dd'), rownum - 1) Transaction_Date_Month  FROM DUAL          CONNECT BY level <= 12)
    SELECT -- use months here somehow --
    FROM   subq_months

  • Materialized View with Joins

    Dear Dev/DBAs,
    I have the following scenario:
    SQL> CREATE TABLE T1 (ID NUMBER(3),NAME VARCHAR2(10));
    SQL> CREATE TABLE T2 (ID NUMBER(3),NAME VARCHAR2(10));
    The T1 contains records having the ID num from 10 to 80 and the T2 having the ID from 90 to 170
    SQL> SELECT * FROM T1 JOIN ALL SELECT * FROM T2
    It give all records in the 2 tables.
    I'm planning to create a materialized view (like CREATE MATERIALIZED VIEW V_TAB REFRESH ON COMMIT AS SELECT * FROM T1 JOIN ALL SELECT * FROM T2) and it seems i can't do with the error ORA-12054, further the oracle documentation says that materialized view can only be used with a simple join.
    Do you have another solution??
    Note that the materialized views can be used to improve queries.
    Thank you in advance

    Straight from the link I posted:
    *Restrictions on Fast Refresh on Materialized Views with UNION ALL*Materialized views with the UNION ALL set operator support the REFRESH FAST option if the following conditions are satisfied:
    * The defining query must have the UNION ALL operator at the top level.
    The UNION ALL operator cannot be embedded inside a subquery, with one exception: The UNION ALL can be in a subquery in the FROM clause provided the defining query is of the form SELECT * FROM (view or subquery with UNION ALL) as in the following example:
    CREATE VIEW view_with_unionall AS
    (SELECT c.rowid crid, c.cust_id, 2 umarker
    FROM customers c WHERE c.cust_last_name = 'Smith'
    UNION ALL
    SELECT c.rowid crid, c.cust_id, 3 umarker
    FROM customers c WHERE c.cust_last_name = 'Jones');
    CREATE MATERIALIZED VIEW unionall_inside_view_mv
    REFRESH FAST ON DEMAND AS
    SELECT * FROM view_with_unionall;
    Note that the view view_with_unionall satisfies the requirements for fast refresh.
    * Each query block in the UNION ALL query must satisfy the requirements of a fast refreshable materialized view with aggregates or a fast refreshable materialized view with joins.
    The appropriate materialized view logs must be created on the tables as required for the corresponding type of fast refreshable materialized view.
    Note that the Oracle Database also allows the special case of a single table materialized view with joins only provided the ROWID column has been included in the SELECT list and in the materialized view log. This is shown in the defining query of the view view_with_unionall.
    * The SELECT list of each query must include a maintenance column, called a UNION ALL marker. The UNION ALL column must have a distinct constant numeric or string value in each UNION ALL branch. Further, the marker column must appear in the same ordinal position in the SELECT list of each query block.
    * Some features such as outer joins, insert-only aggregate materialized view queries and remote tables are not supported for materialized views with UNION ALL.
    * Partiton Change Tracking (PCT)-based refresh is not supported for UNION ALL materialized views.
    * The compatibility initialization parameter must be set to 9.2.0 or higher to create a fast refreshable materialized view with UNION ALL.

  • Regarding Error in Materialized view Fast Refresh

    ORA-12015: cannot create a fast refresh materialized view from a complex query
    CREATE MATERIALIZED VIEW MVCONTENTHISTORY_01
    BUILD IMMEDIATE
    REFRESH FAST
    WITH PRIMARY KEY
    ENABLE QUERY REWRITE
    AS
    SELECT a.DAY, a.contentname,
    SUM
    (CASE
    WHEN (b.subscriptionstartdate) <= (a.DAY)
    AND ((CASE
    WHEN b.subscriptionenddate IS NOT NULL
    THEN (a.DAY)
    ELSE TO_DATE ('01/20/1990', 'MM/DD/YYYY')
    END
    ) <=
    (CASE
    WHEN b.subscriptionenddate IS NOT NULL
    THEN (b.subscriptionenddate)
    ELSE TO_DATE ('01/20/1990', 'MM/DD/YYYY')
    END
    THEN 1
    ELSE 0
    END
    ) COUNT,
    COUNT
    (CASE
    WHEN (b.subscriptionstartdate) <= (a.DAY)
    AND ((CASE
    WHEN b.subscriptionenddate IS NOT NULL
    THEN (a.DAY)
    ELSE TO_DATE ('01/20/1990', 'MM/DD/YYYY')
    END
    ) <=
    (CASE
    WHEN b.subscriptionenddate IS NOT NULL
    THEN (b.subscriptionenddate)
    ELSE TO_DATE ('01/20/1990', 'MM/DD/YYYY')
    END
    THEN 1
    ELSE 0
    END
    ) cnt
    FROM TBLTDATEWISECONTENT a,
    (SELECT TRUNC (a.subscriptionstartdate) subscriptionstartdate,
    TRUNC (a.subscriptionenddate) subscriptionenddate, b.NAME,
    b.contentid
    FROM syntbltcontentsubscrhistory a, syntblmcontent b
    WHERE b.contentid = a.contentid(+)) b
    WHERE a.contentid = b.contentid(+) AND a.DAY = b.subscriptionstartdate(+)
    GROUP BY a.contentname, a.DAY;
    I can't create Materialized view with fast Refresh .
    Kindly provide solution .
    Regards,
    nayana chavda.

    Kindly provide full Oracle version since option vary by release.
    There error message says it is impossible to fast refresh based on a complex query.
    On 10g Oracle provides a package procedure that will tell you why the view cannot be fast refreshed: dbms_mview.explain_mview.
    Otherwise see the Advanced Replication Manual for a list of restrictions.
    10gR2 >>Restrictions for Materialized Views with Subqueries
    The defining query of a materialized view with a subquery is subject to several restrictions to preserve the materialized view's fast refresh capability.
    The following are restrictions for fast refresh materialized views with subqueries:
    Materialized views must be primary key materialized views.
    The master's materialized view log must include certain columns referenced in the subquery. For information about which columns must be included, see "Logging Columns in the Materialized View Log".
    If the subquery is many to many or one to many, join columns that are not part of a primary key must be included in the materialized view log of the master. This restriction does not apply to many to one subqueries.
    The subquery must be a positive subquery. For example, you can use the EXISTS condition, but not the NOT EXISTS condition.
    The subquery must use EXISTS to connect each nested level (IN is not allowed).
    Each table can be in only one EXISTS expression.
    The join expression must use exact match or equality comparisons (that is, equi-joins).
    Each table can be joined only once within the subquery.
    A primary key must exist for each table at each nested level.
    Each nested level can only reference the table in the level above it.
    Subqueries can include AND conditions, but each OR condition can only reference columns contained within one row. Multiple OR conditions within a subquery can be connected with an AND condition.
    All tables referenced in a subquery must reside in the same master site or master materialized view site.
    <<
    HTH -- Mark D Powell --
    Message was edited by: added list of restrictions left off initial post
    mpowel01

  • Order by in MATERIALIZED VIEW not work successfully with first column (ID)

    Dears,
    I am trying to create a Materialized View as below:
    CREATE MATERIALIZED VIEW HR.MV_EMP
    PCTFREE 10
    MAXTRANS 255
    TABLESPACE users
    STORAGE (
    INITIAL 65536
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUILD IMMEDIATE
    REFRESH ON DEMAND
    AS
    SELECT *
    FROM employees
    where rownum < 5000 order by employee_id desc ;But while querying the MATERIALIZED VIEW, it did not work successfully as the data did not appear in the accurate order.
    I tried to create the same MATERIALIZED VIEW but order by another column (Column Date), it worked successfully and the data appeared in the accurate order.
    It means that MATERIALIZED VIEW not work successfully with the first column (id).
    Can you please help me in this ?
    Thanks & regards,,

    A few pointers :
    1. As has been pointed out, the ROWNUM has been incorrectly placed. ROWNUM values are assigned as rows are fetched from the source before the ORDER BY. You need to ORDER BY first (in a SubQuery) and then ROWNUM afterwards (outside the SubQuery).
    2. I wonder why you want only the last 5000 EMPLOYEE_IDs. What if Employee_ID 1 is still an active employee (he is the founder, first employee and CEO ?). There could be very many "low" EMPLOYEE_IDs that are still active.
    3. Logically I would expect some filter other than the ROWNUM ... ORDER BY to be used to select candidate rows. Then, an ORDER BY in the CREATE query would be unnecessary.
    4. When querying the Materialized View you must explicitly ORDER BY (irrespective of whether you did or did not do an ORDER BY in the CREATE ...)
    5. How do you expect to refresh the MV ? Will it always be a COMPLETE Refresh ? Remember that your "5000 employees" filter would likely exclude older employees at the next refresh. If you use some other filter, it should be consistent across all refreshs.
    Hemant K Chitale

  • Problem with Materialized Views in 10g

    Hi All,
    I am creating a Materialized View like
    CREATE MATERIALIZED VIEW mvname TABLESPACE SYSTEM BUILD IMMEDIATE REFRESH WITH ROWID FOR UPDATE AS ( SELECT a,b,c FROM table_a,table_b,table_c WHERE cond );
    I am getting an error
    SQL Error: ORA-12013: updatable materialized views must be simple enough to do fast refresh.
    Can anyone tell what is the problem?
    I have included rowid of all three tables in select clause.

    Hi,
    From Oracle Docs:
    ORA-12013: updatable materialized views must be simple enough to do fast refresh
    Cause: The updatable materialized view query contained a join, subquery, union, connect by, order by, or group by caluse.
    Action: Make the materialized view simpler. If a join is really needed, make multiple simple materialized views then put a view on top of them.
    Regards
    K.Rajkumar

  • Materialized view (creating and complete refresh)

    Good day.
    I have a huge query that is used to create a materialized view. The query consist of 9 joins, a lot of aggregations, some subqueries, so we can say it is rather huge. The query itself executes for about 30 seconds and returns about 200 rows. The materialized view creates and refreshes for more than 30 minutes. Can someone please explain me the mechanism of materialized view creation which causes such bad performance.
    We use Oracle Database 9.2.0.4.
    Thank you in advance.

    I've fount the solution. May be it will be useful for someone not regarding that 9.2 database is less used today than 10.2.
    I studied carefully the plan of the query and the plan of insert statement that is used when creating materialized view and found the cause of trouble. Insert statements generates VIEW PUSHED PREDICATE and BITMAP CONVERSION FROM ROWIDS when parsing. Bitmap conversion can be removed by setting environment parameter btree_bitmap_plans to false (a well-known issue), but I decided not ot change the production environment. The pushed predicate can be removed by using hint NO_PUSH_PRED to each subquery used in a materialized view. This step reduced the time of materialized view creation and execution to about a minute.
    Thank everyone who tried to help.

Maybe you are looking for

  • Anyone have a spare microphone cable for ibook G3 12 inch

    Anyone have a spare microphone cable for ibook G3 12 inch? I pulled the wire from the connector when replacing my logic board.

  • I'm looking for a video of a good, comprehensive demonstration of what Motion 5 can do.

    All I can find so far are tutorials... any suggestions?

  • Macbook Pro not shutting down

    2011 Macbook Pro with Lion I only notice the problem with the system not shutting down or restarting, it goes to the grey screen and the I see the spining icon at the bottom of the screen only when I open itunes and have my external seagate goflex 2t

  • Removing the back cover

    Hi all, Well, we have the ever-popular, iMac G5 that won't power up issue. No sound, no video, the light turns on. The one-year warranty expired on 2/17/07 and it's not in the first generation iMacs covered by Apple's extended repair for this issue.

  • Ipod completely screwed up

    I tried an expert at ilounge and he said come here because he could not help. Here's whats going on: My ipod will not turn on, it either shows a sad face on the ipod screen, or an inanimate battery (which means the battery is ), because the battery i