Performance Issue in UNION ALL....

Hi,
I have a performance issue in a query using select.. union all .
There are few select statements which are joined by union all.
I need to re-frame the query such that the records from each individual select
statement can be appended into a collection variable.
I need to avoid the use of UNION ALL.
Can anyone please help me out in this issue?
Please find the select statement below.
SELECT *
FROM v_gfd1_asset_allocation
WHERE NVL(value,0) <> 0
AND scheme = p_scheme_id
UNION ALL
SELECT *
FROM v_gfd1_capitalization_alloc
WHERE NVL(value,0) <> 0
AND scheme = p_scheme_id
UNION ALL
SELECT *
FROM v_gfd1_currency_allocation
WHERE NVL(value,0) <> 0
AND scheme = p_scheme_id
Thanks,
Santhosh

The UNION ALL takes the result set of one query, appends the result set of the next, and so forth. No sorting or filtering takes place. So, as each query has to be executed to completion, I do not think there is another way - that is what union all is for.
You would probably do well to examine each query's access path. Would an index on NVL( value, 0 ), scheme help, for instance? Understanding the data distribution in the table and how it affects the execution plan would help you improve query performance.

Similar Messages

  • Issue with union all in sql

    Hi All,
    I have a requirement as below.
    SELECT 'A' AS 'XXX' FROM DUAL
    UNION ALL
    SELECT 'B' AS 'XXX' FROM DUAL
    I need to check in such a way in my second sql query if 'B'='A' then i need to print 'A' else 'B' , means in my second query i need to compare the value of XXX with the first query value of XXX if it is same then i need to print first query's value of XXX or else need to print second queries XXX value.
    Please help me on this

    user13424229 wrote:
    Hi All,
    I have a requirement as below.
    SELECT 'A' AS 'XXX' FROM DUAL
    UNION ALL
    SELECT 'B' AS 'XXX' FROM DUAL
    I need to check in such a way in my second sql query if 'B'='A' then i need to print 'A' else 'B' , means in my second query i need to compare the value of XXX with the first query value of XXX if it is same then i need to print first query's value of XXX or else need to print second queries XXX value.
    Please help me on thisYour quesiton is not very clear, I would suggest you read {message:id=9360002}.
    If you are looking at a way to see the next or previous row from your current row then you can use LEAD or LAG analytical function. They are well documented. You can read all about it there.

  • Performance issue with brand new intel iMac extreme

    I am at a loss to explain a problem I've been having and I thought I might put it out to you guys.
    In September I purchased a macbook Pro (2.4 ghz, 4 GB RAM) to use in video editing with Final Cut Pro, and for the most part I've been thrilled. I use 1TB LaCie external drives connected via FW800, and perform Multiclip editing with 4-5 video streams at a time and only on occasion have dropped frames during the editing process.
    In December I determined that I needed to have an additional system, and thought a 2.8Ghz Intel iMac extreme would be an excellent choice, since for the same price I could get a little more power in the processor, more hard drive space and a bigger screen to work on. When we picked up the new system in the store (The Grove Apple Store in LA), we had them upgrade the memory to 4GB.
    Since day one we have had performance issues, including problems playing streaming and DVD video, severe delays mounting and unmounting drives (firewire and USB) and application images, and freezing while doing even simple tasks like printing or checking email. These problems occur even while there are no external drives are connected. I have none of these issues with the Macbook Pro, which has virtually an identical set of programs installed, and both running the same version of Leopard.
    I already took the original iMac back to the store, and they exchanged it, but did not have 4GB sets of RAM in stock so they took the RAM from the original machine and put it in the new one. They said if I continued to have problems then it was most likely the RAM and I should come back when they got more in stock. I DID have the same problems with the new machine, and took it back to the Apple Store and they swapped the memory. It seemed to improve the issue, but now I'm seeing the same severe performance issues again.
    All tech support can do is tell me to do a PRAM reset, which seems to improve things very temporarily (but that may be my imagination) or have me restart, which at least has the ability to make the printing of documents capable.
    What I'm wondering is if it is likely that the RAM is the issue and I just got another bad batch, or if the iMac has some weird glitch that isn't present in the macbook Pro...?? Or could I have possibly gotten 2 bad systems in a row? It's extremely frustrating, and I KNOW it shouldn't be this way! It's so bad I get better performance out of my single-core G5 tower! How do I get a good working system that operates like it should? Am I better off getting another Macbook Pro? I'd rather not for several reasons...
    I have xbench on both the MBP and the iMac and can provide test numbers if they'll help, as well as any other info.
    Thank you so much for reading my novella of a post and also for any insight you have!
    Best,
    Travis

    Hi!
    I got the same problem with my MacBook when it still was new in may 2006. It was supposed to be one of the faster Laptops around but it was soooo slow it drove me nuts. I can only advise to have a look if there is something hugging up your RAM and run some tests using these programs on your machine:
    Xbench:
    http://www.macupdate.com/info.php/id/10081
    MenuMeters:
    http://www.macupdate.com/info.php/id/10451
    If they show any unusual results you might have your problem...
    As to my problem with the MacBook: I did a complete re-install (writing the harddisk over with zeroes) and suddenly everything was just fine. (But be sure to back all your files before that, I learned this one the hard way.) I know it is just a standard answer, but it worked out for me this time...
    Hope this helps in some ways.
    Cheers,
    Rene

  • Performance Issue in VA01

    Hi Experts
    We are facing big problem in the performance while providing the material codes in the transaction VA01.When we provide material numbers, it take long time to response during peak hours. This performance issue is affecting all the countries of our customer. If anyone come across the same scenario, please suggest the solutions handled in your case.
    Thanks
    Jey
    SDCS Consultant

    Hi,
    performance of the system is slowing down, may be one of the reason is log created by user.
    type oraarch in your system and search, select the unwanted log in terms of date.  please do not delete,  back up in CD or pendrive.
    by doing this also can speed up the system.
    thanks.

  • 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

  • Improve performance with union all

    Hello there,
    Oracle Database 11g Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    SQL> show parameter optimizer
    ORA-00942: Tabel of view bestaat niet. (Does not exist)I have the following query using the following input variables
    - id
    - startdate
    - enddate
    The query has the following format
    - assume that the number of columns are the same
    - t1 != t3 and t2 != t4
    select ct.*
    from
      select t1.*
      from   tabel1 t1
        join tabel2 t2
          on t2.key = t1.key
      union all
      select t3.*
      from   tabel3 t3
        join tabel4 t4
          on t4.key = t3.key
    where ct.id = :id
      and ct.date >= :startdate
      and ct.date < :enddate
    order by ct.dateIt is performing really slow, after the first read it performs fast.
    I tried the following thing, which was actually even slower!
    with t1c as
    select t1.*
      from   tabel1 t1
        join tabel2 t2
          on t2.key = t1.key
    where t1.id = :id
      and t1.date >= :startdate
      and t1.date < :enddate
    t2c as
    select t3.*
      from   tabel3 t3
        join tabel4 t4
          on t4.key = t3.key
    where t3.id = :id
      and t3.date >= :startdate
      and t3.date < :enddate
    select ct.*
    from
      select *
      from   t1c
      union all
      select *
      from   t2c
    order by ct.dateSo in words, I have an 'union all' construction reading from different tables with matching columns 'id' and 'date'.
    How can I improve this? Can it be improved? If you do not know the answer, but maybe a suggestion, I will be happy aswell!!!
    Thanks in advance!
    Kind regards,
    Metroickha

    >
    So in words, I have an 'union all' construction reading from different tables with matching columns 'id' and 'date'.
    How can I improve this? Can it be improved? If you do not know the answer, but maybe a suggestion, I will be happy aswell!!!
    >
    If you want to improve on what Oracle is doing you first need to know 'what Oracle is doing'.
    Post the execution plans for the query that show what Oracle is doing.
    Also post the DDL for the tables and indexes and the record counts for the tables and ID/DATE predicates.

  • Performance using UNION ALL

    Hello
    i have 2 schemas S1 and S2 containing complex relational tables. The tables in each schema are related to each other via foreign key relationships. i made views for feature tables in both the schemas , querying column values from their related tables.
    the data structure in both the schemas are exactly the same. Dut to management reasons we have to split them in 2 schemas. S1 contain data for region A and S2 contains data from region B. Now the client wants to see a combined data from region A & B.
    we are planning to create another schema S3 and make views combining views from S1 and S2 in both schemas (V1 in S1 + V1 in S2) using UNION ALL.
    Does UNION ALL will make use of the indexes we already built for parent tables in S1 and S2? Will there be a performance degradation using this approach? What can be the best approach? Our client needs to see real time data....
    regards
    sam

    Since union does an extra sort it has a performance difference compared to union all.
    SQL> select user from dual union select user from dual ;
    USER
    HR
    SQL> select user from dual union all select user from dual ;
    USER
    HR
    HRİf there is up to date and appropriate object statistics Oracle's Cost Based Optimizer will choose best access path, join method and join order depending on your query. Only exceptions are hints, outlines and sql profiles since they stabilize the execution plan.
    For further commenting please post your oracle version, query's test results and its statistics taken from sql*plus timing and autotrace options - http://www.bhatipoglu.com/entry/17/oracle-performance-analysis-tracing-and-performance-evaluation

  • Performing UNION/UNION ALL in views

    I have two databases (DB1 AND DB2) in same server. I have to create two views (V1 AND V2) respectively in DB1 and DB2. And I have to make an union/union all operation in these views (V1 and V2). Is this possible.???.
    Or can I create a single view instead of two views in such a way that the single view contains an union/union all operation between the data taken from two DBs (DB1 and DB2).?
    Any ideas or suggestions on these questions. Your help is well appreciated.
    Thanks in advance.

    Or can I create a single view instead of two views in such a way that the single view contains an union/union all operation between the data taken from two DBs (DB1 and DB2).?
    Make sure you do very thorough testing if you plan to use UNION since that requires a sort operation. And that means that the data from one query has to be sent to the other server before it can be sorted.
    So a query issued on DB1 might sent the DB1 data to DB2 and then send the sorted result back to DB1. But the same query issued on DB2 would already have the DB2 data so after the DB1 data is sent to DB2 and sorted the query is done.
    That is, in one case the entire result set may be sent over the network from one server to the other instead of just one table.

  • TS3694 I am using iphone 3gs, I upgraded my i-os to 6.0 from 5.1.1 however I am facing performance issue, along with this all the applications including settings or any other shuts down automatically. Is there any way by which I can use my phone in better

    I am using iphone 3gs, I upgraded my i-os to 6.0 from 5.1.1 however I am facing performance issue, along with this all the applications including settings or any other shuts down automatically. Is there any way by which I can use my phone in better way?

    No, downgrading from any version of iOS to an earlier version is not supported.

  • Performance issue ! all java guru invited

    hi !
    plz let me know is there any performance related difference between these two approachs
    mention below.
    Ist
    public void method1()
    for(int i=0;i<20;i++)
    String temp = "str"+i;
    myObject mobj = new myObject();
    2nd
    String temp="":
    myObject mobj=null;
    public void method1(){
    for(int i=0;i<20;i++)
    temp = "str"+i;
    mobj = new myObject();
    }

    Find out! Get the loop to run 20000 times and time each using System.currentTimeMillis(). Repeat this several times for each, throw away the highest and lowest couple of results and average the rest. Compare this between the two approaches.
    Regardless, the performance difference is likely to be minor, if any, compared to the construction and allocation of memory for the new Objects. I would hope that most reasonable compilers would be able to deal with these anyway.
    Performance issues aside, many people prefer the former approach since each local variable doesn't outstay its welcome. This makes debugging and refactoring more straightforward. As with all optimisations, it's not worth making them at the expense of clarity if they make no real difference.
    Test the performance of your code, in the context of your application, in realistic circumstances. You'll soon find out where your effort should be spent on optimisations.
    Hope this helps.

  • Update..Union All   Vs  multiple individual Updates -- performance?

    Hi All,
    I have a procedure which fetches data from a remote database. It performs multiple updates on a single table. Will it be any better in terms of performance if I have all the updates combined into one update using a UNION ALL.
    Please advice in terms of performance or any other options of improving performance..
    INSERT INTO BALAN (
    deal_id, projection_period, deposit, spread
    SELECT DEALID, 1, nvl(to_char(sum(avg_deposit) / count(avg_deposit), '99999999999.99'), 0) deposit,
    nvl(to_char(sum(avg_float)/ count(avg_float), '99999999999.99'), 0) spread
    FROM BILLING.CAP_ANST1@LINK_BILLN01D a
    WHERE account = AACCOUNT
    AND group_ind = GROUPID
    AND stamp = v_stamp_date
    UNION ALL
    SELECT DEALID, 3, nvl(to_char(sum(avg_deposit) / count(avg_deposit), '99999999999.99'), 0) deposit,
    nvl(to_char(sum(avg_float)/ count(avg_float), '99999999999.99'), 0) spread
    FROM BILLING.CAP_ANST1@LINK_BILLN01D
    WHERE account = AACCOUNT
    AND group_ind = GROUPID
    AND stamp >= v_stamp_date_minus_2
    UNION ALL
    SELECT DEALID, 6, nvl(to_char(sum(avg_deposit) / count(avg_deposit), '99999999999.99'), 0) deposit,
    nvl(to_char(sum(avg_float)/ count(avg_float), '99999999999.99'), 0) spread
    FROM BILLING.CAP_ANST1@LINK_BILLN01D
    WHERE account = AACCOUNT
    AND group_ind = GROUPID
    AND stamp >= v_stamp_date_minus_5
    UNION ALL
    SELECT DEALID, 12, nvl(to_char(sum(avg_deposit) / count(avg_deposit), '99999999999.99'), 0) deposit,
    nvl(TO_CHAR(SUM(avg_float)/ COUNT(avg_float), '99999999999.99'), 0) spread
    FROM billing.CAP_ANST1@LINK_BILLN01D a
    WHERE account = AACCOUNT
    AND group_ind = GROUPID
    AND stamp >= v_stamp_date_minus_11;
    ---------------- OR---------------------------------
    INSERT INTO IDM.balan
    (DEAL_id, PROJECTION_PERIOD, deposit, spread)
    SELECT DEALID, 1, nvl(SUM (avg_deposit) / COUNT (avg_deposit), 0) deposit,
    nvl(SUM (avg_float) / COUNT (avg_float),0) spread
    FROM BILLING.CAP_ANST1@LINK_BILLN01D a
    WHERE aaccount = a.ACCOUNT
    AND a.group_ind = groupid
    AND stamp = (SELECT to_date(value, 'MM/DD/YYYY')
    FROM APP_ENV
    WHERE name = 'CUR_STAMP');
    INSERT INTO IDM.balan
    (DEAL_id, projection_period, deposit, spread)
    SELECT DEALID, 3, nvl( TO_CHAR(SUM (avg_deposit) / COUNT (avg_deposit), '99999999999.99'),0) deposit,
    nvl( TO_CHAR(SUM (avg_float)/ COUNT (avg_float), '99999999999.99'),0) spread
    FROM BILLING.CAP_ANST1@LINK_BILLN01D a
    WHERE aaccount = a.ACCOUNT
    AND a.group_ind = groupid
    AND stamp >= (SELECT ADD_MONTHS (to_date(value, 'MM/DD/YYYY'), -2)
    FROM APP_ENV
    WHERE name = 'CUR_STAMP');
    INSERT INTO IDM.balan
    (DEAL_ID, projection_period, deposit, spread)
    SELECT DEALID, 6,
    nvl( TO_CHAR(SUM (avg_deposit) / COUNT (avg_deposit), '99999999999.99'),0) deposit,
    nvl( TO_CHAR(SUM (avg_float)/ COUNT (avg_float), '99999999999.99'),0) spread
    FROM billing.CAP_ANST1@LINK_BILLN01D a
    WHERE a.ACCOUNT = aaccount
    AND a.group_ind = groupid
    AND stamp >= (SELECT ADD_MONTHS (to_date(value, 'MM/DD/YYYY'), -5)
    FROM APP_ENV
    WHERE name = 'CUR_STAMP');
    INSERT INTO IDM.balan
    (DEAL_ID, projection_period, deposit, spread)
    SELECT DEALID, 12, nvl( TO_CHAR(SUM (avg_deposit) / COUNT (avg_deposit), '99999999999.99'),0) deposit,
    nvl( TO_CHAR(SUM (avg_float)/ COUNT (avg_float), '99999999999.99'),0) spread
    FROM billing.CAP_ANST1@LINK_BILLN01D a
    WHERE aaccount = a.ACCOUNT
    AND a.group_ind = groupid
    AND stamp >= (SELECT ADD_MONTHS (to_date(value, 'MM/DD/YYYY'), -11)
    FROM APP_ENV
    WHERE name = 'CUR_STAMP');
    Thanks in advance!
    Appreciate your help!
    Thanks
    Bob

    Hi Bob,
    Maybe I misunderstood, but couldn't you just:
    insert into balan(deal_id
                     ,projection_period
                     ,deposit
                     ,spread)
       select dealid
             ,case
                 when stamp  = v_stamp_date          then 1
                 when stamp >= v_stamp_date_minus_2  then 3
                 when stamp >= v_stamp_date_minus_5  then 6
                 when stamp >= v_stamp_date_minus_11 then 12
              end
                 projection_period
             ,nvl(to_char(sum(avg_deposit) / count(avg_deposit), '99999999999.99')
                 ,0)
                 deposit
             ,nvl(to_char(sum(avg_float) / count(avg_float), '99999999999.99'), 0)
                 spread
         from billing.cap_anst1@link_billn01d a
        where account = aaccount
          and group_ind = groupid
          and stamp between v_stamp_date_minus_11 and v_stamp;Regards
    Peter

  • WEBUTIL - Does adding it to all forms cause performance issues?

    If I add the webutil library and object library to all forms in the system (as part of a standard template) despite the fact most won't use it, will this cause any performance issues???
    Thanks in advance...

    The webutil user guide has a chapter on performance considerations. Have you looked at that?
    The number one point from that chapter is:
    1. Only WebUtil Enable Forms that actually need the functionality. Each form that is WebUtil enabled will generate a certain amount of network traffic and memory
    usage simply to instantiate the utility, even if you don’t use any WebUtil
    functionality.

  • 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..

  • UNION ALL destroys performance

    Strangely, we have 2 queries, which when they run independently, run pretty fast (2 seconds for one, instantaneous for the other), but when they're concatenated into a UNION ALL query with no ORDER BY clause, it takes 45 seconds for it to run.
    We tried pushing the SQL into a WITH clause, and some other subquery rewrites, but no perfomance boost. Has anyone seen this before?
    version 10.1.0.4
    --=Chuck

    Here are the results from DBMS_XPLAN. The prior explain plan was copied & pasted from TOAD.
    SQL> explain plan for SELECT   rownum, RUN_DATE.RUN_DATE,
      2           RUN_TIME.RUN_TIME,
      3           cc_report_work.report_name,
      4           cc_report_work.line_sequence,
      5           PURGE_DATE.PURGE_DATE,
      6           NULL AS LAD_GROUP,
      7           NULL AS NP_REASON,
      8           SUBSTR (cc_report_work.print_line, 11, 8) AS FILENR,
      9           SUBSTR (cc_report_work.print_line, 21, 27) AS CLAIMANT,
    10           SUBSTR (cc_report_work.print_line, 48, 10) AS LAD,
    11           SUBSTR (cc_report_work.print_line, 62, 11) AS SSN
    12    FROM   claims.cc_report_work,
    13           (SELECT   report_name, SUBSTR (print_line, 7, 8) AS RUN_DATE
    14              FROM   claims.cc_report_work
    15             WHERE   report_name = 'CC2518B' AND line_sequence = 8) RUN_DATE,
    16           (SELECT   report_name, SUBSTR (print_line, 124, 5) AS RUN_TIME
    17              FROM   claims.cc_report_work
    18             WHERE   report_name = 'CC2518A' AND line_sequence = 2) RUN_TIME,
    19           (SELECT   DISTINCT
    20                     report_name, SUBSTR (print_line, 66, 10) AS PURGE_DATE
    21              FROM   claims.cc_report_work
    22             WHERE   cc_report_work.report_name = 'CC2518B'
    23                     AND SUBSTR (cc_report_work.print_line, 54, 11) =
    24                           'Purged Thru') PURGE_DATE
    25   WHERE   cc_report_work.report_name = 'CC2518B'
    26           AND SUBSTR (cc_report_work.print_line, 14, 1) = ' '
    27           AND TRIM (cc_report_work.print_line) <>
    28                 'M A N U A L   P U R G E   L I S T I N G'
    29           AND cc_report_work.report_name = RUN_DATE.report_name
    30           AND cc_report_work.report_name = PURGE_DATE.report_name;
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3196380662
    | Id  | Operation               | Name           | Rows  | Bytes | Cost (%CPU)|Time     |
    PLAN_TABLE_OUTPUT
    |   0 | SELECT STATEMENT        |                |     1 |   206 | 16903   (2)|00:03:23 |
    |   1 |  COUNT                  |                |       |       |            |         |
    |   2 |   MERGE JOIN CARTESIAN  |                |     1 |   206 | 16903   (2)|00:03:23 |
    |*  3 |    HASH JOIN            |                |     1 |   192 | 12674   (2)|00:02:33 |
    |   4 |     MERGE JOIN CARTESIAN|                |     1 |   128 |  8445   (2)|00:01:42 |
    |*  5 |      TABLE ACCESS FULL  | CC_REPORT_WORK |     1 |    64 |  4222   (2)|00:00:51 |
    |   6 |      BUFFER SORT        |                |     1 |    64 |  4222   (2)|00:00:51 |
    |*  7 |       TABLE ACCESS FULL | CC_REPORT_WORK |     1 |    64 |  4222   (2)|00:00:51 |
    |*  8 |     TABLE ACCESS FULL   | CC_REPORT_WORK |     1 |    64 |  4229   (2)|00:00:51 |
    |   9 |    BUFFER SORT          |                |     1 |    14 | 12675   (2)|00:02:33 |
    |  10 |     VIEW                |                |     1 |    14 |  4230   (2)|00:00:51 |
    |  11 |      SORT UNIQUE        |                |     1 |    62 |  4230   (2)|00:00:51 |
    |* 12 |       TABLE ACCESS FULL | CC_REPORT_WORK |     1 |    62 |  4229   (2)|00:00:51 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
       3 - access("CC_REPORT_WORK"."REPORT_NAME"="REPORT_NAME")
       5 - filter("REPORT_NAME"='CC2518B' AND "LINE_SEQUENCE"=8)
       7 - filter("REPORT_NAME"='CC2518A' AND "LINE_SEQUENCE"=2)
       8 - filter("CC_REPORT_WORK"."REPORT_NAME"='CC2518B' AND
                  SUBSTR("CC_REPORT_WORK"."PRINT_LINE",14,1)=' ' AND
                  TRIM("CC_REPORT_WORK"."PRINT_LINE")<>'M A N U A L   P U R G E   L I S T I N G')
      12 - filter("CC_REPORT_WORK"."REPORT_NAME"='CC2518B' AND
    PLAN_TABLE_OUTPUT
                  SUBSTR("CC_REPORT_WORK"."PRINT_LINE",54,11)='Purged Thru')
    31 rows selected.
    SQL> explain plan for SELECT   rownum, RUN_DATE.RUN_DATE,
      2           RUN_TIME.RUN_TIME,
      3           cc_report_work.report_name,
      4           cc_report_work.line_sequence,
      5           PURGE_DATE.PURGE_DATE,
      6           LAD_GROUP.LAD_GROUP,
      7           NP_REASON.NP_REASON,
      8           SUBSTR (cc_report_work.print_line, 11, 8) AS FILENR,
      9           SUBSTR (cc_report_work.print_line, 21, 31) AS CLAIMANT,
    10           SUBSTR (cc_report_work.print_line, 52, 10) AS LAD,
    11           SUBSTR (cc_report_work.print_line, 70, 11) AS SSN
    12    FROM   claims.cc_report_work,
    13           (SELECT   DISTINCT
    14                     report_name, SUBSTR (print_line, 7, 8) AS RUN_DATE
    15              FROM   claims.cc_report_work
    16             WHERE   report_name = 'CC2518C'
    17                     AND SUBSTR (print_line, 7, 8) LIKE '%/%/%') RUN_DATE,
    18           (SELECT   report_name, SUBSTR (print_line, 124, 5) AS RUN_TIME
    19              FROM   claims.cc_report_work
    20             WHERE   report_name = 'CC2518A' AND line_sequence = 2) RUN_TIME,
    21           (SELECT   DISTINCT
    22                     report_name, SUBSTR (print_line, 67, 10) AS PURGE_DATE
    23              FROM   claims.cc_report_work
    24             WHERE   report_name = 'CC2518C'
    25                     AND SUBSTR (print_line, 37, 29) =
    26                           'Claims with No Activity since') PURGE_DATE,
    27           (SELECT   TRIM (print_line) AS LAD_GROUP, page_advance
    28              FROM   claims.cc_report_work
    29             WHERE   report_name = 'CC2518C'
    30                     AND SUBSTR (print_line, 11, 13) = 'Last Activity')
    31           LAD_GROUP,
    32           (SELECT   TRIM (print_line) AS NP_REASON,
    33                     page_advance,
    34                     line_sequence,
    35                     LEAD (page_advance, 1, NULL)
    36                        OVER (ORDER BY page_advance, line_sequence)
    37                        AS NEXT_PAGE,
    38                     LEAD (line_sequence, 1, NULL)
    39                        OVER (ORDER BY page_advance, line_sequence)
    40                        AS NEXT_LINE
    41              FROM   claims.cc_report_work
    42             WHERE   cc_report_work.report_name = 'CC2518C'
    43                     AND SUBSTR (cc_report_work.print_line, 11, 20) =
    44                           'Reason for Non-Purge') NP_REASON
    45   WHERE       cc_report_work.report_name = 'CC2518C'
    46           AND cc_report_work.page_advance = LAD_GROUP.page_advance
    47           AND cc_report_work.report_name = PURGE_DATE.report_name
    48           AND cc_report_work.report_name = RUN_DATE.report_name
    49           AND SUBSTR (cc_report_work.print_line, 14, 1) = '-'
    50           AND ( (cc_report_work.page_advance = NP_REASON.page_advance
    51                  AND cc_report_work.line_sequence BETWEEN NP_REASON.line_sequence
    52                                                       AND  NP_REASON.NEXT_LINE)
    53                OR (    cc_report_work.page_advance = NP_REASON.page_advance
    54                    AND NP_REASON.NEXT_PAGE IS NULL
    55                    AND NP_REASON.NEXT_LINE IS NULL
    56                    AND cc_report_work.line_sequence > NP_REASON.line_sequence));
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 1773249683
    | Id  | Operation                 | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    PLAN_TABLE_OUTPUT
    |   0 | SELECT STATEMENT          |                |     1 |   381 | 25361   (2)| 00:05:05 |
    |   1 |  COUNT                    |                |       |       ||          |
    |   2 |   NESTED LOOPS            |                |     1 |   381 | 25361   (2)| 00:05:05 |
    |   3 |    MERGE JOIN CARTESIAN   |                |     1 |   221 | 21131   (2)| 00:04:14 |
    |   4 |     MERGE JOIN CARTESIAN  |                |     1 |   207 | 16902   (2)| 00:03:23 |
    |*  5 |      HASH JOIN            |                |     1 |   194 | 12672   (2)| 00:02:33 |
    |   6 |       MERGE JOIN CARTESIAN|                |     1 |   128 |  8447   (2)| 00:01:42 |
    |*  7 |        TABLE ACCESS FULL  | CC_REPORT_WORK |     1 |    64 |  4222   (2)| 00:00:51 |
    |   8 |        BUFFER SORT        |                |     1 |    64 |  4225   (2)| 00:00:51 |
    |*  9 |         TABLE ACCESS FULL | CC_REPORT_WORK |     1 |    64 |  4225   (2)| 00:00:51 |
    |* 10 |       TABLE ACCESS FULL   | CC_REPORT_WORK |     1 |    66 |  4225   (2)| 00:00:51 |
    |  11 |      BUFFER SORT          |                |     1 |    13 | 12677   (2)| 00:02:33 |
    |  12 |       VIEW                |                |     1 |    13 |  4230   (2)| 00:00:51 |
    |  13 |        SORT UNIQUE        |                |     1 |    62 |  4230   (2)| 00:00:51 |
    |* 14 |         TABLE ACCESS FULL | CC_REPORT_WORK |     1 |    62 |  4229   (2)| 00:00:51 |
    |  15 |     BUFFER SORT           |                |     1 |    14 | 16902   (2)| 00:03:23 |
    |  16 |      VIEW                 |                |     1 |    14 |  4230   (2)| 00:00:51 |
    |  17 |       SORT UNIQUE         |                |     1 |    62 |  4230   (2)| 00:00:51 |
    |* 18 |        TABLE ACCESS FULL  | CC_REPORT_WORK |     1 |    62 |  4229   (2)| 00:00:51 |
    |* 19 |    VIEW                   |                |     1 |   160 |  4230   (2)| 00:00:51 |
    |  20 |     WINDOW SORT           |                |     1 |    66 |  4230   (2)| 00:00:51 |
    |* 21 |      TABLE ACCESS FULL    | CC_REPORT_WORK |     1 |    66 |  4229   (2)| 00:00:51 |
    Predicate Information (identified by operation id):
       5 - access("CC_REPORT_WORK"."PAGE_ADVANCE"="PAGE_ADVANCE")
       7 - filter("REPORT_NAME"='CC2518A' AND "LINE_SEQUENCE"=2)
       9 - filter("PAGE_ADVANCE" IS NOT NULL AND "REPORT_NAME"='CC2518C' AND
                  SUBSTR("PRINT_LINE",11,13)='Last Activity')
      10 - filter("CC_REPORT_WORK"."PAGE_ADVANCE" IS NOT NULL AND
                  "CC_REPORT_WORK"."REPORT_NAME"='CC2518C' AND
                  SUBSTR("CC_REPORT_WORK"."PRINT_LINE",14,1)='-')
      14 - filter("REPORT_NAME"='CC2518C' AND SUBSTR("PRINT_LINE",7,8) LIKE '%/%/%')
      18 - filter("REPORT_NAME"='CC2518C' AND SUBSTR("PRINT_LINE",37,29)='Claims with No Activity since')
      19 - filter("CC_REPORT_WORK"."PAGE_ADVANCE"="NP_REASON"."PAGE_ADVANCE" AND
                  "CC_REPORT_WORK"."PAGE_ADVANCE" IS NOT NULL AND
                  "CC_REPORT_WORK"."LINE_SEQUENCE">="NP_REASON"."LINE_SEQUENCE" AND
                  "CC_REPORT_WORK"."LINE_SEQUENCE"<="NP_REASON"."NEXT_LINE" OR
                  "CC_REPORT_WORK"."PAGE_ADVANCE"="NP_REASON"."PAGE_ADVANCE" AND
                  "CC_REPORT_WORK"."PAGE_ADVANCE" IS NOT NULL AND "NP_REASON"."NEXT_PAGE" IS NULL AND
                  "NP_REASON"."NEXT_LINE" IS NULL AND "CC_REPORT_WORK"."LINE_SEQUENCE">"NP_REASON"."LINE_SEQUENCE")
      21 - filter("CC_REPORT_WORK"."REPORT_NAME"='CC2518C' AND
                  SUBSTR("CC_REPORT_WORK"."PRINT_LINE",11,20)='Reason for Non-Purge')
    52 rows selected.
    SQL> explain plan for SELECT   rownum, RUN_DATE.RUN_DATE,
      2           RUN_TIME.RUN_TIME,
      3           cc_report_work.report_name,
      4           cc_report_work.line_sequence,
      5           PURGE_DATE.PURGE_DATE,
      6           NULL AS LAD_GROUP,
      7           NULL AS NP_REASON,
      8           SUBSTR (cc_report_work.print_line, 11, 8) AS FILENR,
      9           SUBSTR (cc_report_work.print_line, 21, 27) AS CLAIMANT,
    10           SUBSTR (cc_report_work.print_line, 48, 10) AS LAD,
    11           SUBSTR (cc_report_work.print_line, 62, 11) AS SSN
    12    FROM   claims.cc_report_work,
    13           (SELECT   report_name, SUBSTR (print_line, 7, 8) AS RUN_DATE
    14              FROM   claims.cc_report_work
    15             WHERE   report_name = 'CC2518B' AND line_sequence = 8) RUN_DATE,
    16           (SELECT   report_name, SUBSTR (print_line, 124, 5) AS RUN_TIME
    17              FROM   claims.cc_report_work
    18             WHERE   report_name = 'CC2518A' AND line_sequence = 2) RUN_TIME,
    19           (SELECT   DISTINCT
    20                     report_name, SUBSTR (print_line, 66, 10) AS PURGE_DATE
    21              FROM   claims.cc_report_work
    22             WHERE   cc_report_work.report_name = 'CC2518B'
    23                     AND SUBSTR (cc_report_work.print_line, 54, 11) =
    24                           'Purged Thru') PURGE_DATE
    25   WHERE   cc_report_work.report_name = 'CC2518B'
    26           AND SUBSTR (cc_report_work.print_line, 14, 1) = ' '
    27           AND TRIM (cc_report_work.print_line) <>
    28                 'M A N U A L   P U R G E   L I S T I N G'
    29           AND cc_report_work.report_name = RUN_DATE.report_name
    30           AND cc_report_work.report_name = PURGE_DATE.report_name
    31  UNION ALL
    32  SELECT   rownum, RUN_DATE.RUN_DATE,
    33           RUN_TIME.RUN_TIME,
    34           cc_report_work.report_name,
    35           cc_report_work.line_sequence,
    36           PURGE_DATE.PURGE_DATE,
    37           LAD_GROUP.LAD_GROUP,
    38           NP_REASON.NP_REASON,
    39           SUBSTR (cc_report_work.print_line, 11, 8) AS FILENR,
    40           SUBSTR (cc_report_work.print_line, 21, 31) AS CLAIMANT,
    41           SUBSTR (cc_report_work.print_line, 52, 10) AS LAD,
    42           SUBSTR (cc_report_work.print_line, 70, 11) AS SSN
    43    FROM   claims.cc_report_work,
    44           (SELECT   DISTINCT
    45                     report_name, SUBSTR (print_line, 7, 8) AS RUN_DATE
    46              FROM   claims.cc_report_work
    47             WHERE   report_name = 'CC2518C'
    48                     AND SUBSTR (print_line, 7, 8) LIKE '%/%/%') RUN_DATE,
    49           (SELECT   report_name, SUBSTR (print_line, 124, 5) AS RUN_TIME
    50              FROM   claims.cc_report_work
    51             WHERE   report_name = 'CC2518A' AND line_sequence = 2) RUN_TIME,
    52           (SELECT   DISTINCT
    53                     report_name, SUBSTR (print_line, 67, 10) AS PURGE_DATE
    54              FROM   claims.cc_report_work
    55             WHERE   report_name = 'CC2518C'
    56                     AND SUBSTR (print_line, 37, 29) =
    57                           'Claims with No Activity since') PURGE_DATE,
    58           (SELECT   TRIM (print_line) AS LAD_GROUP, page_advance
    59              FROM   claims.cc_report_work
    60             WHERE   report_name = 'CC2518C'
    61                     AND SUBSTR (print_line, 11, 13) = 'Last Activity')
    62           LAD_GROUP,
    63           (SELECT   TRIM (print_line) AS NP_REASON,
    64                     page_advance,
    65                     line_sequence,
    66                     LEAD (page_advance, 1, NULL)
    67                        OVER (ORDER BY page_advance, line_sequence)
    68                        AS NEXT_PAGE,
    69                     LEAD (line_sequence, 1, NULL)
    70                        OVER (ORDER BY page_advance, line_sequence)
    71                        AS NEXT_LINE
    72              FROM   claims.cc_report_work
    73             WHERE   cc_report_work.report_name = 'CC2518C'
    74                     AND SUBSTR (cc_report_work.print_line, 11, 20) =
    75                           'Reason for Non-Purge') NP_REASON
    76   WHERE       cc_report_work.report_name = 'CC2518C'
    77           AND cc_report_work.page_advance = LAD_GROUP.page_advance
    78           AND cc_report_work.report_name = PURGE_DATE.report_name
    79           AND cc_report_work.report_name = RUN_DATE.report_name
    80           AND SUBSTR (cc_report_work.print_line, 14, 1) = '-'
    81           AND ( (cc_report_work.page_advance = NP_REASON.page_advance
    82                  AND cc_report_work.line_sequence BETWEEN NP_REASON.line_sequence
    83                                                       AND  NP_REASON.NEXT_LINE)
    84                OR (    cc_report_work.page_advance = NP_REASON.page_advance
    85                    AND NP_REASON.NEXT_PAGE IS NULL
    86                    AND NP_REASON.NEXT_LINE IS NULL
    87                    AND cc_report_work.line_sequence > NP_REASON.line_sequence));
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3197798840
    | Id  | Operation                  | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    PLAN_TABLE_OUTPUT
    |   0 | SELECT STATEMENT           |                |     2 |   609 | 42264  (61)| 00:08:28 |
    |   1 |  UNION-ALL                 |                |       |       |            |          |
    |   2 |   COUNT                    |                |       |       |            |          |
    |   3 |    MERGE JOIN CARTESIAN    |                |     1 |   206 | 16903   (2)| 00:03:23 |
    |*  4 |     HASH JOIN              |                |     1 |   192 | 12674   (2)| 00:02:33 |
    |   5 |      MERGE JOIN CARTESIAN  |                |     1 |   128 |  8445   (2)| 00:01:42 |
    |*  6 |       TABLE ACCESS FULL    | CC_REPORT_WORK |     1 |    64 |  4222   (2)| 00:00:51 |
    |   7 |       BUFFER SORT          |                |     1 |    64 |  4222   (2)| 00:00:51 |
    |*  8 |        TABLE ACCESS FULL   | CC_REPORT_WORK |     1 |    64 |  4222   (2)| 00:00:51 |
    |*  9 |      TABLE ACCESS FULL     | CC_REPORT_WORK |     1 |    64 |  4229   (2)| 00:00:51 |
    |  10 |     BUFFER SORT            |                |     1 |    14 | 12675   (2)| 00:02:33 |
    |  11 |      VIEW                  |                |     1 |    14 |  4230   (2)| 00:00:51 |
    |  12 |       SORT UNIQUE          |                |     1 |    62 |  4230   (2)| 00:00:51 |
    |* 13 |        TABLE ACCESS FULL   | CC_REPORT_WORK |     1 |    62 |  4229   (2)| 00:00:51 |
    |  14 |   COUNT                    |                |       |       |            |          |
    |  15 |    NESTED LOOPS            |                |     1 |   403 | 25361   (2)| 00:05:05 |
    |  16 |     MERGE JOIN CARTESIAN   |                |     1 |   221 | 21131   (2)| 00:04:14 |
    |  17 |      MERGE JOIN CARTESIAN  |                |     1 |   207 | 16902   (2)| 00:03:23 |
    |* 18 |       HASH JOIN            |                |     1 |   194 | 12672   (2)| 00:02:33 |
    |  19 |        MERGE JOIN CARTESIAN|                |     1 |   128 |  8447   (2)| 00:01:42 |
    |* 20 |         TABLE ACCESS FULL  | CC_REPORT_WORK |     1 |    64 |  4222   (2)| 00:00:51 |
    |  21 |         BUFFER SORT        |                |     1 |    64 |  4225   (2)| 00:00:51 |
    |* 22 |          TABLE ACCESS FULL | CC_REPORT_WORK |     1 |    64 |  4225   (2)| 00:00:51 |
    |* 23 |        TABLE ACCESS FULL   | CC_REPORT_WORK |     1 |    66 |  4225   (2)| 00:00:51 |
    |  24 |       BUFFER SORT          |                |     1 |    13 | 12677   (2)| 00:02:33 |
    |  25 |        VIEW                |                |     1 |    13 |  4230   (2)| 00:00:51 |
    |  26 |         SORT UNIQUE        |                |     1 |    62 |  4230   (2)| 00:00:51 |
    |* 27 |          TABLE ACCESS FULL | CC_REPORT_WORK |     1 |    62 |  4229   (2)| 00:00:51 |
    |  28 |      BUFFER SORT           |                |     1 |    14 | 16902   (2)| 00:03:23 |
    |  29 |       VIEW                 |                |     1 |    14 |  4230   (2)| 00:00:51 |
    |  30 |        SORT UNIQUE         |                |     1 |    62 |  4230   (2)| 00:00:51 |
    |* 31 |         TABLE ACCESS FULL  | CC_REPORT_WORK |     1 |    62 |  4229   (2)| 00:00:51 |
    |* 32 |     VIEW                   |                |     1 |   182 |  4230   (2)| 00:00:51 |
    |  33 |      WINDOW SORT           |                |     1 |    66 |  4230   (2)| 00:00:51 |
    |* 34 |       TABLE ACCESS FULL    | CC_REPORT_WORK |     1 |    66 |  4229   (2)| 00:00:51 |
    Predicate Information (identified by operation id):
       4 - access("CC_REPORT_WORK"."REPORT_NAME"="REPORT_NAME")
       6 - filter("REPORT_NAME"='CC2518B' AND "LINE_SEQUENCE"=8)
       8 - filter("REPORT_NAME"='CC2518A' AND "LINE_SEQUENCE"=2)   9 - filter("CC_REPORT_WORK"."REPORT_NAME"='CC2518B' AND
                  SUBSTR("CC_REPORT_WORK"."PRINT_LINE",14,1)=' ' AND
                  TRIM("CC_REPORT_WORK"."PRINT_LINE")<>'M A N U A L   P U R G E   LI S T I N G')
      13 - filter("CC_REPORT_WORK"."REPORT_NAME"='CC2518B' AND
                  SUBSTR("CC_REPORT_WORK"."PRINT_LINE",54,11)='Purged Thru')
      18 - access("CC_REPORT_WORK"."PAGE_ADVANCE"="PAGE_ADVANCE")
      20 - filter("REPORT_NAME"='CC2518A' AND "LINE_SEQUENCE"=2)
      22 - filter("PAGE_ADVANCE" IS NOT NULL AND "REPORT_NAME"='CC2518C' AND
                  SUBSTR("PRINT_LINE",11,13)='Last Activity')
      23 - filter("CC_REPORT_WORK"."PAGE_ADVANCE" IS NOT NULL AND
                  "CC_REPORT_WORK"."REPORT_NAME"='CC2518C' AND
                  SUBSTR("CC_REPORT_WORK"."PRINT_LINE",14,1)='-')
      27 - filter("REPORT_NAME"='CC2518C' AND SUBSTR("PRINT_LINE",7,8) LIKE '%/%/%')
      31 - filter("REPORT_NAME"='CC2518C' AND SUBSTR("PRINT_LINE",37,29)='Claims with No
                  Activity since')
      32 - filter("CC_REPORT_WORK"."PAGE_ADVANCE"="NP_REASON"."PAGE_ADVANCE" AND
                  "CC_REPORT_WORK"."PAGE_ADVANCE" IS NOT NULL AND
                  "CC_REPORT_WORK"."LINE_SEQUENCE">="NP_REASON"."LINE_SEQUENCE" AND
                  "CC_REPORT_WORK"."LINE_SEQUENCE"<="NP_REASON"."NEXT_LINE" OR
                  "CC_REPORT_WORK"."PAGE_ADVANCE"="NP_REASON"."PAGE_ADVANCE" AND
                  "CC_REPORT_WORK"."PAGE_ADVANCE" IS NOT NULL AND "NP_REASON"."NEXT_PAGE" IS NULL AND
                  "NP_REASON"."NEXT_LINE" IS NULL AND "CC_REPORT_WORK"."LINE_SEQUENCE">"NP_REASON"."LINE_SEQUENCE")
      34 - filter("CC_REPORT_WORK"."REPORT_NAME"='CC2518C' AND
                  SUBSTR("CC_REPORT_WORK"."PRINT_LINE",11,20)='Reason for Non-Purge')
    73 rows selected.--=cf

  • 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.

Maybe you are looking for

  • Tab not working in CS6?

    I just subscribed to CS Cloud, and I like the latest version of Dreamweaver, but I've found one little "bug." When I do a search and replace operation, I type something into the "Find," box, then I push the Tab key to move the cursor into the "Replac

  • Change SC from SRM

    Hi Guys, We usually change SC from Web Version , i follow the same thing as of today. I want to know how to change the SC from SRM backend... i mean from SRM Server any T-code for this Rg sameer

  • Make it possible to select language on an invoice before it is generated

    So the change should make it possible for the user to choose language before generating the invoice.

  • Dragging keyword to multiple images in Aperture?

    Hi, As of recently, keyword is only applied to first image selected, not to all. IT IS VERY INCONVENIENT. Thanks a lot, Raphael

  • IMovie, iPhoto etc.

    I currently have an iBook G4 running 10.3.9. My computer came with iMovie, iPhoto, iDvd, and Garage Band. I know that Tiger doesn't come with these programs, but I would like to know if I can carry over my older versions when I upgrade, and how to do