OR and UNION

Is there any difference between OR condition in where clause and set operator UNION?
i tried queries with OR condition in where clause and then split that query in two queries with UNION set operator.
i have tested for some queries and its giving me the same output but i am not sure is this the right approach for performance tunning purpose.
please suggest for the same.

Thanks a lot..
well i m using those two condition with a update statement...while using union all its taking more time as compared to UNION.
The elapsed time is very less with UNION....
my concern is, earlier that query was using OR condition and taking somewhere round 12 sec for updating the records. now i have changed it to union and now its taking .02 sec..but i m working on development database and don't know about production database .... I m not sure whether it will work in same manner on production as well becuase the difference between the record count is huge.
second question:For update query do we have to use union all in where condition or union is the right set operator.
please assist its the right way to tune a query or i can follow some other process
thanks in advance

Similar Messages

  • Joins and Unions  defference

    Hi Mates.
    Could any one tell me the Basic difference between Joins and Unions . I know InfoSet contain  joins and Multiproviders contains the unions.
    Regards.
    harry

    Hi Harry,
       Let suppose you had two table TAB1 = 10 records and TAB2 = 30.
       If you are using the left join based on TAB1 for TAB2 then you will get only 10 only.
       If you are using the inner join between tab1 and tab2 then you will get only the combination of records only...(less records)
      if you are using the union between the two tables then you will get totaly 40 records.
    Regards,
    PRK
    Message was edited by: PRK

  • Alter express code to include views and unions for top dim items

    If a user selects a dimension item at the top most level, the explain plan shows that it does a full table scan of the fact table instead of using the materialized views. If we add the highlighted information(see below) to the osa generated sql, then the explain plan does what we want it to do.
    Do you know if it is possible to alter the express code to include the views and unions for the dimension items that are at the top most level in the hierarchy? I think that I need to alter how the sq.query.drv program figures out what to include in the sql. But this is beyond my express comfort level.
    The query below is generated by the osa cube and we want to include the highlighted information in the sql that is generated which will force it to use the correct query rewrite and return data in a reasonable time frame.
    Is this possible and has anyone tried this before?
    SELECT 'B4' || lt2.acct_lvl_4_id
    , 'C2' || lt6.cust_grpng_id
    , 'G1000'
    , 'L1000'
    , 'O190012880'
    , 'P1000000000'
    , 'R100001'
    , 'T3' || lt25.mth_id
    , 'E190'
    , SUM (ft34.usd_curr_pl_amt)
    FROM osa_fivcas_mth_ifct_gbl_992 ft34
    , osa_fivcas_acct_992 lt2
    , osa_fivcas_cal_mastr lt25
    , osa_fivcas_cust_898_000 lt6
    -- Extra Tables
    , osa_fivcas_geo_942 lt20
    , osa_fivcas_org_817 lt22
    , osa_fivcas_prod_710 lt23
    WHERE lt2.acct_lvl_9_skid = ft34.acct_lvl_9_skid
    AND lt6.cust_lvl_10_skid = ft34.cust_lvl_10_skid
    AND lt25.mth_skid = ft34.mth_skid
    -- Extra Join Conditions
    AND lt20.geo_lvl_8_skid = ft34.geo_lvl_8_skid
    AND lt22.org_lvl_12_skid = ft34.org_lvl_12_skid
    AND lt23.fpc_skid = ft34.fpc_skid
    AND lt2.acct_lvl_4_id IN ('81013286')
    AND lt6.cust_grpng_id IS NOT NULL
    AND lt25.mth_id IN ('AUG08')
    GROUP BY 'B4' || lt2.acct_lvl_4_id
    , 'C2' || lt6.cust_grpng_id
    , 'G1000'
    , 'L1000'
    , 'O190012880'
    , 'P1000000000'
    , 'R100001'
    , 'T3' || lt25.mth_id
    , 'E190';

    David,
    When u add a field to a header table. U can use the User data source to bind it. Even if u add the DBDatasource the Coulmn needs to be present in the DB at the time of setting the data source to the Field in the UI.
    Actually if u add a header filed to the DB it pops up on the User-Fields Form i guess u can use it as no extra code is needed. To view the UDF form VIEW--User Defined Fields.
    Hope it helps,
    Vasu Natari.

  • Question regarding Joins and Union

    Hi All,
    Here is the question:
    I have two databases, on which I made a UNION to see both item codes and item names. The issue is that on one database I have an item with the same code than the other, but due human error, on the other database, I have the same name but with an "s" or something like that.
    What I need to do is, when I make a query, I want to see all item codes from both tables, but I want to see only the description from the db1.
    How can I do this?
                                  |      db1                  |    db 2
    ---------------------------   |  -------------------------  | ---------------------------   
    itemcode                 |     ART001            |   ART001
    item name               |     Rock                |   Rocks

    Pavan Patil wrote:
    In my select query I am using only one column (which is part of primary) while joining two base tables and one column of foreign key of other table to get data.
    My query here is whether I have to make use of all the columns of the composite primary key and foreign key to get the values and after making use of this whether performance of the query will be improved ? (Presently my qyery is taking 6.24 mins).
    This is not a question of performance but of what result you want. The result of joining on one column is logically quite different to joining on all of them. I strongly suspect that you will need to join on all three key columns to get a useful result - but that depends on what you are trying to achieve.

  • Materialized view issue with spatial index and UNION all.

    Hi guys,
    I'm trying to build the following materialized view:
    create materialized VIEW MV_ElectricalStuffs
      refresh fast
      AS
      SELECT jb.ROWID,
        jb.FID,
        JB.NAME_NUMBER
      FROM EL_BUS_BAR jb
      UNION ALL
      SELECT INC.ROWID,
        INC.FID,
        NULL,
        INC.NAME_NUMBER
      FROM EL_INTERNAL_CELL INC;
    I have this error showing up:
    ORA-12015: cannot create a fast refresh materialized view from a complex query
    This is because the table EL_INTERNAL_CELL has a SDO_GEOMETRY column that has a spatial index, whose ddl is
    CREATE INDEX EL_INTERNAL_CELL_S ON EL_INTERNAL_CELL (GEOM) INDEXTYPE IS MDSYS.SPATIAL_INDEX
    PARAMETERS('SDO_INDX_DIMS=2 TABLESPACE=USERS LAYER_GTYPE=COLLECTION');
    When I remove the spatial index from EL_INTERNAL_CELL column GEOM, Oracle is very happy and creates the view.
    Is there a mean however to keep the spatial index in the materialized view?

    I've managed to drop the spatial index prior to create the materialized view and it is ok. After the materialized view creation, I've recreated the spatial index on the table and all ran smooth. Hope nothing will go bad in the future because of this trick on spatial index..

  • SQL: GROUP BY and UNION addition issue..

    I'm looking to to get the TOTALS of the grouping. What I'm getting now is either a 1 or a 2 whether or not each PRIMARY_ASSIGMENT_GROUP appears in each query. when I run the
    SELECT a.PRIMARY_ASSIGNMENT_GROUP,GROUP(a.PRIMARY_ASSIGNMENT_GROUP) from
    SELECT
    COUNT(PRIMARY_ASSIGNMENT_GROUP),PRIMARY_ASSIGNMENT_GROUP
    from
    SMINCREQ
    LEFT JOIN SMOPERATOR on SMINCREQ.OPENED_BY=SMOPERATOR.NAME
    WHERE
    open_time BETWEEN to_date(:P246_SDATEB,'DD-MON-YYYY') AND to_date(:P246_EDATEB,'DD-MON-YYYY') and
    ((to_char(CAST((FROM_TZ(CAST(open_time AS TIMESTAMP),'+00:00') AT TIME ZONE 'US/Eastern') AS DATE),'HH24') between '00' and '08') or (to_char(CAST((FROM_TZ(CAST(open_time AS TIMESTAMP),'+00:00') AT TIME ZONE 'US/Eastern') AS DATE),'HH24') between '19' and '24')) GROUP BY PRIMARY_ASSIGNMENT_GROUP
    UNION ALL
    SELECT
    COUNT(PRIMARY_ASSIGNMENT_GROUP),PRIMARY_ASSIGNMENT_GROUP
    from SMINTERACTIONS
    WHERE
    open_time BETWEEN to_date(:P246_SDATEB,'DD-MON-YYYY') AND to_date(:P246_EDATEB,'DD-MON-YYYY') and
    ((to_char(CAST((FROM_TZ(CAST(open_time AS TIMESTAMP),'+00:00') AT TIME ZONE 'US/Eastern') AS DATE),'HH24') between '00' and '08') or (to_char(CAST((FROM_TZ(CAST(open_time AS TIMESTAMP),'+00:00') AT TIME ZONE 'US/Eastern') AS DATE),'HH24') between '19' and '24')) GROUP BY PRIMARY_ASSIGNMENT_GROUP
    ) a
    GROUP BY (a.PRIMARY_ASSIGNMENT_GROUP)
    ORDER by COUNT(a.PRIMARY_ASSIGNMENT_GROUP)

    bostonmacosx wrote:
    I'm looking to to get the TOTALS of the grouping. What I'm getting now is either a 1 or a 2 whether or not each PRIMARY_ASSIGMENT_GROUP appears in each query. when I run the
    SELECT a.PRIMARY_ASSIGNMENT_GROUP,GROUP(a.PRIMARY_ASSIGNMENT_GROUP) from
    SELECT
    COUNT(PRIMARY_ASSIGNMENT_GROUP),PRIMARY_ASSIGNMENT_GROUP
    from
    SMINCREQ
    LEFT JOIN SMOPERATOR on SMINCREQ.OPENED_BY=SMOPERATOR.NAME
    WHERE
    open_time BETWEEN to_date(:P246_SDATEB,'DD-MON-YYYY') AND to_date(:P246_EDATEB,'DD-MON-YYYY') and
    ((to_char(CAST((FROM_TZ(CAST(open_time AS TIMESTAMP),'+00:00') AT TIME ZONE 'US/Eastern') AS DATE),'HH24') between '00' and '08') or (to_char(CAST((FROM_TZ(CAST(open_time AS TIMESTAMP),'+00:00') AT TIME ZONE 'US/Eastern') AS DATE),'HH24') between '19' and '24')) GROUP BY PRIMARY_ASSIGNMENT_GROUP
    UNION ALL
    SELECT
    COUNT(PRIMARY_ASSIGNMENT_GROUP),PRIMARY_ASSIGNMENT_GROUP
    from SMINTERACTIONS
    WHERE
    open_time BETWEEN to_date(:P246_SDATEB,'DD-MON-YYYY') AND to_date(:P246_EDATEB,'DD-MON-YYYY') and
    ((to_char(CAST((FROM_TZ(CAST(open_time AS TIMESTAMP),'+00:00') AT TIME ZONE 'US/Eastern') AS DATE),'HH24') between '00' and '08') or (to_char(CAST((FROM_TZ(CAST(open_time AS TIMESTAMP),'+00:00') AT TIME ZONE 'US/Eastern') AS DATE),'HH24') between '19' and '24')) GROUP BY PRIMARY_ASSIGNMENT_GROUP
    ) a
    GROUP BY (a.PRIMARY_ASSIGNMENT_GROUP)
    ORDER by COUNT(a.PRIMARY_ASSIGNMENT_GROUP)Instead of using UNION ALL you should be able to get by with GROUPING SETS or ROLLUP.
    If you'd care to put together a small test case with data (representing what you have) and some sample output (what you need) along with your Oracle version
    select * from v$versionI'm sure someone will help you out.
    Cheers,

  • Concatenation and Union all

    Hi,
    From Oracle 9i performance guide:
    "Concatenation is useful for statements with different conditions combined with an OR clause"
    "If a query contains a WHERE clause with multiple conditions combined with OR operators, then the optimizer transforms it into an equivalent compound query that uses the UNION ALL set operator, if this makes the query execute more efficiently"
    Can anyone tell me when concatenation is better than union and vice versa?

    skde wrote:
    Hi,
    From Oracle 9i performance guide:
    "Concatenation is useful for statements with different conditions combined with an OR clause"
    "If a query contains a WHERE clause with multiple conditions combined with OR operators, then the optimizer transforms it into an equivalent compound query that uses the UNION ALL set operator, if this makes the query execute more efficiently"
    Can anyone tell me when concatenation is better than union and vice versa?Concatenation is not exactly the same as UNION ALL (the ALL is important, by the way), as it has to eliminate repetitions of data. You may rewrite an 'OR' query as a UNION ALL, concatenation is simply Oracle's strategy for doing this. There's an example on my blog which might help you understand the issues: http://jonathanlewis.wordpress.com/2007/02/26/subquery-with-or/
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
    There is a +"Preview"+ tab at the top of the text entry panel. Use this to check what your message will look like before you post the message. If it looks a complete mess you're unlikely to get a response. (Click on the +"Plain text"+ tab if you want to edit the text to tidy it up.)
    +"I believe in evidence. I believe in observation, measurement, and reasoning, confirmed by independent observers. I'll believe anything, no matter how wild and ridiculous, if there is evidence for it. The wilder and more ridiculous something is, however, the firmer and more solid the evidence will have to be."+
    Isaac Asimov                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Issue with Alias and Union of CTEs

    I have a query that works in SQL Server but I'm having issues with it in PL/SQL.  I keep running into the error saying "invalid identifier" when I try to reference PlantNumber or Plant_No or any other piece of the CTE or subquery.  Is this not possible with Oracle?
    Here's a shortened version of my query:
    WITH RemoveData AS
       SELECT a.PLANT_NO,a.ALLOC_WHDV_VOL,a.KW_CTR_REDELIVERED_HV, a.MTR_NO, a.MTR_SFX, a.TRNX_ID, a.REC_STATUS_CD,
    MAX(a.ACCT_DT) ACCT_DT
       FROM GasStmt a
       WHERE a.REC_STATUS_CD = 'RR'
       GROUP BY a.PLANT_NO,a.ALLOC_WHDV_VOL,a.KW_CTR_REDELIVERED_HV, a.MTR_NO, a.MTR_SFX, a.TRNX_ID, a.REC_STATUS_CD
       HAVING COUNT(a.REC_STATUS_CD) > 2
      RemoveData2 AS
       SELECT plant_no "PlantNumber"
       ,SUM(-a.ALLOC_WHDV_VOL) "PlantStandardGrossWellheadMcf"
       ,SUM(KW_CTR_REDELIVERED_HV) "KeepWholeResidueMMBtu"
       FROM RemoveData a
       GROUP BY plant_no
      OriginalData AS
       SELECT a.PLANT_NO "PlantNumber"
       ,SUM(a.ALLOC_WHDV_VOL) "PlantStandardGrossWellheadMcf"
       ,SUM(CASE WHEN a.REC_STATUS_CD = 'RR' THEN -a.KW_CTR_REDELIVERED_HV ELSE a.KW_CTR_REDELIVERED_HV END) "KeepWholeResidueMMBtu"
       FROM GasStmt a
       LEFT OUTER JOIN (SELECT MTR_NO, MTR_SFX, TRNX_ID, REC_STATUS_CD, MAX(ACCT_DT) ACCT_DT
       FROM GasStmt
       WHERE REC_STATUS_CD = 'RR'
       GROUP BY MTR_NO, MTR_SFX, TRNX_ID, REC_STATUS_CD
       HAVING COUNT(TRNX_ID) > 1) b
       ON a.MTR_NO = b.MTR_NO
       AND a.TRNX_ID = b.TRNX_ID
       AND a.Rec_Status_Cd = b.REC_STATUS_CD
       AND a.Acct_Dt = b.ACCT_DT
       WHERE a.ACCT_DT > '1/1/2010'
       AND b.MTR_NO IS NULL
       GROUP BY a.PLANT_NO
    UnionCTE AS (  
    SELECT *
    FROM RemoveData2
    UNION
    SELECT *
    FROM OriginalData
    SELECT PlantNumber, SUM(PlantStandardGrossWellheadMcf) AS PlantStandardGrossWellheadMcf,SUM(KeepWholeResidueMMBtu) AS KeepWholeResidueMMBtu
    FROM UnionCTE
    GROUP BY PlantNumber
    It's the bottom select from UnionCTE that's causing the issue.  Any tips would be appreciated!

    I can't check it at the moment, but here's some code I forgot to post.  Thanks for your response, I'll let you know if it works for me.
    CREATE TABLE STG.GasStmt
    (PLANT_NO varchar(100),
    ALLOC_WHDV_VOL numeric(29, 5),
    KW_CTR_REDELIVERED_HV numeric(29, 5),
    MTR_NO varchar(100),
    MTR_SFX varchar(100),
    TRNX_ID bigint,
    REC_STATUS_CD varchar(100),
    ACCT_DT DateTime)
    insert into STG.GasStmt
    select '043','0','50','36563','','83062200','OR','12/1/2011' union all
    select '002','0','100','36563','','83062222','OR','12/1/2011' union all
    select '002','0','-.99','36563','','-83062299','RR','12/1/2011' union all
    select '002','0','-.99','36563','','-83062299','RR','2/1/2013' union all
    select '002','0','-.99','36563','','-83062299','RR','4/1/2013' union all
    select '002','0','-.99','36563','','83062299','OR','2/1/2011' union all
    select '002','0','-.99','36563','','-86768195','RR','12/1/2011' union all
    select '002','0','-.99','36563','','-86768195','RR','2/1/2013' union all
    select '002','0','-.99','36563','','-86768195','RR','4/1/2013' union all
    select '002','0','-.99','36563','','86768195','OR','3/1/2011' union all
    select '002','0','-.99','36563','','-90467786','RR','1/1/2012' union all
    select '002','0','-.99','36563','','-90467786','RR','2/1/2013' union all
    select '002','0','-.99','36563','','-90467786','RR','4/1/2013' union all
    select '002','0','-.99','36563','','90467786','OR','4/1/2011' union all
    select '002','0','-.99','36563','','-77671301','RR','2/1/2013' union all
    select '002','0','-.99','36563','','-77671301','RR','4/1/2013' union all
    select '002','0','-.99','36563','','77671301','OR','1/1/2011' union all
    select '002','0','-.99','36563','','-68420423','RR','2/1/2013' union all
    select '002','0','-.99','36563','','68420423','OR','4/1/2013' union all
    select '002','0','-.99','36563','','-188808446','RR','3/1/2013' union all
    select '002','0','-.99','36563','','188808446','OR','1/1/2013' union all
    select '002','1205.15','0','36563','A','138365544','OR','2/1/2012'

  • Very slow performance with UNION and UNION ALL

    I am returning three datasets as one with a UNION ALL between each of three SQL statements. The first one returns either 3 or 4 rows, the second one returns about 10 rows and the third one returns one row. The SQL statements are a little complex but they're all working on very small datasets ( < 1000 rows ) so when I run each of the three SQL statements by themselves, they run to completion and return data in less than 1 second.
    However.
    When I join the three statements together with a UNION ALL statement between them, the statement runs until I manually abort it. I've run it for up to two hours and it shows no signs of either 1) erroring or 2) running to completion. And, I've tried replacing the UNION ALL with UNION and I get the identical results - nothing returned, no error message.
    I've checked the obvious -- same column names, same number of columns, etc. I think that if there were something obvious like that, I would get an error message as soon as I attempted to execute the statements.
    I will be happy to post the code if you'd like, but I'm wondering if anyone has experienced these or similar symptoms when joining together SQL statements with UNIONs and if so what you did to get around it.
    Thanks in advance,
    Carl

    Or I guess you could use subquery factoring (WITH clause) and MATERIALIZE hints to create the temp tables inline, e.g.
    WITH table1 AS
         ( SELECT /*+ materialize */ somecolumns FROM sometable )
       , table2 AS
         ( SELECT /*+ materialize */ somecolumns FROM othertable )
       , table2 AS
         ( SELECT /*+ materialize */  somecolumns FROM anothertable )
    SELECT somecolumns FROM table1
    UNION ALL
    SELECT somecolumns FROM table2
    UNION ALL
    SELECT somecolumns FROM table3It might also be valuable to investigate exactly what is happening and why, as this might suggest a way to address the root cause.

  • UNION ALL and UNION performance issue

    Hi All,
    I am trying to figure out the data for which only receive transaction has been done and further processing is pending. These transactions include all PO, RMA , ISO etc...
    I have to use UNION ALL in this case as for RMA and ISO, details which i want are not able to gather in a single query.
    But query is taking a lot of time ...may be around 30..mins in UNION ALL while 6 to 7 mins in UNION.
    To get all records I must have to use UNION ALL...
    So kindly suggest the solution for this problem
    Thanks
    Sachin
    Query is given below...
    SELECT /* + FIRST_ROWS */ DECODE(rsl.SOURCE_DOCUMENT_CODE,'REQ',(SELECT org1.ORGANIZATION_NAME
                                                           FROM     org_organization_definitions org1
                                                           WHERE org1.ORGANIZATION_ID =
                                                           rsl.FROM_ORGANIZATION_ID)) Vendor_Name
    ,rsh.RECEIPT_NUM Receipt_Number
         ,TO_CHAR(rt3.TRANSACTION_DATE,'Mon-DD-YYYY HH:MM:SS') Receipt_Date_and_Time
         ,msi.SEGMENT1 Part_Number
         ,msi.DESCRIPTION Part_Name
         ,rt3.QUANTITY Quantity
         ,rt3.UNIT_OF_MEASURE UOM
         ,NULL ASL_Status
         --for ISO no asl flag ASL Flag
         ,TO_CHAR(TRUNC((((86400*(SYSDATE-rt3.TRANSACTION_DATE))/60)/60)/24))|| ' Days ' || TO_CHAR(TRUNC(((86400*(SYSDATE-rt3.TRANSACTION_DATE))/60)/60)-24*(TRUNC((((86400*(SYSDATE-rt3.TRANSACTION_DATE))/60)/60)/24)))|| ' Hours' Days_and_hours_passed
         ,DECODE(
                        NVL(msi.max_minmax_quantity,0) ,
                        0 , 0 ,
                        (NVL(msi.max_minmax_quantity,0) -
                        NVL(inmohqd.onhand,0))
                             * 100
                             / NVL(msi.max_minmax_quantity,0)
                        ) gap_percent
    FROM rcv_transactions rt3
         ,rcv_shipment_headers rsh
         ,rcv_shipment_lines rsl
         ,mtl_system_items msi
         ,org_organization_definitions org
         --,MTL_ONHAND_QUANTITIES_DETAIL moqhd
         ,(SELECT NVL(SUM(primary_transaction_quantity),0) onhand,INVENTORY_ITEM_ID item_id,ORGANIZATION_ID organization_id
         FROM      mtl_onhand_quantities_detail
         WHERE SUBINVENTORY_CODE NOT IN ('Wip_SF','Wip_Int','Reject','Scrap','FG Trading','FG')
         GROUP BY INVENTORY_ITEM_ID, ORGANIZATION_ID) inmohqd
    WHERE inmohqd.item_id(+) = msi.INVENTORY_ITEM_ID
         AND inmohqd.organization_id(+) = msi.ORGANIZATION_ID
         --AND inmoqhd.SUBINVENTORY_CODE NOT IN  ('Wip_SF','Wip_Int','Reject','Scrap','FG Trading','FG')
         AND msi.INVENTORY_ITEM_ID = rsl.ITEM_ID
         AND rsh.SHIPMENT_HEADER_ID = rsl.SHIPMENT_HEADER_ID
         AND org.ORGANIZATION_ID = rt3.ORGANIZATION_ID
         AND msi.ORGANIZATION_ID = rt3.ORGANIZATION_ID
         AND rsh.SHIPMENT_HEADER_ID = rt3.SHIPMENT_HEADER_ID
         AND rsl.SHIPMENT_HEADER_ID = rt3.SHIPMENT_HEADER_ID
         AND rsl.SHIPMENT_LINE_ID = rt3.SHIPMENT_LINE_ID
         AND rt3.PO_HEADER_ID IS NULL
         AND TRUNC(rt3.TRANSACTION_DATE) <= TRUNC(p_tilldate)
         AND rsl.TO_ORGANIZATION_ID = p_organization_id
         AND rsh.ORGANIZATION_ID = p_organization_id
         AND CONCAT(TRIM(rt3.SHIPMENT_HEADER_ID),TRIM(rt3.SHIPMENT_LINE_ID)) IN
         SELECT CONCAT(TRIM(rt1.SHIPMENT_HEADER_ID),TRIM(rt1.SHIPMENT_LINE_ID))
         FROM     rcv_transactions rt1
         WHERE NOT EXISTS(
         SELECT 1
              FROM     rcv_transactions rt2
              WHERE     rt2.TRANSACTION_TYPE <> 'RECEIVE'
                        AND rt1.SHIPMENT_HEADER_ID = rt2.SHIPMENT_HEADER_ID
                        AND rt1.SHIPMENT_LINE_ID = rt2.SHIPMENT_LINE_ID
                        AND rt2.ORGANIZATION_ID = p_organization_id
    UNION
    SELECT /* + FIRST_ROWS */ pv.VENDOR_NAME Vendor_Name
         ,rsh.RECEIPT_NUM Receipt_Number
         ,TO_CHAR(rt.TRANSACTION_DATE,'Mon-DD-YYYY HH:MM:SS') Receipt_Date_and_Time
         ,msi.SEGMENT1 Part_Number
         ,msi.DESCRIPTION Part_Name
         ,rt.QUANTITY Quantity
         ,rt.UNIT_OF_MEASURE UOM
         --start 001
         ,NVL((SELECT DISTINCT DECODE (ASL_STATUS_ID,1,'New',2,'Approved','To be checked')
                   FROM po_approved_supplier_list pasl
                   WHERE pasl.item_id=rsl.ITEM_ID
                             AND pasl.VENDOR_ID(+) = pv.VENDOR_ID
                             AND pasl.VENDOR_SITE_ID(+) = pvs.VENDOR_SITE_ID),'No_data') ASL_Status
              --end 001
              ,TO_CHAR(TRUNC((((86400*(SYSDATE-rt.TRANSACTION_DATE))/60)/60)/24))|| ' Days ' || TO_CHAR(TRUNC(((86400*(SYSDATE-rt.TRANSACTION_DATE))/60)/60)-24*(TRUNC((((86400*(SYSDATE-rt.TRANSACTION_DATE))/60)/60)/24)))|| ' Hours' Days_and_hours_passed          ,DECODE(
                   NVL(msi.max_minmax_quantity,0) ,
              0 , 0 ,
              (NVL(msi.max_minmax_quantity,0) -
              NVL(inmohqd.onhand,0))
                   * 100
                   / NVL(msi.max_minmax_quantity,0)
              ) gap_percent
    FROM rcv_transactions rt
         ,po_vendors pv
         ,po_vendor_sites_all pvs
         ,rcv_shipment_headers rsh
         ,rcv_shipment_lines rsl
         ,mtl_system_items msi
         ,org_organization_definitions org
         --,mtl_onhand_quantities_detail moqhd
         ,(SELECT NVL(SUM(primary_transaction_quantity),0) onhand,INVENTORY_ITEM_ID item_id,ORGANIZATION_ID organization_id
         FROM      mtl_onhand_quantities_detail
         WHERE SUBINVENTORY_CODE NOT IN ('Wip_SF','Wip_Int','Reject','Scrap','FG Trading','FG')
         GROUP BY INVENTORY_ITEM_ID, ORGANIZATION_ID) inmohqd
    WHERE inmohqd.item_id(+) = msi.INVENTORY_ITEM_ID
         AND inmohqd.ORGANIZATION_ID(+) = msi.ORGANIZATION_ID
         --AND inmoqhd.SUBINVENTORY_CODE NOT IN  ('Wip_SF','Wip_Int','Reject','Scrap','FG Trading','FG')
         AND msi.INVENTORY_ITEM_ID = rsl.ITEM_ID
         AND rsh.SHIPMENT_HEADER_ID = rsl.SHIPMENT_HEADER_ID
         AND pv.VENDOR_ID = pvs.VENDOR_ID
         AND org.ORGANIZATION_ID = rt.ORGANIZATION_ID
         AND msi.ORGANIZATION_ID = rt.ORGANIZATION_ID
         AND pvs.VENDOR_SITE_ID = rt.VENDOR_SITE_ID
         AND pv.VENDOR_ID = rt.VENDOR_ID
         AND rsh.SHIPMENT_HEADER_ID = rt.SHIPMENT_HEADER_ID
         AND rsl.SHIPMENT_HEADER_ID = rt.SHIPMENT_HEADER_ID
         AND rsl.SHIPMENT_LINE_ID = rt.SHIPMENT_LINE_ID
         AND TRUNC(rt.TRANSACTION_DATE) <= TRUNC(p_tilldate)
         AND rsl.TO_ORGANIZATION_ID = p_organization_id
         AND CONCAT(TRIM(rt.SHIPMENT_HEADER_ID),TRIM(rt.SHIPMENT_LINE_ID)) IN
              SELECT CONCAT(TRIM(rt1.SHIPMENT_HEADER_ID),TRIM(rt1.SHIPMENT_LINE_ID))
              FROM RCV_TRANSACTIONS rt1
              WHERE rt1.TRANSACTION_TYPE = 'RECEIVE'
                   AND rt1.DESTINATION_TYPE_CODE = 'RECEIVING'
                   AND rt1.PO_HEADER_ID IS NOT NULL
                   AND NOT EXISTS(
                   SELECT 1
                        FROM     RCV_TRANSACTIONS rt2
                        WHERE     rt2.SHIPMENT_HEADER_ID = rt1.SHIPMENT_HEADER_ID
                                  AND rt2.SHIPMENT_LINE_ID = rt1.SHIPMENT_LINE_ID
                                  AND rt2.TRANSACTION_TYPE <> 'RECEIVE'
         )

    In this case, for selected columns, all data is same for one of the RMA with more than one line. So UNION will skip one of the records. However, shipment line id are different for both records, so by selecting it in select list is solving the problem and so no need to use UNION ALL. But, anyhow UNION ALL is better than UNION in performance as it does not require to sort. Then why I am facing this problem...
    Kindly suggest
    Regards,
    Sachin

  • Decode and union

    Is it possible to use a decode function in the order by clause, when you have to select statements with a union?

    Hi, Tove
    Have you tried using a lexical parameter for your 'order by' clause? In the after_parameter_form trigger you could then use an 'if/else' statement to achieve the same result as a decode. This works in a simple query but I have not tried it in a union.
    Regards,
    Valerie

  • With clause and union

    any alternative solution for these kind of query? i have union in two with clause query but resulting error.
    below is a sample example.
      1   with x as (select distinct no from dbo.tt)
      2   select * from x
      3  union all
      4   with yy as (select distinct no from dbo.tt)
      5*  select * from yy
    SQL> /
    select * from yy
    ERROR at line 5:
    ORA-32034: unsupported use of WITH clause

    with x as (select distinct no from dbo.tt),
         yy as (select distinct no from dbo.tt)
    select * from x
    union all
    select * from yySY.

  • Oracle doc inconsistent on materialize view with union all and self joins

    First of all, I can't seem to create a materialized view containing self-joins AND union all. Is it possible?
    I checked Oracle 9i (my version: PL/SQL Release 9.2.0.4.0 - Production) documentation and I get different answers (or so it seems to me).
    First I saw this: "The COMPATIBILITY parameter must be set to 9.0 if the materialized aggregate view has inline views, outer joins, self joins or grouping sets and FAST REFRESH is specified during creation..."
    Did you see the part about 'self joins' in there? I did and I was pumped because that seems to say that you CAN have 'self joins' (and my compatibility is 9.2...)
    BUT
    In the very same document I also found "Oracle does not allow self-joins in materialized join views." (rage)
    You can see the document I am speaking of here: http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96520/mv.htm#574889
    Whenever I try to create the mview I get the following error. (
    In any caseORA-01446 cannot select ROWID from view with DISTINCT, GROUP BY, etc.

    First of all, I can't seem to create a materialized view containing self-joins AND union all. Is it possible?
    I checked Oracle 9i (my version: PL/SQL Release 9.2.0.4.0 - Production) documentation and I get different answers (or so it seems to me).
    First I saw this: "The COMPATIBILITY parameter must be set to 9.0 if the materialized aggregate view has inline views, outer joins, self joins or grouping sets and FAST REFRESH is specified during creation..."
    Did you see the part about 'self joins' in there? I did and I was pumped because that seems to say that you CAN have 'self joins' (and my compatibility is 9.2...)
    BUT
    In the very same document I also found "Oracle does not allow self-joins in materialized join views." (rage)
    You can see the document I am speaking of here: http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96520/mv.htm#574889
    Whenever I try to create the mview I get the following error. (
    In any caseORA-01446 cannot select ROWID from view with DISTINCT, GROUP BY, etc.

  • UNION ALL slow (cost goes from 75 and 173 to 450,789!)

    Hi,
    I have two Selects (lots of joins - big tables)
    Select A) has an explain plan cost of 75
    Select B) has an explain plan cost of 173
    If I union (or union all) the cost goes up to 450,789!
    I can paste in the queries, plans etc - but if anyone has any quick ideas that'd be great.
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    What I'd like is to force the optomiser to run each query sequentially - but not really sure how.
    Any help would be really appreciated - I have few hairs left and am just about to tear the last one out!
    Cheers,
    Patrick

    Attached are the queries and the explain plan.
    I have simply tried UNION and UNION ALL to see if there's a difference (expecting UNION ALL to be faster).. but (distinct) UNION Is what I want.
    Queries
    explain plan for
    (SELECT ety_entity_identifier "a" ,
      ety_current_name "b" ,
      gment.ety_discriminant "c" ,
      upper(ind_first_name)
      || ' '
      || upper(ind_last_name) "d" ,
      CASE
        WHEN ind_last_name = NULL
        then null
      END e
    FROM gv_emr_entity_master m
    INNER JOIN gv_ety_entities gv_ety
    ON gv_ety.ety_entity_identifier = m.mtr_identifier
    AND gv_ety.ety_ety_version      = m.mtr_current_version
    AND gv_ety.ety_reg_code         = m.mtr_reg_code
    INNER JOIN gm_ety_entities gment
    ON gment.ety_id               = gv_ety.ety_id
    INNER JOIN gv_erl_entity_roles gve
    ON m.mtr_identifier       = gve.erl_entity_identifier
    AND m.mtr_current_version = gve.erl_ety_version
    INNER JOIN gm_erl_entity_roles gme
    ON gve.erl_id = gme.erl_id
    INNER JOIN gv_imr_individual_master gvm
    ON gme.erl_ind_individual_identifier = gvm.mtr_identifier
    AND gme.erl_ind_version              = gvm.mtr_current_version
    INNER JOIN gv_ind_individuals gvi
    ON gvm.mtr_identifier       = gvi.ind_individual_identifier
    AND gvm.mtr_current_version = gvi.ind_ind_version
    INNER JOIN gm_ind_individuals gmn
    ON gvi.ind_id = gmn.ind_id
    INNER JOIN gv_ias_individual_addresses gvad
    ON gvi.ind_reg_code               = gvad.ias_reg_code
    AND gvi.ind_individual_identifier = gvad.ias_individual_identifier
    AND gvi.ind_ind_version           = gvad.ias_ind_version
    INNER JOIN gm_rfr_repository_folder gmrfr
    ON gmrfr.rfr_entity_identifier = gv_ety.ety_entity_identifier
    INNER JOIN gm_rdt_repository_documents gmrdt
    ON gmrdt.rdt_rfr_id = gmrfr.rfr_id
    INNER JOIN rdi_repository_documents_info rdire
    ON rdire.rdi_rdt_id                                   = gmrdt.rdt_id
    WHERE
    gmrdt.rdt_dte_code                               IN ('OPD','PD')
    AND TO_CHAR(rdire.rdi_submission_date, 'YYYY-MM-DD') >= TO_CHAR('2007-11-01')
    and to_char(rdire.rdi_submission_date, 'YYYY-MM-DD') <= to_char('2009-01-05')
    and rownum > 0
    and rownum < 10
    union all
    SELECT ety_entity_identifier a ,
      ety_current_name "b" ,
      gment.ety_discriminant "c" ,
      gment.ety_current_name "d" ,
      gment.ety_entity_identifier "e"
    FROM gv_emr_entity_master m
    INNER JOIN gv_ety_entities gv_ety
    ON gv_ety.ety_entity_identifier = m.mtr_identifier
    AND gv_ety.ety_ety_version      = m.mtr_current_version
    AND gv_ety.ety_reg_code         = m.mtr_reg_code
    INNER JOIN gm_ety_entities gment
    ON gment.ety_id               = gv_ety.ety_id
    INNER JOIN gv_erl_entity_roles gve
    ON m.mtr_identifier       = gve.erl_entity_identifier
    AND m.mtr_current_version = gve.erl_ety_version
    INNER JOIN gm_erl_entity_roles gm_erl
    ON gve.erl_id = gm_erl.erl_id
    INNER JOIN gv_ety_entities gv_ety_temp
    ON gm_erl.erl_entity_identifier_assoc = gv_ety_temp.ety_entity_identifier
    INNER JOIN gv_emr_entity_master gv_emr_master
    ON gv_ety_temp.ety_entity_identifier = gv_emr_master.mtr_identifier
    AND gv_ety_temp.ety_ety_version      = gv_emr_master.mtr_current_version
    INNER JOIN gm_ety_entities gm_ety_temp
    ON gm_ety_temp.ety_id = gv_ety_temp.ety_id
    INNER JOIN gv_eas_entity_addresses gva
    ON gv_ety_temp.ety_reg_code           = gva.eas_reg_code
    AND gv_ety_temp.ety_entity_identifier = gva.eas_entity_identifier
    AND gv_ety_temp.ety_ety_version       = gva.eas_ety_version
    INNER JOIN gm_rfr_repository_folder gmrfr
    ON gmrfr.rfr_entity_identifier = gv_ety.ety_entity_identifier
    INNER JOIN gm_rdt_repository_documents gmrdt
    ON gmrdt.rdt_rfr_id = gmrfr.rfr_id
    INNER JOIN rdi_repository_documents_info rdire
    on rdire.rdi_rdt_id                                   = gmrdt.rdt_id
    WHERE 
    gmrdt.rdt_dte_code                               IN ('OPD','PD')
    AND gm_erl.erl_rre_name                               = 'SHR'
    AND TO_CHAR(rdire.rdi_submission_date, 'YYYY-MM-DD') >= TO_CHAR('2007-11-01')
    and to_char(rdire.rdi_submission_date, 'YYYY-MM-DD') <= to_char('2009-01-05')
    and rownum > 0
    and rownum < 10
    Plan hash value: 91542951
    | Id  | Operation                                 | Name                          | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                          |                               |    18 |  4905 |       |   450K (46)| 01:30:10 |
    |   1 |  UNION-ALL                                |                               |       |       |       |            |          |
    |*  2 |   COUNT STOPKEY                           |                               |       |       |       |            |          |
    |*  3 |    FILTER                                 |                               |       |       |       |            |          |
    |*  4 |     HASH JOIN                             |                               |   173K|    47M|    38M|   249K  (1)| 00:49:54 |
    |*  5 |      HASH JOIN                            |                               |   151K|    36M|    36M|   231K  (1)| 00:46:24 |
    |*  6 |       HASH JOIN                           |                               |   151K|    34M|    30M|   203K  (1)| 00:40:43 |
    |*  7 |        HASH JOIN                          |                               |   151K|    28M|    27M|   182K  (1)| 00:36:35 |
    |*  8 |         HASH JOIN                         |                               |   151K|    25M|    23M|   170K  (1)| 00:34:06 |
    |*  9 |          HASH JOIN                        |                               |   151K|    21M|  4840K|   140K  (1)| 00:28:05 |
    |* 10 |           HASH JOIN                       |                               | 34132 |  4433K|  3464K|   127K  (1)| 00:25:35 |
    |* 11 |            HASH JOIN                      |                               | 34419 |  3058K|  2776K|   120K  (1)| 00:24:03 |
    |* 12 |             HASH JOIN                     |                               | 34229 |  2373K|  1912K|   117K  (1)| 00:23:35 |
    |* 13 |              HASH JOIN                    |                               | 34229 |  1504K|  1440K|   114K  (1)| 00:22:49 |
    |  14 |               NESTED LOOPS                |                               | 34229 |  1036K|       | 99509   (1)| 00:19:55 |
    |* 15 |                TABLE ACCESS FULL          | RDI_REPOSITORY_DOCUMENTS_INFO | 34205 |   467K|       | 31522   (2)| 00:06:19 |
    |* 16 |                TABLE ACCESS BY INDEX ROWID| GM_RDT_REPOSITORY_DOCUMENTS   |     1 |    17 |       |     2   (0)| 00:00:01 |
    |* 17 |                 INDEX UNIQUE SCAN         | SYS_C0082075                  |     1 |       |       |     1   (0)| 00:00:01 |
    |  18 |               TABLE ACCESS FULL           | GM_RFR_REPOSITORY_FOLDER      |  2125K|    28M|       | 11843   (1)| 00:02:23 |
    |  19 |              TABLE ACCESS FULL            | GV_ETY_ENTITIES               |   953K|    23M|       |  1958   (1)| 00:00:24 |
    |  20 |             TABLE ACCESS FULL             | GV_EMR_ENTITY_MASTER          |   951K|    18M|       |   758   (2)| 00:00:10 |
    |  21 |            TABLE ACCESS FULL              | GM_ETY_ENTITIES               |   945K|    37M|       |  5120   (1)| 00:01:02 |
    |  22 |           TABLE ACCESS FULL               | GV_ERL_ENTITY_ROLES           |  4233K|    68M|       |  6413   (1)| 00:01:17 |
    |* 23 |          TABLE ACCESS FULL                | GM_ERL_ENTITY_ROLES           |  3611K|    92M|       | 22218   (1)| 00:04:27 |
    |  24 |         TABLE ACCESS FULL                 | GV_IMR_INDIVIDUAL_MASTER      |  3994K|    83M|       |  4547   (2)| 00:00:55 |
    |  25 |        TABLE ACCESS FULL                  | GV_IND_INDIVIDUALS            |  3994K|   144M|       |  9720   (1)| 00:01:57 |
    |  26 |       TABLE ACCESS FULL                   | GM_IND_INDIVIDUALS            |  4008K|    68M|       | 20842   (1)| 00:04:11 |
    |  27 |      INDEX FAST FULL SCAN                 | FKGV_IAS_IND592213_IDX        |  4564K|   139M|       |  6062   (1)| 00:01:13 |
    |* 28 |   COUNT STOPKEY                           |                               |       |       |       |            |          |
    |* 29 |    FILTER                                 |                               |       |       |       |            |          |
    |* 30 |     HASH JOIN                             |                               |  1163K|   286M|    35M|   201K  (1)| 00:40:16 |
    |* 31 |      HASH JOIN                            |                               |   150K|    33M|    30M|   180K  (1)| 00:36:11 |
    |* 32 |       HASH JOIN                           |                               |   151K|    28M|    20M|   172K  (1)| 00:34:25 |
    |  33 |        TABLE ACCESS FULL                  | GV_EMR_ENTITY_MASTER          |   951K|     9M|       |   758   (2)| 00:00:10 |
    |* 34 |        HASH JOIN                          |                               |   151K|    27M|    25M|   168K  (1)| 00:33:46 |
    |* 35 |         HASH JOIN                         |                               |   151K|    23M|  2328K|   163K  (1)| 00:32:47 |
    |* 36 |          TABLE ACCESS FULL                | GM_ERL_ENTITY_ROLES           | 99240 |  1162K|       | 22205   (1)| 00:04:27 |
    |* 37 |          HASH JOIN                        |                               |   151K|    21M|  4840K|   140K  (1)| 00:28:05 |
    |* 38 |           HASH JOIN                       |                               | 34132 |  4433K|  3464K|   127K  (1)| 00:25:35 |
    |* 39 |            HASH JOIN                      |                               | 34419 |  3058K|  2776K|   120K  (1)| 00:24:03 |
    |* 40 |             HASH JOIN                     |                               | 34229 |  2373K|  1912K|   117K  (1)| 00:23:35 |
    |* 41 |              HASH JOIN                    |                               | 34229 |  1504K|  1440K|   114K  (1)| 00:22:49 |
    |  42 |               NESTED LOOPS                |                               | 34229 |  1036K|       | 99509   (1)| 00:19:55 |
    |* 43 |                TABLE ACCESS FULL          | RDI_REPOSITORY_DOCUMENTS_INFO | 34205 |   467K|       | 31522   (2)| 00:06:19 |
    |* 44 |                TABLE ACCESS BY INDEX ROWID| GM_RDT_REPOSITORY_DOCUMENTS   |     1 |    17 |       |     2   (0)| 00:00:01 |
    |* 45 |                 INDEX UNIQUE SCAN         | SYS_C0082075                  |     1 |       |       |     1   (0)| 00:00:01 |
    |  46 |               TABLE ACCESS FULL           | GM_RFR_REPOSITORY_FOLDER      |  2125K|    28M|       | 11843   (1)| 00:02:23 |
    |  47 |              TABLE ACCESS FULL            | GV_ETY_ENTITIES               |   953K|    23M|       |  1958   (1)| 00:00:24 |
    |  48 |             TABLE ACCESS FULL             | GV_EMR_ENTITY_MASTER          |   951K|    18M|       |   758   (2)| 00:00:10 |
    |  49 |            TABLE ACCESS FULL              | GM_ETY_ENTITIES               |   945K|    37M|       |  5120   (1)| 00:01:02 |
    |  50 |           TABLE ACCESS FULL               | GV_ERL_ENTITY_ROLES           |  4233K|    68M|       |  6413   (1)| 00:01:17 |
    |  51 |         TABLE ACCESS FULL                 | GV_ETY_ENTITIES               |   953K|    23M|       |  1958   (1)| 00:00:24 |
    |  52 |       TABLE ACCESS FULL                   | GM_ETY_ENTITIES               |   945K|    34M|       |  5102   (1)| 00:01:02 |
    |  53 |      INDEX FAST FULL SCAN                 | FKGV_EAS_ENT111959_IDX        |  7325K|   146M|       |  7127   (1)| 00:01:26 |
    Query Block Name / Object Alias (identified by operation id):
       1 - SET$1      
       2 - SEL$B4C8BCFD
      15 - SEL$B4C8BCFD / RDIRE@SEL$11
      16 - SEL$B4C8BCFD / GMRDT@SEL$10
      17 - SEL$B4C8BCFD / GMRDT@SEL$10
      18 - SEL$B4C8BCFD / GMRFR@SEL$9
      19 - SEL$B4C8BCFD / GV_ETY@SEL$1
      20 - SEL$B4C8BCFD / M@SEL$1
      21 - SEL$B4C8BCFD / GMENT@SEL$2
      22 - SEL$B4C8BCFD / GVE@SEL$3
      23 - SEL$B4C8BCFD / GME@SEL$4
      24 - SEL$B4C8BCFD / GVM@SEL$5
      25 - SEL$B4C8BCFD / GVI@SEL$6
      26 - SEL$B4C8BCFD / GMN@SEL$7
      27 - SEL$B4C8BCFD / GVAD@SEL$8
      28 - SEL$5ECD7CF3
      33 - SEL$5ECD7CF3 / GV_EMR_MASTER@SEL$17
      36 - SEL$5ECD7CF3 / GM_ERL@SEL$15
      43 - SEL$5ECD7CF3 / RDIRE@SEL$22
      44 - SEL$5ECD7CF3 / GMRDT@SEL$21
      45 - SEL$5ECD7CF3 / GMRDT@SEL$21
      46 - SEL$5ECD7CF3 / GMRFR@SEL$20
      47 - SEL$5ECD7CF3 / GV_ETY@SEL$12
      48 - SEL$5ECD7CF3 / M@SEL$12
      49 - SEL$5ECD7CF3 / GMENT@SEL$13
      50 - SEL$5ECD7CF3 / GVE@SEL$14
      51 - SEL$5ECD7CF3 / GV_ETY_TEMP@SEL$16
      52 - SEL$5ECD7CF3 / GM_ETY_TEMP@SEL$18
      53 - SEL$5ECD7CF3 / GVA@SEL$19
    Predicate Information (identified by operation id):
       2 - filter(ROWNUM<10)
       3 - filter(ROWNUM>0)
       4 - access("GVI"."IND_REG_CODE"="GVAD"."IAS_REG_CODE" AND "GVI"."IND_INDIVIDUAL_IDENTIFIER"="GVAD"."IAS_INDIVIDUAL_IDENT
                  IFIER" AND "GVI"."IND_IND_VERSION"="GVAD"."IAS_IND_VERSION")
       5 - access("GVI"."IND_ID"="GMN"."IND_ID")
       6 - access("GVM"."MTR_IDENTIFIER"="GVI"."IND_INDIVIDUAL_IDENTIFIER" AND
                  "GVM"."MTR_CURRENT_VERSION"="GVI"."IND_IND_VERSION")
       7 - access("GME"."ERL_IND_INDIVIDUAL_IDENTIFIER"="GVM"."MTR_IDENTIFIER" AND
                  "GME"."ERL_IND_VERSION"="GVM"."MTR_CURRENT_VERSION")
       8 - access("GVE"."ERL_ID"="GME"."ERL_ID")
       9 - access("M"."MTR_IDENTIFIER"="GVE"."ERL_ENTITY_IDENTIFIER" AND "M"."MTR_CURRENT_VERSION"="GVE"."ERL_ETY_VERSION")
      10 - access("GMENT"."ETY_ID"="GV_ETY"."ETY_ID")
      11 - access("GV_ETY"."ETY_ENTITY_IDENTIFIER"="M"."MTR_IDENTIFIER" AND
                  "GV_ETY"."ETY_ETY_VERSION"="M"."MTR_CURRENT_VERSION" AND "GV_ETY"."ETY_REG_CODE"="M"."MTR_REG_CODE")
      12 - access("GMRFR"."RFR_ENTITY_IDENTIFIER"="GV_ETY"."ETY_ENTITY_IDENTIFIER")
      13 - access("GMRDT"."RDT_RFR_ID"="GMRFR"."RFR_ID")
      15 - filter(TO_CHAR(INTERNAL_FUNCTION("RDIRE"."RDI_SUBMISSION_DATE"),'YYYY-MM-DD')>='2007-11-01' AND
                  TO_CHAR(INTERNAL_FUNCTION("RDIRE"."RDI_SUBMISSION_DATE"),'YYYY-MM-DD')<='2009-01-05')
      16 - filter("GMRDT"."RDT_DTE_CODE"='OPD' OR "GMRDT"."RDT_DTE_CODE"='PD')
      17 - access("RDIRE"."RDI_RDT_ID"="GMRDT"."RDT_ID")
      23 - filter("GME"."ERL_IND_INDIVIDUAL_IDENTIFIER" IS NOT NULL AND "GME"."ERL_IND_VERSION" IS NOT NULL)
      28 - filter(ROWNUM<10)
      29 - filter(ROWNUM>0)
      30 - access("GV_ETY_TEMP"."ETY_REG_CODE"="GVA"."EAS_REG_CODE" AND
                  "GV_ETY_TEMP"."ETY_ENTITY_IDENTIFIER"="GVA"."EAS_ENTITY_IDENTIFIER" AND
                  "GV_ETY_TEMP"."ETY_ETY_VERSION"="GVA"."EAS_ETY_VERSION")
      31 - access("GM_ETY_TEMP"."ETY_ID"="GV_ETY_TEMP"."ETY_ID")
      32 - access("GV_ETY_TEMP"."ETY_ENTITY_IDENTIFIER"="GV_EMR_MASTER"."MTR_IDENTIFIER" AND
                  "GV_ETY_TEMP"."ETY_ETY_VERSION"="GV_EMR_MASTER"."MTR_CURRENT_VERSION")
      34 - access("GM_ERL"."ERL_ENTITY_IDENTIFIER_ASSOC"="GV_ETY_TEMP"."ETY_ENTITY_IDENTIFIER")
      35 - access("GVE"."ERL_ID"="GM_ERL"."ERL_ID")
      36 - filter("GM_ERL"."ERL_ENTITY_IDENTIFIER_ASSOC" IS NOT NULL AND "GM_ERL"."ERL_RRE_NAME"='SHR')
      37 - access("M"."MTR_IDENTIFIER"="GVE"."ERL_ENTITY_IDENTIFIER" AND "M"."MTR_CURRENT_VERSION"="GVE"."ERL_ETY_VERSION")
      38 - access("GMENT"."ETY_ID"="GV_ETY"."ETY_ID")
      39 - access("GV_ETY"."ETY_ENTITY_IDENTIFIER"="M"."MTR_IDENTIFIER" AND
                  "GV_ETY"."ETY_ETY_VERSION"="M"."MTR_CURRENT_VERSION" AND "GV_ETY"."ETY_REG_CODE"="M"."MTR_REG_CODE")
      40 - access("GMRFR"."RFR_ENTITY_IDENTIFIER"="GV_ETY"."ETY_ENTITY_IDENTIFIER")
      41 - access("GMRDT"."RDT_RFR_ID"="GMRFR"."RFR_ID")
      43 - filter(TO_CHAR(INTERNAL_FUNCTION("RDIRE"."RDI_SUBMISSION_DATE"),'YYYY-MM-DD')>='2007-11-01' AND
                  TO_CHAR(INTERNAL_FUNCTION("RDIRE"."RDI_SUBMISSION_DATE"),'YYYY-MM-DD')<='2009-01-05')
      44 - filter("GMRDT"."RDT_DTE_CODE"='OPD' OR "GMRDT"."RDT_DTE_CODE"='PD')
      45 - access("RDIRE"."RDI_RDT_ID"="GMRDT"."RDT_ID")
    Column Projection Information (identified by operation id):
       1 - STRDEF[200], STRDEF[4000], STRDEF[400], STRDEF[4000], STRDEF[200]
       2 - "GMN"."IND_LAST_NAME"[VARCHAR2,400], "GMN"."IND_FIRST_NAME"[VARCHAR2,400],
           "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400], "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000],
           "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200]
       3 - "GMN"."IND_LAST_NAME"[VARCHAR2,400], "GMN"."IND_FIRST_NAME"[VARCHAR2,400],
           "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400], "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000],
           "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200]
       4 - (#keys=3) "GMN"."IND_LAST_NAME"[VARCHAR2,400], "GMN"."IND_FIRST_NAME"[VARCHAR2,400],
           "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400], "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000],
           "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200]
       5 - (#keys=1) "GVI"."IND_INDIVIDUAL_IDENTIFIER"[VARCHAR2,200], "GVI"."IND_IND_VERSION"[NUMBER,22],
           "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400], "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000],
           "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200], "GVI"."IND_REG_CODE"[VARCHAR2,200], "GMN"."IND_LAST_NAME"[VARCHAR2,400],
           "GMN"."IND_FIRST_NAME"[VARCHAR2,400]
       6 - (#keys=2) "GVI"."IND_INDIVIDUAL_IDENTIFIER"[VARCHAR2,200], "GVI"."IND_IND_VERSION"[NUMBER,22],
           "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400], "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000],
           "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200], "GVI"."IND_REG_CODE"[VARCHAR2,200], "GVI"."IND_ID"[NUMBER,22]
       7 - (#keys=2) "GVM"."MTR_IDENTIFIER"[VARCHAR2,200], "GVM"."MTR_CURRENT_VERSION"[NUMBER,22],
           "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000], "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200],
           "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400]
       8 - (#keys=1) "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000], "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200],
           "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400], "GME"."ERL_IND_VERSION"[NUMBER,22],
           "GME"."ERL_IND_INDIVIDUAL_IDENTIFIER"[VARCHAR2,200]
       9 - (#keys=2) "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000], "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200],
           "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400], "GVE"."ERL_ID"[NUMBER,22]
      10 - (#keys=1) "M"."MTR_IDENTIFIER"[VARCHAR2,200], "M"."MTR_CURRENT_VERSION"[NUMBER,22],
           "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400], "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200],
           "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000]
      11 - (#keys=3) "M"."MTR_IDENTIFIER"[VARCHAR2,200], "M"."MTR_CURRENT_VERSION"[NUMBER,22], "GV_ETY"."ETY_ID"[NUMBER,22]
      12 - (#keys=1) "GV_ETY"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200], "GV_ETY"."ETY_REG_CODE"[VARCHAR2,200],
           "GV_ETY"."ETY_ID"[NUMBER,22], "GV_ETY"."ETY_ETY_VERSION"[NUMBER,22]
      13 - (#keys=1) "GMRFR"."RFR_ENTITY_IDENTIFIER"[VARCHAR2,200]
      14 - (#keys=0) "GMRDT"."RDT_RFR_ID"[NUMBER,22]
      15 - "RDIRE"."RDI_RDT_ID"[NUMBER,22]
      16 - "GMRDT"."RDT_RFR_ID"[NUMBER,22]
      17 - "GMRDT".ROWID[ROWID,10]
      18 - "GMRFR"."RFR_ID"[NUMBER,22], "GMRFR"."RFR_ENTITY_IDENTIFIER"[VARCHAR2,200]
      19 - "GV_ETY"."ETY_REG_CODE"[VARCHAR2,200], "GV_ETY"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200],
           "GV_ETY"."ETY_ETY_VERSION"[NUMBER,22], "GV_ETY"."ETY_ID"[NUMBER,22]
      20 - "M"."MTR_REG_CODE"[VARCHAR2,200], "M"."MTR_IDENTIFIER"[VARCHAR2,200], "M"."MTR_CURRENT_VERSION"[NUMBER,22]
      21 - "GMENT"."ETY_ID"[NUMBER,22], "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200],
           "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000], "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400]
      22 - "GVE"."ERL_ENTITY_IDENTIFIER"[VARCHAR2,200], "GVE"."ERL_ETY_VERSION"[NUMBER,22], "GVE"."ERL_ID"[NUMBER,22]
      23 - "GME"."ERL_ID"[NUMBER,22], "GME"."ERL_IND_INDIVIDUAL_IDENTIFIER"[VARCHAR2,200], "GME"."ERL_IND_VERSION"[NUMBER,22]
      24 - "GVM"."MTR_IDENTIFIER"[VARCHAR2,200], "GVM"."MTR_CURRENT_VERSION"[NUMBER,22]
      25 - "GVI"."IND_REG_CODE"[VARCHAR2,200], "GVI"."IND_INDIVIDUAL_IDENTIFIER"[VARCHAR2,200],
           "GVI"."IND_IND_VERSION"[NUMBER,22], "GVI"."IND_ID"[NUMBER,22]
      26 - "GMN"."IND_ID"[NUMBER,22], "GMN"."IND_FIRST_NAME"[VARCHAR2,400], "GMN"."IND_LAST_NAME"[VARCHAR2,400]
      27 - "GVAD"."IAS_REG_CODE"[VARCHAR2,200], "GVAD"."IAS_INDIVIDUAL_IDENTIFIER"[VARCHAR2,200],
           "GVAD"."IAS_IND_VERSION"[NUMBER,22]
      28 - "GM_ETY_TEMP"."ETY_CURRENT_NAME"[VARCHAR2,4000], "GM_ETY_TEMP"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200],
           "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400], "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000],
           "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200]
      29 - "GM_ETY_TEMP"."ETY_CURRENT_NAME"[VARCHAR2,4000], "GM_ETY_TEMP"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200],
           "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400], "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000],
           "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200]
      30 - (#keys=3) "GM_ETY_TEMP"."ETY_CURRENT_NAME"[VARCHAR2,4000], "GM_ETY_TEMP"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200],
           "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400], "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000],
           "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200]
      31 - (#keys=1) "GV_ETY_TEMP"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200], "GV_ETY_TEMP"."ETY_ETY_VERSION"[NUMBER,22],
           "GV_ETY_TEMP"."ETY_REG_CODE"[VARCHAR2,200], "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400],
           "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000], "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200],
           "GM_ETY_TEMP"."ETY_CURRENT_NAME"[VARCHAR2,4000], "GM_ETY_TEMP"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200]
      32 - (#keys=2) "GV_ETY_TEMP"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200], "GV_ETY_TEMP"."ETY_ETY_VERSION"[NUMBER,22],
           "GV_ETY_TEMP"."ETY_ID"[NUMBER,22], "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400], "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000],
           "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200], "GV_ETY_TEMP"."ETY_REG_CODE"[VARCHAR2,200]
      33 - "GV_EMR_MASTER"."MTR_IDENTIFIER"[VARCHAR2,200], "GV_EMR_MASTER"."MTR_CURRENT_VERSION"[NUMBER,22]
      34 - (#keys=1) "GV_ETY_TEMP"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200], "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400],
           "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000], "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200],
           "GV_ETY_TEMP"."ETY_REG_CODE"[VARCHAR2,200], "GV_ETY_TEMP"."ETY_ID"[NUMBER,22], "GV_ETY_TEMP"."ETY_ETY_VERSION"[NUMBER,22]
      35 - (#keys=1) "GM_ERL"."ERL_ENTITY_IDENTIFIER_ASSOC"[VARCHAR2,200], "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000],
           "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200], "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400]
      36 - "GM_ERL"."ERL_ID"[NUMBER,22], "GM_ERL"."ERL_ENTITY_IDENTIFIER_ASSOC"[VARCHAR2,200]
      37 - (#keys=2) "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000], "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200],
           "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400], "GVE"."ERL_ID"[NUMBER,22]
      38 - (#keys=1) "M"."MTR_IDENTIFIER"[VARCHAR2,200], "M"."MTR_CURRENT_VERSION"[NUMBER,22],
           "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400], "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200],
           "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000]
      39 - (#keys=3) "M"."MTR_IDENTIFIER"[VARCHAR2,200], "M"."MTR_CURRENT_VERSION"[NUMBER,22], "GV_ETY"."ETY_ID"[NUMBER,22]
      40 - (#keys=1) "GV_ETY"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200], "GV_ETY"."ETY_REG_CODE"[VARCHAR2,200],
           "GV_ETY"."ETY_ID"[NUMBER,22], "GV_ETY"."ETY_ETY_VERSION"[NUMBER,22]
      41 - (#keys=1) "GMRFR"."RFR_ENTITY_IDENTIFIER"[VARCHAR2,200]
      42 - (#keys=0) "GMRDT"."RDT_RFR_ID"[NUMBER,22]
      43 - "RDIRE"."RDI_RDT_ID"[NUMBER,22]
      44 - "GMRDT"."RDT_RFR_ID"[NUMBER,22]
      45 - "GMRDT".ROWID[ROWID,10]
      46 - "GMRFR"."RFR_ID"[NUMBER,22], "GMRFR"."RFR_ENTITY_IDENTIFIER"[VARCHAR2,200]
      47 - "GV_ETY"."ETY_REG_CODE"[VARCHAR2,200], "GV_ETY"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200],
           "GV_ETY"."ETY_ETY_VERSION"[NUMBER,22], "GV_ETY"."ETY_ID"[NUMBER,22]
      48 - "M"."MTR_REG_CODE"[VARCHAR2,200], "M"."MTR_IDENTIFIER"[VARCHAR2,200], "M"."MTR_CURRENT_VERSION"[NUMBER,22]
      49 - "GMENT"."ETY_ID"[NUMBER,22], "GMENT"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200],
           "GMENT"."ETY_CURRENT_NAME"[VARCHAR2,4000], "GMENT"."ETY_DISCRIMINANT"[VARCHAR2,400]
      50 - "GVE"."ERL_ENTITY_IDENTIFIER"[VARCHAR2,200], "GVE"."ERL_ETY_VERSION"[NUMBER,22], "GVE"."ERL_ID"[NUMBER,22]
      51 - "GV_ETY_TEMP"."ETY_REG_CODE"[VARCHAR2,200], "GV_ETY_TEMP"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200],
           "GV_ETY_TEMP"."ETY_ETY_VERSION"[NUMBER,22], "GV_ETY_TEMP"."ETY_ID"[NUMBER,22]
      52 - "GM_ETY_TEMP"."ETY_ID"[NUMBER,22], "GM_ETY_TEMP"."ETY_ENTITY_IDENTIFIER"[VARCHAR2,200],
           "GM_ETY_TEMP"."ETY_CURRENT_NAME"[VARCHAR2,4000]
      53 - "GVA"."EAS_REG_CODE"[VARCHAR2,200], "GVA"."EAS_ENTITY_IDENTIFIER"[VARCHAR2,200], "GVA"."EAS_ETY_VERSION"[NUMBER,22]Edited by: user12839343 on Jun 14, 2010 6:43 PM

  • Performance Tuning Issues: UNION and Stored Outlines

    Hi,
    I have two questions,
    Firstly I have read this:
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14211/sql_1016.htm#i35699
    What I can understand is using UNION ALL is better than UNION.
    The ALL in UNION ALL is logically valid because of this exclusivity. It allows the plan to be carried out without an expensive sort to rule out duplicate rows for the two halves of the query.
    Can someone explain me the following sentences.
    Secondly my Oracle Database 10g is on FIRST_ROWS_1, how can stored outlines help in reducing I/O cost and response time in general?Please explain.
    Thank you,
    Adith

    Union ALL and Union
    SQL> select 1, 2 from dual
    union
    select 1, 2 from dual;
    | Id | Operation | Name | Rows | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 2 | 6 (67)| 00:00:01 |
    | 1 | SORT UNIQUE | | 2 | 6 (67)| 00:00:01 |
    | 2 | UNION-ALL | | | | |
    | 3 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
    | 4 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
    11 rows selected.
    SQL>select 1, 2 from dual
    union all
    select 1, 2 from dual;
    | Id | Operation | Name | Rows | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 2 | 4 (50)| 00:00:01 |
    | 1 | UNION-ALL | | | | |
    | 2 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
    | 3 | FAST DUAL | | 1 | 2 (0)| 00:00:01 |
    10 rows selected.
    Adith

Maybe you are looking for

  • Mac OS 10.8.4 slows down and freezes

    Hi, I am running Mac OS X Mountain Lion with the newest updates. Since 4 Weeks I am receiving error messages like this one: WindowServer[112]: CGXDisableUpdate: UI updates were forcibly disabled by application "Chrome" for over 1.00 seconds. Server h

  • OBIEE Time Series Funstion

    Hi, I have a "Gross Sales Amt LY" Formula: Ago(Gross Sales Amt, Year, 1) Now, when I hit obiee I donot see the LY column populated... however, when I query "Gross Sales Amt LW", that's last week..it's working fine... Can any of you tell me what can b

  • Service master user exit to populate work center description

    Hi experts, In IW31 work order, I need a user exit to populate the work center description to PR delivery address for control key PM03 with Service Master.  I have tried and search in vain for other BADI or user exit but none works. Is there anyone h

  • WCM: Operational Class assignment to Technical Objects

    Greetings Experts, Gurus and SAP Sages! In WCM, we are able to create an Operational Class to restrict the particular Operational Conditions & Operational Groups that are relevant for the Technical Objects. But I am having difficulty uderstanding the

  • The internal speakers are making are making a strange noise on my mac

    the internal speakers on my mac are making a strange noise they are working but its almost like there is some interfierence or something