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

Similar Messages

  • Issue with complete refresh on materialized view when using rownum

    Hi all,
    I had an issue with rownum when using complete refresh
    I am using rownum when creating materialized view and it is generation correctly.But the issue was when i am refreshing the same ,rownum was not getting sorted in ascending order.
    anyone had come across this scenario

    rownum is determined as the row is output, so "order by rownum" does literally nothing.
    http://docs.oracle.com/cd/B19306_01/server.102/b14200/pseudocolumns009.htm

  • Problem with replication based on materialized view

    Problem with replication based on materialized view...
    Given:
    1. Source: S-1
    2. Targets: T-1, T-2
    3. DB links: from T-1 to S-1, from T-2 to S-1
    Required replicate table TBL on S-1 to T-1, T-2 via db links.
    On S-1 was created materialized view log with PK on TBL. On T-1, T-2 were created mat.views as "on prebuilt table refresh fast on demand". In case of get "ORA-12034: materialized view log younger than last refresh" or initial load - perform complete refresh. Initial load on T-1 takes about 1 hour, on T-2 - about 12 hours. Refresh is executed via job with minutely interval. If refresh is running then it is not performed.
    Problem: after initial load on T-1 performs fast refresh, but on T-2 raised ORA-12034 and complete performs again.
    What's wrong?

    34MCA2K2, Google lover?
    I confess perhaps I gave a little info.
    View log was created before MV.
    It was the first initial load.
    No refresh failed.
    No DDL.
    No purge log.
    Not warehouse.
    There is no such behavior for MVs on another sites.
    P.S. I ask help someone who knows what's wrong or who faced with it or can me  follow by usefull link.
    P.P.S. It's a pity that there is no button "Useless answer"

  • Unexpected synonym creation via a materialized view DDL statement

    While I was doing some testing for a future materialized view creation I did this...
    create materialized view yes as select empno, ename from emp;Oracle created a table called "YES" and a materialized view called "YES".
    Then I did this...
    create materialized view wow as select empno, ename from emp;Oracle created a table called "WOW" and materialized view called "WOW", and a synonym called "WOW1"...
    Eh? Whats up with he synonym called "WOW1"?
    SQL*Plus: Release 9.0.1.4.0 -
    Oracle9i Enterprise Edition Release 9.2.0.5.0 - 64bit

    I'm not able to reproduce this. My version is 9.2.0.7.0
    my_schema@mydb> create materialized view yes as select employee_id, salary from employees;
    Materialized view created.
    Elapsed: 00:00:01.00
    my_schema@mydb> select object_type, owner, object_name from dba_objects where object_name = 'YES';
    OBJECT_TYPE        OWNER                          OBJECT_NAME
    MATERIALIZED VIEW  my_schema                        YES
    TABLE              my_schema                        YES
    Elapsed: 00:00:00.03
    my_schema@mydb> create materialized view wow as select employee_id, salary from employees;
    Materialized view created.
    Elapsed: 00:00:00.04
    my_schema@mydb> select object_type, owner, object_name from dba_objects where object_name like 'WOW%';
    OBJECT_TYPE        OWNER                          OBJECT_NAME
    MATERIALIZED VIEW  my_schema                        WOW
    TABLE              my_schema                        WOW

  • Help with sql query on materialized view logs

    I am in need of a query to find out what tablespace and snap shot site a long list of materialized view logs are associated with.
    something like below except tablespace and snap_shot_site are not an option for this table.
    select log_owner, master, log_table, tablespace, snap_shot_site from dba_mview_logs;

    What is the refresh method set as?
    Could you paste the full MV log creation script and the corresponding MV creation script.

  • Synonym problem with external table in materialized view

    I have a materialized view that includes selects on two external tables.
    However, no matter how I try to access the external tables, the creation fails with a "Synonym Translation Is No Longer Valid" (ORA-00980) error.
    This happens even when I replace the tablename with the full table name, including the link.
    I can create a view just fine, but if I then try something like CREATE MATERIALIZED VIEW mvw_my_view AS SELECT * FROM vw_my_view (where vw_my_view is the view in question), it still throws the Synonym Translation exception.

    00980, 00000, "synonym translation is no longer valid"
    // *Cause: A synonym did not translate to a legal target object. This
    //         could happen for one of the following reasons:
    //         1. The target schema does not exist.
    //         2. The target object does not exist.
    //         3. The synonym specifies an incorrect database link.
    //         4. The synonym is not versioned but specifies a versioned
    //            target object.
    // *Action: Change the synonym definition so that the synonym points at
    //          a legal target object.It is really, Really, REALLY difficult to fix a problem that can not be seen.
    use COPY & PASTE so we can see what you do & how Oracle responds.

  • Performance Issue with Crosstab Reports Using Disco Viewer 10.1.2.48.18

    We're experiencing Performance Issue (retrieving 40000 rows) with Crosstab Reports Using Disco Viewer 10.1.2.48.18 ( > 01 Minute , executing "Building Page Axis" or executing a Refresh).
    Are there parameters to tun (in pref.txt file) , in order to reduce "Building Page Axis" execution ?
    Note : We've got the same performance problem , using Discoverer Desktop 10.1.2.48.18.
    Thank's in advance for your Help.

    Hi
    Well if the same issue occurs in both Desktop and Viewer then you have your answer. It's not the way that Discoverer is running the workbook its the way the workbook has been constructed.
    For a start, 40000 rows for a Crosstab is way over the top and WILL cause performance issues. This is because Discoverer has to create a bucket for every data point for every combination of items on the page, side and top axes. The more rows, page items and column headings that you have, the more buckets you have and therefore the longer it will take for Discoverer to work out the contents of every bucket.
    Also, whenever you use page items or crosstabs, Discoverer has to retrieve all of the rows for the entire query, not just the first x rows as with a table. This is because it cannot possibly know how many buckets to create until it has all the rows.
    You therefore to:
    a) apply sufficient filters to reduce the amount of data being returned to something manageable
    b) reduce the number of page items, if used
    c) reduce the number of items on the side or top axis of a crosstab
    d) reduce the number of complex calculations, especially calculations that would generate a new bucket
    If you have a lot of complex calculations, you should consider the use of a materialized view / summary folder to pre-calculate the values.
    Does this help?
    Best wishes
    Michael Armstrong-Smith
    URL: http://learndiscoverer.com
    Blog: http://learndiscoverer.blogspot.com

  • Help with query rewrite and materialized views

    Hello everybody,
    I'm currently learning how to use Oracle (10G Enterprise) and in particular, Materialized Views.
    I seem to have a problem making the optimizer use a materialized view. I have already set the OPTIMIZER_MODE, QUERY_REWRITE_ENABLED and QUERY_REWRITE_INTEGRITY as needed.
    I need to create a materialized view for the following query:
    Q1:
    SELECT PS_SUPPKEY, PS_PARTKEY, PS_SUPPCOST
    FROM PARTSUPPLIER E, PART WHERE PS_PARTKEY=P_PARTKEY and (lower(P_COMMENT) LIKE ''_o_a\%'' or lower(P_COMMENT) LIKE ''_o_u\%'')
    and PS_SUPPCOST =
    (SELECT min( PS_SUPPCOST)
    FROM PARTSUPPLIER I
    WHERE E.PS_PARTKEY=I.PS_PARTKEY)'
    I created it using the following code:
    CREATE MATERIALIZED VIEW mv_q1
    ENABLE QUERY REWRITE
    AS SELECT PS_SUPPKEY, PS_PARTKEY, PS_SUPPCOST
    FROM PARTSUPPLIER E JOIN PART ON (PS_PARTKEY=P_PARTKEY)
    WHERE lower(P_COMMENT) LIKE '_o_a%' or lower(P_COMMENT) LIKE '_o_u%'
    and PS_SUPPCOST=
    (SELECT min( PS_SUPPCOST)
    FROM PARTSUPPLIER I
    WHERE E.PS_PARTKEY=I.PS_PARTKEY);
    I have created the statistics using:
    execute dbms_stats.gather_table_stats('frandres',' mv_q1');
    execute dbms_stats.gather_table_stats('frandres','PARTSUPPLIER');
    execute dbms_stats.gather_table_stats('frandres','PART');
    Both partsupplier and part are tables and not views.
    When executing Q1, the plan does not use the materialized view. Furthermore, when using explain rewrite:
    DECLARE
    qrytxt VARCHAR2(3000) := 'SELECT PS_SUPPKEY, PS_PARTKEY, PS_SUPPCOST
    FROM PARTSUPPLIER E, PART WHERE PS_PARTKEY=P_PARTKEY and (lower(P_COMMENT) LIKE ''_o_a\%'' or lower(P_COMMENT) LIKE ''_o_u\%'')
    and PS_SUPPCOST =
    (SELECT min( PS_SUPPCOST)
    FROM PARTSUPPLIER I
    WHERE E.PS_PARTKEY=I.PS_PARTKEY)';
    BEGIN
    dbms_mview.EXPLAIN_REWRITE
    (qrytxt,'MV_Q1','MV_Q1');
    END;
    I get the following message:
    MESSAGE
    QSM-01150: query did not rewrite
    QSM-01263: query rewrite not possible when query references a dictionary table o
    r view
    QSM-01219: no suitable materialized view found to rewrite this query
    What I can't understand is why it says I am referencing the dictionary or a view?
    If I remove the (lower(P_COMMENT) LIKE ''_o_a\%'' or lower(P_COMMENT) LIKE ''_o_u\%'') condition to the query (using the same materialized view), I get the following message from EXPLAIN_REWRITE:
    MESSAGE
    QSM-01150: query did not rewrite
    QSM-01219: no suitable materialized view found to rewrite this query
    Which is reasonable.
    I don't know if the like condition is messing up my materialized view. Can anyone please help?
    Thanks a lot in advance.
    Edited by: user12072111 on Oct 29, 2009 9:43 PM

    Bingo!
    The 10.2.0.3 patch set is supposed to fix this ( [List of bugs fixed (MVs)|http://www.dbatools.net/doc/bug10203.html#MVIEW] )
    In particular:
    5052568      Query rewrite does not work for SQL with LIKE clause.
    Thank you very much for your message!
    The downside is that I'm only using Oracle for educational purposes and consequently have no Metalink id, so I can't install the patch. Thanks a lot though!

  • Mission Control/ Expose issue with stacked pages hard to view. Please help

    Is it just me or is there a real issue with the way Mission Control/ Expose displays these stacked windows? For instance, I had about 6 finder windows open, showing 6 different folders on my Desktop. If I then use Mission Control to quickly access a particular folder, it displays all my finder windows together, stacked up on one another and this makes it almost impossible to view which particular folder i want. It doesnt have the folder names displayed so this is seriuosly time consuming now. Is this something im doing wrong, or is it a valid issue?
    many thanks

    If you are just trying to see all the Finder windows which are available, just invoke App expose. I use a 4 finger swipe down. If you are in finder, just swipe. If you are in another application, hover your mouse over the Finder icon in the dock and swipe. All the windows are easy to see.
    (You can, of course, do this with any application, not just the Finder.)
    charlie

  • Problem with queries while refreshing materialized views

    We are in oracle 8.1.7. We have some materialized views that are refreshed with DMBS_REFRESH.REFRESH in a Job. The problem is that when the refresh occurs while a query is executing we get a "Invalid Rowid" or "0RA-08103 Object not longer exists" in the session executing the query.
    We already have reproduced the problem. Is this a bug ? Any idea?
    Thanks.

    Check if the objects referred in the MV defination has undergone any reorg recently.

  • Issue with creation of a specific field for a java program.

    Hey everyone,
    This is homework which is end of chapter "challenges" to practice what we've learnt.
    The chapter covers inheritance (super class and all things related)
    I'm having quite an annoying issue with the very beginning of the instructions, where it tells me to make the following fields:
    - Employee name
    - Employee number in the format XXX-L , where each X is a digit within the range 0-9 and the L is a letter within the range A-M.
    - Hire date
    This is what I wrote for code so far
    private String name;
    //private WTF
    private String date;I really have no idea what to do for the second field, how to even constrain integers and letters in the same field with a rule for number range and letter range, and that for each character independently, for what I understand.
    Any advice with this? It's blocking me from continuing -_-, because I can't make accessors and mutators and constructors, etc, if i'm still unsure of how the fields unfold.
    Thanks in advance.

    You can create a HireDate class.
    public class HireDate{
       private final int day;
       private final String month;
       private final int year;
       public HireDate(int day, String month, int year){
          this.day = day;
          this.month = month;
          this.year = year;
    }In the HireDate Constructor you could put if statements to ensure that only correct information is present. The fields are final because the hire date will not change. Override the toString() method so that when you print it out it will be in the correct format. Create some getter methods to get the private fields.
    Then in your other class just do this
    HireDate hired = new HireDate(10, July, 1991);Now you have an object that stores all 3 fields for you. You can use the object as you like and when it prints it will be in the format you want.
    Or you could just make hireDate a String variable. That is what I always did and I never lost marks for it. The reason I suggest this way is because you mentioned rules and constraints.

  • Please help with the query creating Materialized View

    Hi,
    We are using the below query to create a Materialized View but it has been running since 3 hours. It is an Oracle 9i database running in HP-UX.The quey is as follows,
    (SELECT
    /*+ use_nl(A) parallel (A,4)*/
    A.ICD_CODE AS ICD_CODE,
    A.ICD_DESC AS ICD_DESC,
    A.PROC_GROUP as PROC_GROUP,
    B.COMPL_ICD_CODE AS COMPL_ICD_CODE,
    B.COMPL_GRP_TXT AS COMPL_GRP_TXT,
    C.PROC_TYPE AS PROC_TYPE ,
    C.I_O_IND AS I_O_IND,
    C.DISC_MON AS QUARTER ,
    B.PAT_KEY AS PAT_KEY ,
    D.COMPL_TYPE_TXT AS COMPL_TYPE_TXT ,
    C.PROV_ID AS PROV_ID ,
    A.SPECIALTY AS SPECIALTY
    FROM
    EES_ICD_9_CODE A ,
    EES_CLINICAL_COMPL_DATA B,
    EES_CLINICAL_DATA C,
    EES_CLINCL_COMPL_ICD D                                                                            
    WHERE A.ICD_CODE= B.ICD_CODE
                    AND B.ICD_CODE= C.ICD_CODE
                    AND B.COMPL_ICD_CODE=D.ICD_9_CD
                    AND B.PAT_KEY=C.PAT_KEY
                    AND B.COMPL_ICD_CODEB.ICD_CODE
                    AND C.PROC_TYPE  'L'
                    AND B.COMPL_GRP_TXT'Reoperations'
                    AND D.COMPL_TYPE_TXT'Intra-operative Misadventure'
                    AND C.DISC_MON>='2003101'
                    AND A.SPECIALTY='Colo-Rectal')
    union
    (SELECT
    /*+ use_nl(A) parallel (A,4)*/
    A.ICD_CODE AS ICD_CODE,
    A.ICD_DESC AS ICD_DESC,
    A.PROC_GROUP as PROC_GROUP,
    B.COMPL_ICD_CODE AS COMPL_ICD_CODE,
    B.COMPL_GRP_TXT AS COMPL_GRP_TXT,
    C.PROC_TYPE AS PROC_TYPE ,
    C.I_O_IND AS I_O_IND,
    C.DISC_MON AS QUARTER ,
    B.PAT_KEY AS PAT_KEY ,
    D.COMPL_TYPE_TXT AS COMPL_TYPE_TXT ,
    C.PROV_ID AS PROV_ID ,
    A.SPECIALTY AS SPECIALTY
    FROM
    EES_ICD_9_CODE A ,
    EES_CLINICAL_COMPL_DATA B,
    EES_CLINICAL_DATA C,
    EES_CLINCL_COMPL_ICD D                                                                            
    WHERE A.ICD_CODE= B.ICD_CODE
                    AND B.ICD_CODE= C.ICD_CODE
                    AND B.COMPL_ICD_CODE=D.ICD_9_CD
                   AND B.PAT_KEY=C.PAT_KEY
                    AND B.COMPL_ICD_CODEB.ICD_CODE
                    AND C.PROC_TYPE  'L'
                    --AND B.COMPL_GRP_TXT'Reoperations'
                    AND D.COMPL_TYPE_TXT='Intra-operative Misadventure'
                    AND B.PROC_DAY=C.PROC_DAY
                    AND C.DISC_MON>='2003101'
                    AND A.SPECIALTY='Colo-Rectal')
    union
    (SELECT
    /*+ use_nl(A) parallel (A,4)*/
    A.ICD_CODE AS ICD_CODE,
    A.ICD_DESC AS ICD_DESC,
    A.PROC_GROUP as PROC_GROUP,
    B.COMPL_ICD_CODE AS COMPL_ICD_CODE,
    B.COMPL_GRP_TXT AS COMPL_GRP_TXT,
    C.PROC_TYPE AS PROC_TYPE ,
    C.I_O_IND AS I_O_IND,
    C.DISC_MON AS QUARTER ,
    B.PAT_KEY AS PAT_KEY ,
    D.COMPL_TYPE_TXT AS COMPL_TYPE_TXT ,
    C.PROV_ID AS PROV_ID ,
    A.SPECIALTY AS SPECIALTY
    FROM
    EES_ICD_9_CODE A ,
    EES_CLINICAL_COMPL_DATA B,
    EES_CLINICAL_DATA C,
    EES_CLINCL_COMPL_ICD D                                                                            
    WHERE A.ICD_CODE= B.ICD_CODE
                    AND B.ICD_CODE= C.ICD_CODE
                    AND B.COMPL_ICD_CODE=D.ICD_9_CD
                    AND B.PAT_KEY=C.PAT_KEY
                    AND B.COMPL_ICD_CODEB.ICD_CODE
                    AND C.PROC_TYPE  'L'
                    AND B.COMPL_GRP_TXT='Reoperations'
                    --AND D.COMPL_TYPE_TXT='Intra-operative Misadventure'
                    AND B.PROC_DAY>C.PROC_DAY
                    AND C.DISC_MON>='2003101'
                    AND A.SPECIALTY='Colo-Rectal')
    The explain plan is as follows,
    PLAN_TABLE_OUTPUT
    | Id  | Operation                          |  Name                    | Rows  | Bytes |TempSpc| Cost  |  TQ    |IN-OUT| PQ Distrib |
    |   0 | SELECT STATEMENT                   |                          | 46935 |  6716K|       | 10648 |        |      |            |
    |   1 |  SORT UNIQUE                       |                          | 46935 |  6716K|    14M| 10648 | 45,14  | P->S | QC (RAND)  |
    |   2 |   UNION-ALL                        |                          |       |       |       |       | 45,13  | P->P | HASH       |
    |*  3 |    HASH JOIN                       |                          | 42801 |  6102K|       |  4640 | 45,13  | PCWP |            |
    |*  4 |     TABLE ACCESS FULL              | EES_CLINCL_COMPL_ICD     |   875 | 18375 |       |     2 | 45,02
    |*  5 |     HASH JOIN                      |                          | 41552 |  5072K|    14M|  4638 | 45,13  | PCWP |            |
    |*  6 |      TABLE ACCESS FULL             | EES_CLINICAL_DATA        |  1430K|    40M|       |  2855 | 45,03
    |*  7 |      HASH JOIN                     |                          |   628K|    56M|       |   494 | 45,10  | P->P | HASH       |
    |*  8 |       TABLE ACCESS FULL            | EES_ICD_9_CODE           |    37 |  2183 |       |     1 | 45,08 
    |*  9 |       TABLE ACCESS BY INDEX ROWID  | EES_CLINICAL_COMPL_DATA  |  2090K|    71M|       |   49
    |  10 |        BITMAP CONVERSION TO ROWIDS |                          |       |       |       |       |        |    
    |* 11 |         BITMAP INDEX FULL SCAN     | INX_COMPL_GRP            |       |       |       |       |        |
    |* 12 |    TABLE ACCESS BY INDEX ROWID     | EES_CLINICAL_DATA        |     1 |    33 |       |     1
    |  13 |     NESTED LOOPS                   |                          |  1327 |   196K|       |   947 | 45,13  | PCWP |            |
    |* 14 |      HASH JOIN                     |                          | 60205 |  6996K|       |   495 | 45,13  | PCWP |            |
    |  15 |       TABLE ACCESS BY INDEX ROWID  | EES_CLINCL_COMPL_ICD     |    36 |   756 |       |    
    |* 16 |        INDEX RANGE SCAN            | COMPL_TYPE_TXT_3         |     1 |       |       |     1 |     
    |* 17 |       HASH JOIN                    |                          |  1420K|   132M|       |   494 | 45,13  | PCWP |            |
    |* 18 |        TABLE ACCESS FULL           | EES_ICD_9_CODE           |    37 |  2183 |       |     1 | 45,11 
    |* 19 |        TABLE ACCESS BY INDEX ROWID | EES_CLINICAL_COMPL_DATA  |  4722K|   175M|       |   49
    |  20 |         BITMAP CONVERSION TO ROWIDS|                          |       |       |       |       |        |      |           
    |  21 |          BITMAP INDEX FULL SCAN    | INX_COMPL_GRP            |       |       |       |       |        |
    |* 22 |      INDEX RANGE SCAN              | EES_CLINICAL_DATA_IND1   |     1 |       |       |     2 | 45,13
    |* 23 |    HASH JOIN                       |                          |  2807 |   416K|       |  4695 | 45,13  | PCWP |            |
    |  24 |     TABLE ACCESS FULL              | EES_CLINCL_COMPL_ICD     |   911 | 19131 |       |     2 | 45,06
    |* 25 |     HASH JOIN                      |                          |  2617 |   334K|    15M|  4693 | 45,13  | PCWP |            |
    |* 26 |      TABLE ACCESS FULL             | EES_CLINICAL_DATA        |  1430K|    45M|       |  2855 | 45,07
    |* 27 |      HASH JOIN                     |                          |   791K|    74M|       |   305 | 45,12  | P->P | HASH       |
    |* 28 |       TABLE ACCESS FULL            | EES_ICD_9_CODE           |    37 |  2183 |       |     1 | 45,09 
    |* 29 |       TABLE ACCESS BY INDEX ROWID  | EES_CLINICAL_COMPL_DATA  |  2632K|    97M|       |   30
    |  30 |        BITMAP CONVERSION TO ROWIDS |                          |       |       |       |       |        |    
    |* 31 |         BITMAP INDEX SINGLE VALUE  | INX_COMPL_GRP            |       |       |       |       |        |
    Predicate Information (identified by operation id):
       3 - access("B"."COMPL_ICD_CODE"="D"."ICD_9_CD")
       4 - filter("D"."COMPL_TYPE_TXT"'Intra-operative Misadventure')
       5 - access("B"."ICD_CODE"="C"."ICD_CODE" AND "B"."PAT_KEY"="C"."PAT_KEY")
       6 - filter("C"."PROC_TYPE"'L' AND "C"."DISC_MON">=2003101)
       7 - access("A"."ICD_CODE"="B"."ICD_CODE")
       8 - filter("A"."SPECIALTY"='Colo-Rectal')
       9 - filter("B"."COMPL_ICD_CODE""B"."ICD_CODE")
      11 - filter("B"."COMPL_GRP_TXT"'Reoperations')
      12 - filter("B"."ICD_CODE"="C"."ICD_CODE" AND "C"."PROC_TYPE"'L' AND "B"."PROC_DAY"="C"."PROC_DA
      14 - access("B"."COMPL_ICD_CODE"="D"."ICD_9_CD")
      16 - access("D"."COMPL_TYPE_TXT"='Intra-operative Misadventure')
      17 - access("A"."ICD_CODE"="B"."ICD_CODE")
      18 - filter("A"."SPECIALTY"='Colo-Rectal')
      19 - filter("B"."COMPL_ICD_CODE""B"."ICD_CODE")
      22 - access("B"."PAT_KEY"="C"."PAT_KEY")
      23 - access("B"."COMPL_ICD_CODE"="D"."ICD_9_CD")
      25 - access("B"."ICD_CODE"="C"."ICD_CODE" AND "B"."PAT_KEY"="C"."PAT_KEY")
           filter("B"."PROC_DAY">"C"."PROC_DAY")
      26 - filter("C"."PROC_TYPE"'L' AND "C"."DISC_MON">=2003101)
      27 - access("A"."ICD_CODE"="B"."ICD_CODE")
      28 - filter("A"."SPECIALTY"='Colo-Rectal')
      29 - filter("B"."COMPL_ICD_CODE""B"."ICD_CODE")
      31 - access("B"."COMPL_GRP_TXT"='Reoperations')
    Note: cpu costing is offPlease help.

    Try removing the hints.
    Is 47,000 a reasonable estimate of how many rows you expect in the results?
    See these posts for other information that you should supply.
    HOW TO: Post a SQL statement tuning request
    HOW TO: Post a SQL statement tuning request - template posting
    When your query takes too long
    When your query takes too long ...

  • A table with two fast refresh materialized views

    Hi,
    In the current env of ours, there are three database servers.
    Data is to refreshed on demand from the master site to other two materialized view sites using fast refresh.
    Means if we have a table name ABC on Site 1. Then site2 and site3 needs to have fast refresh materialzied views from ABC.
    Can we use same materialzied view logs of ABC to refresh site2 and site3 (on demand)?
    Thanks,
    Ramneek

    Yes. Assuming materialized views on both site2 and site3, the MV logs on site1 won't be cleared until the data has been pushed to both site2 and site3.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Issue with Standard Cost estimates / Material Ledger

    Background:
    We have been using SAP for the last 5 years with Material Ledger active. Due to a number of reasons, we have not revised its standard cost estimates from 2001 till now. This means that at month end, we do not mark and release prices as recommended, nor do we mark prices and use dynamic release.
    What Happened:
    A new material called PFSW3 was made. This is a FERT. Before production
    could start my team released the standard cost estimate for this material. Production was now able to proceed without problem. Then, when the time came to sell the material (VF02), SAP again raised the error 'cost estimate not found'. On checking the standard price in MM03, we discovered that the future cost estimate was missing. So we created and marked a new cost estimate in the middle of February 2007.
    Problem:
    When the first sale took place, SAP released the marked cost estimate and posted a Price Change document to adjust for the new standard cost. I understand this was due to dynamic release. Now, when month end came, the system settled all the production orders of material PFSW3 but did not do multi level costing on it.
    Internal Investigation:
    My team has determined that the material PFSW3 has price determination 2 set by mistake. All our other production materials (HALB and FERT) are
    set to price determination 3 in the material master (accounting view).
    Questions:
    To sum this situation up,
    we need to know why the material PFSW3 was not marked closed in its period status (CKM3) at the time of closing through CKMLCP?
    What are the implications of not closing this material in Feb 2007 (current period status is showing 'Quantities and values entered')?
    How can we close this material this month?
    The future cost estimate is again missing for PFSW3 in March 2007 and I
    fear we are going to face more problems as this material is sold to customers.
    Please respond this is an urgent issue.

    Dear Shumyl,
    Please, have a look at Note 645083 - Material period status set to "Closing Entry Completed" that might help to closing your material in previous period.
    Hope it will be useful.
    Regards,
    Flaviano.

  • Issue with creation of COPA document

    Hi
    Can you please look into the following scenario and provide inputs on the issue
    Single Finished Material Number in SAP for both plant
    Plant 1 (Co Code 1000)u2013 Trading Material
    Plant2 u2013Co Code 2000) Manufactures Material
    Plant 2 manufacture Material and sell it to plant 1 and plant 1 sell it to third party. How can we create the COPA document at the time of billing (OTC) for plant 1
    We do nt want to run the Std Cost Estimate for Plant 1.
    thanks in advance
    kind regards
    sap student

    Hi
    If this scenario is applicable always i.e. Plant 2 will always make and Plant 1 will always sell, then you dont need to release cost estimate in Plant 1
    1. Maintain Price Control V in Plant 1 so that it will accet the Std Price of Plant 2 whenever you do the GR
    2. Create a Costing Key in Ke40 and specify the cost estimate Plant = PLANT 2... DO NOT check the radio button "use line item plant as cost estimate plant)... With this, whenever billing hapens from Plant 1, it will pick the Std cost of Plant 2
    br, Ajay M

Maybe you are looking for