Need help tuning join in slow query

Hi all,
I have the following issue to tune the below join condition in my query below:
SELECT PO.COMPANY,
PO.UPDATE_DATE,
PO.EXTENDED_AMT,
PO.LOCATION,
ICLOCATION.R_NAME AS LOCATION_DESC,
PO.VENDOR,
AP.VENDOR_VNAME,
MAJOR.DESCRIPTION AS MAJOR_DESC,
MINOR.DESCRIPTION AS MINOR_DESC,
CASE po.purch_majcl
WHEN ' '
THEN 'NONE'
ELSE po.purch_majcl
END AS PURCH_MAJ,
CASE po.purch_min
WHEN ' '
THEN 'NONE'
ELSE po.purch_min
END AS PURCH_MIN,
CASE po.manuf_code
WHEN ' '
THEN 'NO MFG'
ELSE po.manuf_code
END AS MANUF_CODE,
CASE po.manuf_nbr
WHEN ' '
THEN 'NONE'
ELSE po.manuf_nbr
END AS MANUF_NBR,
CASE po.manuf_division
WHEN ' '
THEN 'NONE'
ELSE po.manuf_division
END AS MANUF_DIV,
CASE po.agreement_ref
WHEN ' '
THEN 'NONE'
ELSE PO.AGREEMENT_REF
END AS AGRMT_REF,
/* ITEMLOC IS REQUIRED TO GET TO ICCACATEGORY */
CASE po.item_type
WHEN 'I'
THEN ICCATEGORY.INV_ACCT_UNIT
ELSE MMDIST.ACCT_UNIT
END AS ACCT_UNIT,
CASE po.item_type
WHEN 'I'
THEN ICCATEGORY.GL_CATEGORY
ELSE to_char(MMDIST.ACCOUNT)
END AS ACCOUNT,
/* ITEMLOC IS REQUIRED TO GET TO ICCACATEGORY */
PO.ITEM_TYPE,
PO.ITEM,
PO.DESCRIPTION AS ITEM_DESC,
PO.ENT_REC_UOM,
PO.ENT_RUOM_MULT,
PO.ENT_REC_QTY,
PO.ORIG_UNIT_CST,
PO.MATCH_UNIT_CST,
PO.PO_NUMBER,
PO.PO_LINE_NBR,
PO.QTY_TO_PROC,
PURCHORDER.PO_DATE,
PURCHORDER.BUYER_CODE,
BUYER.R_NAME AS BUYER_NAME
FROM LAW.PURCHORDER, LAWS81.BUYER,
LAW.ICLOCATION, LAW.APVENMAST,
LAW.PO LEFT JOIN LAW.MMDIST
ON (PO.COMPANY = MMDIST.COMPANY
AND PO.LOCATION = MMDIST.LOCATION
AND PO.PO_NUMBER = MMDIST.DOC_NUMBER
AND PO.PO_RELEASE = MMDIST.DOC_NBR_NUM
AND PO.PO_CODE = MMDIST.PO_CODE
AND PO.PO_LINE_NBR = MMDIST.LINE_NBR
AND MMDIST.SYSTEM_CD = 'PO'
AND MMDIST.DOC_TYPE = 'PT'
AND MMDIST.COMPONENT_SEQ = 0
AND MMDIST.AOC_CODE = ' ')
/* 1st JOIN TO ITEMLOC */
LEFT JOIN LAW.ITEMLOC
ON PO.COMPANY = ITEMLOC.COMPANY
AND PO.LOCATION = ITEMLOC.LOCATION
AND PO.ITEM = ITEMLOC.ITEM,
/* 2nd JOIN from ITEMLOC to ICCATEGORY */
/* It should use the ITEMLOC join from above */
/* creating cartesian product with itemloc */
LAW.ITEMLOC LEFT JOIN LAW.ICCATEGORY
ON ITEMLOC.COMPANY = ICCATEGORY.COMPANY
AND ITEMLOC.LOCATION = ICCATEGORY.LOCATION
AND ITEMLOC.GL_CATEGORY = ICCATEGORY.GL_CATEGORY,
/* need to get to ICCATEGORY table using 2nd JOIN condition above */
LAW.PO LEFT JOIN LAW.MAJOR
ON PO.PURCH_MAJ = MAJOR.MAJOR_CLASS
AND MAJOR.CLASS_TYPE = 'P'
LEFT JOIN LAW.MINOR
ON PO.PURCH_MAJCL = MINOR.MAJOR_CLASS
AND PO.PURCH_MINCL = MINOR.MINOR_CLASS
AND MINOR.CLASS_TYPE = 'P'
WHERE PO.COMPANY = PO.COMPANY
AND PO.PO_NUMBER = PO.PO_NUMBER
AND PO.PO_RELEASE = PO.PO_RELEASE
AND PO.PO_CODE = PO.PO_CODE
AND PO.PO_LINE_NBR = PO.LINE_NBR
AND PO.COMPANY = ICLOCATION.COMPANY
AND PO.LOCATION = ICLOCATION.LOCATION
AND PO.VENDOR = APVENMAST.VENDOR
AND PO.COMPANY = PURCHORDER.COMPANY
AND PO.PO_CODE = PURCHORDER.PO_CODE
AND PO.PO_NUMBER = PURCHORDER.PO_NUMBER
AND PO.PO_RELEASE = PURCHORDER.PO_RELEASE
AND PURCHORDER.BUYER_CODE = BUYER.BUYER_CODE
AND PO.R_STATUS = 1
AND PO.ENT_REC_QTY > 0
This query runs very slow and we cannot change the code to add or modify indexes. We need to join the 2nd table to the third table with optimized performance. How can I tune this slow running query with the best join conditions?
Thanks

I want to join the OS_LOCN_CURR_STK table with the
OT_PO_ITEM table , such that all items in
OS_LOCN_CURR_STK are displayed.
If you want all items in OS_LOCN_CURR_STK to be returned, use an OUTER JOIN on the columns joining the 2 tables.

Similar Messages

  • Need help tuning on this select query

    select a.exceptionid, c.sequencenumber, c.messagedelay,a.exceptioncode
    from exceptiondetailview a, exceptionrecaltkey b, sequencerconfig c
    where a.exceptionid = b.exceptionid
    and a.transactiontype = c.transactiontype
    and a.exceptionid in (
    select exceptionid
    from exceptionrecaltkey
    where altkeyname = 'SequenceKey' and altkeyvalue like ('%[11968176]%'))
    minus
    select exceptionid
    from exceptionrecaltkey
    where altkeyname = 'SequenceFlowName'
    and altkeyvalue <> 'APV_OUTBOUND')
    and b.altkeyname = 'SequenceKey'
    and c.sequenceflowname = 'APV_OUTBOUND'
    and c.sequencenumber > ( decode(ASN, null, (select min(sequencenumber) from sequencerconfig where sequenceflowname = 'APV_OUTBOUND' and exceptioncode = a.exceptioncode),
    (select sequencenumber from sequencerconfig where sequenceflowname = 'APV_OUTBOUND' and transactiontype = ASN and exceptioncode = a.exceptioncode) ) )
    and a.status = 'New'

    Hi,
    Please try this ,
    select a.exceptionid, c.sequencenumber, c.messagedelay,a.exceptioncode
    from exceptiondetailview a, exceptionrecaltkey b, sequencerconfig c
    where
    exists a.exceptionid in (
    select exceptionid
    from exceptionrecaltkey
    where altkeyname = 'SequenceKey' and altkeyvalue like ('%[11968176]%'))
    and a.exceptionid = b.exceptionid
    and a.transactiontype = c.transactiontype
    minus
    select exceptionid
    from exceptionrecaltkey
    where altkeyname = 'SequenceFlowName'
    and altkeyvalue 'APV_OUTBOUND')
    and b.altkeyname = 'SequenceKey'
    and c.sequenceflowname = 'APV_OUTBOUND'
    and c.sequencenumber > ( decode(ASN, null, (select min(sequencenumber) from sequencerconfig where sequenceflowname = 'APV_OUTBOUND' and exceptioncode = a.exceptioncode),
    (select sequencenumber from sequencerconfig where sequenceflowname = 'APV_OUTBOUND' and transactiontype = ASN and exceptioncode = a.exceptioncode) ) )
    and a.status = 'New'
    REgards,
    N.Senthil

  • Need help tuning slow running query

    Need help tuning below two Oracle queries:
    Query #1:
    ======================
    SELECT "WORK_ORDER_FACT_ALL_YESTERDAY"."WORK_ORDER_HISTORY_ID",
    "WORK_ORDER_FACT_ALL_YESTERDAY"."ACCOUNT_NUMBER",
    "ACCOUNT_DIM"."ACCOUNT_NUMBER", "ACCOUNT_DIM"."ACCOUNT_WS_DISC_DATE"
    FROM "CDWD"."WORK_ORDER_FACT_ALL_YESTERDAY" "WORK_ORDER_FACT_ALL_YESTERDAY",
    "CDWD"."ACCOUNT_DIM" "ACCOUNT_DIM"
    WHERE (SUBSTR ("WORK_ORDER_FACT_ALL_YESTERDAY"."ACCOUNT_FIRST_NAME", 1, 1) =
    SUBSTR ("ACCOUNT_DIM"."ACCOUNT_FIRST_NAME", 1, 1)
    AND (SUBSTR ("WORK_ORDER_FACT_ALL_YESTERDAY"."ACCOUNT_LAST_NAME", 1, 4) =
    SUBSTR ("ACCOUNT_DIM"."ACCOUNT_LAST_NAME", 1, 4)
    AND ("WORK_ORDER_FACT_ALL_YESTERDAY"."ACCOUNT_DL_NUMBER" =
    "ACCOUNT_DIM"."ACCOUNT_DL_NUMBER"
    AND "WORK_ORDER_FACT_ALL_YESTERDAY"."WO_TYPE_CODE" IN ('25', '27')
    AND ("ACCOUNT_DIM"."REVENUE_TYPE_ID" = 1)
    AND ("WORK_ORDER_FACT_ALL_YESTERDAY"."TRANSFER_COUNT" = 0)
    AND ("WORK_ORDER_FACT_ALL_YESTERDAY"."WINBACK_ADD_COUNT" = 0)
    AND ("ACCOUNT_DIM"."ACCOUNT_WS_ENTRY_DATE" <
    (TO_DATE ('2006.05.02', 'yyyy.mm.dd') - 11
    AND ("WORK_ORDER_FACT_ALL_YESTERDAY"."IS_DERIVED" = 0)
    AND ("ACCOUNT_DIM"."EXPIRATION_DATE" IS NULL)
    AND ("WORK_ORDER_FACT_ALL_YESTERDAY"."ACT_ACCOUNT_TYPE_CD" <> '50');
    Query #2
    ==================
    UPDATE work_order_fact_all_yesterday g
    SET returns_count = 1
    WHERE EXISTS (SELECT 1
    FROM (SELECT a.phone_dim_key AS transactional_phone_dim_key,
    b.mdn_number AS transactional_mdn_number,
    b.account_number AS transactional_account_number
    FROM work_order_fact_all_yesterday a INNER JOIN phone_dim b ON a.phone_dim_key = b.phone_dim_key
    WHERE a.gross_deactivations_count = 1) e
    INNER JOIN (SELECT c.phone_dim_key AS historical_phone_dim_key,
    d.mdn_number AS historical_mdn_number,
    d.account_number AS historical_account_number
    FROM (SELECT phone_dim_key
    FROM work_order_activity_fact
    WHERE gross_adds_count = 1
    AND report_date >= :b1 - 66
    AND NVL (is_derived, 0 ) = 0
    UNION
    SELECT phone_dim_key
    FROM work_order_fact_all_yesterday
    WHERE gross_adds_count = 1
    AND is_derived = 0) c
    INNER JOIN phone_dim d ON c.phone_dim_key = d.phone_dim_key ) f
    ON e.transactional_mdn_number = f.historical_mdn_number
    AND e.transactional_account_number = f.historical_account_number
    WHERE e.transactional_phone_dim_key = g.phone_dim_key)
    AND g.gross_deactivations_count = 1
    AND g.account_revenue_type_id = 1;
    I ran the DBMS_SQLTUNE on it for 10g and did not get any advice. How can I tune the above queries? Thanks!

    Tune the SQL? Looking at the join criteria of SUBSTR("WORK_ORDER_FACT_ALL_YESTERDAY"."ACCOUNT_FIRST_NAME", 1, 1) = SUBSTR ("ACCOUNT_DIM"."ACCOUNT_FIRST_NAME", 1, 1) and other substrings, it seems to me that you have basic flaws in your relation design.
    Column must be atomic values. Having to extract a sub-set value from a column to create the intelligence needed to join to another table - that is just plain wrong in relation design. Never mind the performance impact and overheads it causes in the database.

  • Need help on join query

    Hi All,
    Please help me on the below join condition,
    >SELECT * FROM ESTIMATE_LINE WHERE JOB_ID = '214582' AND ESTIMATE_ID = 2;
    Output : Returns 1 row,
    >SELECT * FROM ESTIMATE_ACCOUNTING_LINE WHERE JOB_ID = '214582' AND ESTIMATE_ID = 2;
    Output : Returns 3 rows,
    I would like to add these two outputs as on, Finally i've to get 4 rows in the output,
    For that am writing the query like this,
    SELECT EL.*,EAL.*
    FROM ESTIMATE_LINE EL,
    ESTIMATE_ACCOUNTING_LINE EAL
    WHERE EL.JOB_ID = EAL.JOB_ID (+)
    AND EL.ESTIMATE_ID = EAL.ESTIMATE_ID (+)
    AND EAL.JOB_ID = '214582'
    AND EL.ESTIMATE_ID = 2,
    It is not giving the exact output, the common fields are there in the join condition,
    Can some one please re write the query for expected output..
    I am trying it but not getting the exact output,Unable to find out where the mistake is ...
    Thanks,
    gra

    Hi,
    First, let me make sure I undersatnd the problem.
    You have a query that lookas for information about a given job_id and estimate_id the estimate_line table. This query produces X rows.
    You have another query that lookas for information about the same job_id and estimate_id the estimate_accounting__line table. This query produces Y rows.
    You want to get the same results in one query that produces X+Y rows.
    That sounds like a job for UNION, not a join.
    If the two queries produces the same number of columns, and the data types of the columns are similiar, then you can just write the two queries together. Instead of a semicolon at the end of the first query, you'll say UNION (or UNION ALL):
    SELECT * FROM ESTIMATE_LINE            WHERE JOB_ID = '214582' AND ESTIMATE_ID = 2
    UNION ALL
    SELECT * FROM ESTIMATE_ACCOUNTING_LINE WHERE JOB_ID = '214582' AND ESTIMATE_ID = 2;If the columns are not the same, you'll need to call some conversion functions, or add literal columns (such as NULL) to the queries.
    If you need help, post a little sampe data (CREATE TABLE and INSERT statements) and the results you want from that data.

  • Need help in rewriting a sql query

    Can any one please tell me if there is any utility that can help me correcting the sql I have I need to tune the query as its taking lot of time. I want to use some tool that will help me re-formating the query.
    Any help in this regard will be highly appreciated.

    If you think that Oracle SQL Tuning Tools like SQL Tuning Advisor and SQL Access Advisor are not helping.
    You might look into thrid party tools like Quest- SQL Navigator and TOAD.
    But I don't advise this based on the following:
    Re: Oracle Third Party Tools and Oracle Database
    Oracle have enough tools of its own to satisfy the various needs.
    Adith

  • [8i] Need help with hierarchical (connect by) query

    First, I'm working in 8i.
    My problem is, I keep getting the error ORA-01437: cannot have join with CONNECT BY.
    And, the reason I get that error is because one of the criteria I need to use to prune some branches with is in another table... Is there anyway to work around this? I tried an in-line view (but got the same error). I thought about using the connect by query as an in-line view and filtering off what I don't want that way, but I'm not sure how to filter out an entire branch...
    Here is some simplified sample data:
    CREATE TABLE     bom_test
    (     parent          CHAR(25)
    ,     component     CHAR(25)
    ,     qty_per          NUMBER(9,5)
    INSERT INTO     bom_test
    VALUES     ('ABC-1','101-34',10);
    INSERT INTO     bom_test
    VALUES     ('ABC-1','A-109-347',2);
    INSERT INTO     bom_test
    VALUES     ('ABC-1','ABC-100G',1);
    INSERT INTO     bom_test
    VALUES     ('ABC-1','1A247G01',2);
    INSERT INTO     bom_test
    VALUES     ('ABC-100G','70052',18);
    INSERT INTO     bom_test
    VALUES     ('ABC-100G','M9532-278',5);
    INSERT INTO     bom_test
    VALUES     ('1A247G01','X525-101',2);
    INSERT INTO     bom_test
    VALUES     ('1A247G01','1062-324',2);
    INSERT INTO     bom_test
    VALUES     ('X525-101','R245-9010',2);
    CREATE TABLE     part_test
    (     part_nbr     CHAR(25)
    ,     part_type     CHAR(1)
    INSERT INTO     part_test
    VALUES     ('ABC-1','M');
    INSERT INTO     part_test
    VALUES     ('101-34','P');
    INSERT INTO     part_test
    VALUES     ('A-109-347','P');
    INSERT INTO     part_test
    VALUES     ('ABC-100G','M');
    INSERT INTO     part_test
    VALUES     ('1A247G01','P');
    INSERT INTO     part_test
    VALUES     ('70052','P');
    INSERT INTO     part_test
    VALUES     ('M9532-278','P');
    INSERT INTO     part_test
    VALUES     ('X525-101','M');
    INSERT INTO     part_test
    VALUES     ('1062-324','P');
    INSERT INTO     part_test
    VALUES     ('R245-9010','P');This is the basic query (with no pruning of branches):
    SELECT     LEVEL
    ,     b.component
    ,     b.parent
    ,     b.qty_per
    FROM     bom_test b
    START WITH          b.parent     = 'ABC-1'
    CONNECT BY PRIOR     b.component     = b.parentThe query above gives the results:
          LEVEL COMPONENT                 PARENT                        QTY_PER
          1.000 101-34                    ABC-1                          10.000
          1.000 A-109-347                 ABC-1                           2.000
          1.000 ABC-100G                  ABC-1                           1.000
          2.000 70052                     ABC-100G                       18.000
          2.000 M9532-278                 ABC-100G                        5.000
          1.000 1A247G01                  ABC-1                           2.000
          2.000 X525-101                  1A247G01                        2.000
          3.000 R245-9010                 X525-101                        2.000
          2.000 1062-324                  1A247G01                        2.000
    9 rows selected....but I only want the branches (children, grandchildren, etc.) of part type 'M'.
    e.g.:
          LEVEL COMPONENT                 PARENT                        QTY_PER
          1.000 101-34                    ABC-1                          10.000
          1.000 A-109-347                 ABC-1                           2.000
          1.000 ABC-100G                  ABC-1                           1.000
          2.000 70052                     ABC-100G                       18.000
          2.000 M9532-278                 ABC-100G                        5.000
          1.000 1A247G01                  ABC-1                           2.000Any suggestions?

    Hi,
    user11033437 wrote:
    First, I'm working in 8i.
    My problem is, I keep getting the error ORA-01437: cannot have join with CONNECT BY.
    And, the reason I get that error is because one of the criteria I need to use to prune some branches with is in another table... Is there anyway to work around this? I tried an in-line view (but got the same error). Post your query. It's very hard to tell what you're doing wrong if we don't know what you're doing.
    ...but I only want the branches (children, grandchildren, etc.) of part type 'M'.
    e.g.:
    LEVEL COMPONENT                 PARENT                        QTY_PER
    1.000 101-34                    ABC-1                          10.000
    1.000 A-109-347                 ABC-1                           2.000
    1.000 ABC-100G                  ABC-1                           1.000
    2.000 70052                     ABC-100G                       18.000
    2.000 M9532-278                 ABC-100G                        5.000
    1.000 1A247G01                  ABC-1                           2.000
    You mean you want don't want the descendants (children, grandchildren, etc.) of any component whose part_type is not 'M'.
    The part_type of the component itself doesn't matter: component '101-34' is included, even though its part_type is 'P', and component 'X525-101' is excluded, even though its part_type is 'M'.
    >
    Any suggestions?Sorry, I don't have an Oracle 8.1 database at hand now. All three of the queries below get the correct results in Oracle 10.2, and I don't believe they do anything that isn't allowed in 8.1.
    You can't do a join and CONNECT BY in the same query on Oracle 8.1.
    I believe you can do one first, then the other, using in-line views. The frist two queries do the join first.
    --     Query 1: Join First
    SELECT     LEVEL
    ,     component
    ,     parent
    ,     qty_per
    FROM     (     -- Begin in-line view to join bom_test and part_test
              SELECT     b.component
              ,     b.parent
              ,     b.qty_per
              ,     p.part_type     AS parent_type
              FROM     bom_test     b
              ,     part_test     p
              WHERE     p.part_nbr     = b.parent
         )     -- End in-line view to join bom_test and part_test
    START WITH     parent     = 'ABC-1'
    CONNECT BY     parent          = PRIOR component
         AND     parent_type     = 'M'
    ;Query 2 is very much like Query 1, but it does more filtering in the sub-query, returning only rows hose part_type or whose parent's part_type is 'M". Your desired result set will be a tree taken entirely from this set. Query 2 may be faster, because the sub-query is more selective, but then again, it may be slower because it has to do an extra join.
    {code}
    -- Query 2: Join first, prune in sub-query
    SELECT     LEVEL
    ,     component
    ,     parent
    ,     qty_per
    FROM     (     -- Begin in-line view to join bom_test and part_test
              SELECT     b.component
              ,     b.parent
              ,     b.qty_per
              ,     p.part_type     AS parent_type
              FROM     bom_test     b
              ,     part_test     p
              ,     part_test     c
              WHERE     p.part_nbr     = b.parent
              AND     c.part_nbr     = b.component
              AND     'M'          IN (c.part_type, p.part_type)
         )     -- End in-line view to join bom_test and part_test
    START WITH     parent     = 'ABC-1'
    CONNECT BY     parent          = PRIOR component
         AND     parent_type     = 'M'
    {code}
    Query 3, below, takes a completely different approach. It does the CONNECT BY query first, then does a join to see what the parent's part_type is. We can easily cut out all the nodes whose parent's part_type is not 'M', but that will leave components like 'R245-9010' whose parent has part_type 'M', but should be excluded because its parent is excluded. To get the correct results, we can do another CONNECT BY query, using the same START WITH and CONNECT BY conditions, but this time only looking at the pruhed results of the first CONNECT BY query.
    {code}
    --     Query 3: CONNECT BY, Prune, CONNECT BY again
    SELECT     LEVEL
    ,     component
    ,     parent
    ,     qty_per
    FROM     (     -- Begin in-line view of 'M' parts in hierarchy
              SELECT     h.component
              ,     h.parent
              ,     h.qty_per
              FROM     (     -- Begin in-line view h, hierarchy from bom_test
                        SELECT     component
                        ,     parent
                        ,     qty_per
                        FROM     bom_test
                        START WITH     parent     = 'ABC-1'
                        CONNECT BY     parent     = PRIOR component
                   ) h     -- End in-line view h, hierarchy from bom_test
              ,     part_test     p
              WHERE     p.part_nbr     = h.parent
              AND     p.part_type     = 'M'
         )     -- End in-line view of 'M' parts in hierarchy
    START WITH     parent     = 'ABC-1'
    CONNECT BY     parent     = PRIOR component
    {code}
    I suspect that Query 3 will be slower than the others, but if the CONNECT BY query is extremely selective, it may be better.
    It would be interesting to see your findings using the full tables. Please post your observations and the explain plan output.
    As usual, your message is a model of completeness and clarity:
    <ul>
    <li>good sample data,
    <li> posted in a way people can use it,
    <li>clear results,
    <li> good explanation
    <li> nciely formatted code
    </ul>
    Keep up the good work!

  • Need help inLOV's in AF Query

    Hi,
    I need help in adding LOV's in AF Query. Please do the need full.
    Regards,

    Hi all,
    My issue was resolved i have followed the link"http://andrejusb.blogspot.com/2008/11/adf-query-component-and-view-criteria.html"
    Regards,

  • Need help in PO Approval Group Query

    Hi,
    I need a Query which will list of users that has the Approval Group “BUYER” and “BUYER_DEMO” assigned to them.
    It will be needful if anyone provides me the Query
    Thanks and Regards

    Hi
    Try this.
    SELECT PAPF.employee_number
    ,PAPF.full_name
    FROM po_control_groups_all PCGA
    ,po_position_controls_all PPCA
    ,per_all_assignments_f PAAF
    ,per_all_people_f PAPF
    WHERE PCGA.control_group_name IN ('BUYER','BUYER_DEMO')
    AND PCGA.control_group_id = PPCA.control_group_id
    AND PPCA.position_id = PAAF.position_id
    AND PAAF.person_id = PAPF.person_id
    Thanks and Regards,
    JD

  • Need help to re-format the query

    Hi All,
    Could any one please help me to rewrite this query or explain me how to do it as it is taking 20 mins to execute....
    SELECT
    AC.ACC_NO||DECODE(MI.MSG_CLASS,'ROF',(SELECT LMI2.PAYMENT_SET      
                                       FROM
            MIF LMI2 WHERE LMI2.MID =
            (SELECT CHILDMID FROM MFAMILY WHERE PARENTMID= MI.MID AND RELATION='ROF')),MI.PAYMENT_SET)||
            DECODE(MI.MSG_CLASS,'ROF', (SELECT LMI2.SERVICE FROM MIF LMI2 WHERE LMI2.MID = (SELECT CHILDMID FROM
      MFAMILY WHERE PARENTMID=MI.MID AND RELATION='ROF')),MI.SERVICE) HASH_KEY,
      MI.MID ,
      DECODE(MI.MSG_CLASS,'ROF',(SELECT LMI2.PAYMENT_SET FROM MIF LMI2
      WHERE LMI2.MID = (SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND
      RELATION='ROF')),MI.PAYMENT_SET) PAYMENT_SET,
      MI.AMOUNT,
      NVL(DECODE(MI.MSG_CLASS,'ROF',MI.CRAMOUNT, MI.DBAMOUNT) ,0) AMT,
      AC.ACC_NO,
      DECODE(MI.MSG_CLASS,'ROF',(SELECT LMI2.BATCH_COMPANY_CD FROM MIF LMI2 WHERE
      LMI2.MID = (SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND
      RELATION='ROF')),MI.BATCH_COMPANY_CD) BATCHCOMP,
      AC.ACC_ALIAS, NVL(AC.IBAN,
      NVL(AC.ACC_ALIAS,AC.ACC_NO)) IBAN_ACCNO,
      AC.CURRENCY , AC.ACCOUNTNAME ,
      CASE
           WHEN (SIGN(MI.PROCESS_DT - TO_DATE(:B2 ,'YYYYMMDD'))) = '1'
           THEN 'F'
           ELSE 'C' END FUTURE_IND,
           (CASE
                WHEN (MI.MSG_STATUS = 'CANCELED' OR   MI.STATBFHELD = 'CANCELED')
                THEN 'C'
                WHEN MI.BATCH_PAYMENT_TP = 'RMTRT'
                THEN 'R'
                WHEN (MI.REJECT_RETURN='REJT' OR MI.MSG_CLASS = 'ROF' OR MI.MSG_STATUS = 'REJECTED')
                THEN 'A'
                WHEN (MI.REJECT_RETURN='RETN' OR (MI.BATCH_PAYMENT_TP='RTACH' AND MSG_CLASS='ROF'))
                THEN 'B'
                WHEN  MI.MSG_STATUS='FORWARD_PROCESSING'
                THEN 'F'
                WHEN (MI.MSG_STATUS NOT IN  ('COMPLETE','CANCELED','REJECTED') OR (MI.MSG_STATUS='AGED' AND
                     MI.STATBFHELD NOT IN ('COMPLETE','CANCELED','REJECTED')) )
                THEN 'U'
                WHEN  MI.PROCESS_DT = TO_DATE(:B2 ,'YYYYMMDD')
                THEN 'P' END)
      PAY_STATUS,
      MT.DB_FEE_ACCOUNT_CCY,
      (SELECT MESSAGEFREETEXT.CONTENTS
           FROM
           MESSAGEFREETEXT
           WHERE
                FIELDNAME ='MANDATEREFERENCE'
                     AND MESSAGEFREETEXT.MID= MI.MID) MANDREF,
      (SELECT MESSAGEFREETEXT.CONTENTS
           FROM MESSAGEFREETEXT
           WHERE FIELDNAME ='DIRECT_DEBIT_REFERENCE' AND MESSAGEFREETEXT.MID=MI.MID)  DDREF,
      MT.CUSTOMER_BATCH_REFERENCE LOCINFO,
      (SELECT  MESSAGEFREETEXT.CONTENTS
           FROM MESSAGEFREETEXT WHERE FIELDNAME =  'SECOND_PARTY_ID' AND MESSAGEFREETEXT.MID=MI.MID) SECPRTYINF,
      (SELECT  MESSAGEFREETEXT.CONTENTS
           FROM MESSAGEFREETEXT WHERE FIELDNAME = 'HUB_PAY_PROD_TYP' AND MESSAGEFREETEXT.MID=MI.MID) PAYPRODTYP,
      DECODE(MI.MSG_CLASS,'ROF',(SELECT LMI2.CHANNEL_REFERENCE FROM MIF LMI2
                          WHERE LMI2.MID = (SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND
                                         RELATION='ROF')),MI.CHANNEL_REFERENCE) CHNREF,
      (SELECT  MESSAGEFREETEXT.CONTENTS
           FROM MESSAGEFREETEXT
           WHERE FIELDNAME =  'CHN_BATCH_REF' AND MESSAGEFREETEXT.MID=MI.MID) CHNBATREF,
      TO_CHAR(DECODE(MI.MSG_CLASS,'ROF',(SELECT LMI2.VALUE_DATE FROM MIF LMI2
                     WHERE LMI2.MID = (SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND
                                    RELATION='ROF')),MI.VALUE_DATE),'DD/MM/YYYY') VALUEDT,
      DECODE(MI.MSG_CLASS,'ROF',(SELECT LMI2.ORIG_REFERENCE FROM MIF LMI2 WHERE LMI2.MID = (SELECT
                          CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND RELATION='ROF')),
                                                        MI.ORIG_REFERENCE) ORIGREF,
      CASE
           WHEN (MI.OFFICE <> MI.ORIG_OFFICE)
           THEN MT.DR_SIDE_RATE_AM
           ELSE
                CASE
                     WHEN MI.DBCURRENCY = MI.CRCURRENCY
                     THEN
                          CASE
                               WHEN MI.CRCURRENCY = :B4
                               THEN MT.DR_RATE ELSE MT.CR_RATE
                          END
                     ELSE
                          CASE
                               WHEN   MI.CRCURRENCY = :B4
                               THEN MT.DR_RATE ELSE MT.CR_RATE
                          END
                END
           END EXCHRT,
      MT.BBK_ADDR1,
      MT.BBK_ADDR2,
      MT.BBK_ADDR3 ,
      MT.BBK ,
      MT.BNF_ADDR1,
      MT.BNF_ADDR2,
      MT.BNF_ADDR3,
      MT.BNF_ADDR4 ,
      MT.BNF ,
      DECODE(MT.BNF_IDCODE,'AC',MT.BNF_ID,' ') ORGBNFID,
      DECODE(NVL(MI.ORIG_INSTRUCT_AMOUNT,0),0, MI.ORIG_AMOUNT) ORGINSTAMT,
      NVL(TRIM(MI.ORIG_INSTRUCT_CURRENCY),  MI.ORIG_CURRENCY) ORGINSTCUR,
      CASE
           WHEN MOP LIKE 'DRFT%'
           THEN 'DD'
           WHEN MOP   LIKE 'CHEQ%'
           THEN 'CO'
           WHEN MOP LIKE 'SWIFT'
           THEN 'TT'
           WHEN MOP LIKE 'DDP%'
           THEN 'T'
           WHEN MOP LIKE 'BOOK'
           THEN 'T' ELSE 'LP'
      END PYMTTP,
      MT.OBI ,
      TO_CHAR(MI.PROCESS_DT,'YYYYMMDD') PROCESSDT,
      MI.REFERENCE,
      MT.BBK_BIC,
      MT.BBK_IDCODE,
      DECODE(MT.BBK_IDCODE,'AC',' ',SUBSTR(MT.BBK_ID,1,12)) BBKID,
      MI.LOCAL_REF,
      MI.CURRENCY INDCURR,
      MI.MSG_STATUS,
      MI.PK_BATCH_SUBSET,
      TO_CHAR(SBBATCH.PROCESS_DT,'YYYYMMDD') SBPROCESSDT,
      DECODE(MI.MSG_CLASS,'ROF',MI.CRCURRENCY, MI.DBCURRENCY) DBCURR,
      MI.ORIG_REFERENCE ORIGREFRET
      FROM
           MIF MI,
           MTF1000 MT,
           ACCOUNTS AC,
           (     SELECT
                     MF.PK_BATCH_SUBSET,
                     MF.PROCESS_DT,
                     MTF.ORG_ID,
                     MTF.MP_CR_ACC,
                     MTF.CR_ACC_NO
                FROM
                     MIF MF,
                     MTF1000
                     MTF
                WHERE
                     ((MSG_STATUS IN ('COMPLETE','CANCELED','REJECTED')) OR
                     (MSG_STATUS = 'AGED' AND STATBFHELD IN ('COMPLETE','CANCELED','REJECTED')))
                AND
                     BATCH_MSG_TP = 'S' AND MF.MID = MTF.MID )
           SBBATCH
      WHERE
           MI.MSG_TYPE =   :B3
      AND MI.PROCESS_DT = TO_DATE(:B2 ,'YYYYMMDD')
      AND MI.BATCH_MSG_TP = 'I'
      AND DECODE(MI.MSG_CLASS,'ROF',
           (SELECT LMI2.SERVICE FROM MIF LMI2 WHERE LMI2.MID =
           (SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND RELATION='ROF')),MI.SERVICE)
           IN ('NET','HCN','BIB','LST','MRI')
      AND MI.PK_BATCH_EXCH IN (SELECT PK_BATCH_EXCH FROM BATCH_EXCH)
      AND MI.MID = MT.MID
      AND SBBATCH.PK_BATCH_SUBSET = MI.PK_BATCH_SUBSET
      AND TRIM(DECODE(MI.MSG_CLASS,'ROF',MT.CR_ACC_NO, NVL(MT.ORG_ID,NVL(MT.MP_DB_ACC,MT.ACC_NO))) )=AC.ACC_NO
      AND AC.OFFICE = :B1
      ORDER BY HASH_KEY,PAY_STATUS

    Hi,
    please try this.
    The first decode or at least part of it repeats at least 7 times.
         DECODE(MI.MSG_CLASS,'ROF',
                                         (SELECT LMI2.PAYMENT_SET  
                                    FROM MIF LMI2 WHERE LMI2.MID =
          (SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND RELATION='ROF')
                                            ),MI.PAYMENT_SET
                   ||
        DECODE(MI.MSG_CLASS,'ROF',
                                         (SELECT LMI2.SERVICE
                                                                                 FROM MIF LMI2 WHERE LMI2.MID =
                   (SELECT CHILDMID FROM MFAMILY WHERE PARENTMID=MI.MID AND RELATION='ROF')
                                             ),MI.SERVICE) HASH_KEY,
    is similar to this
    select mif.* from mif, mfamily where mif.mid=mfamily.childmid
    and relation = 'ROF' and msg_class='ROF'
    insert it as an inline view and add a conditition
    from ...
    (select mif.* from mif, mfamily where mif.mid=mfamily.childmid
    and relation = 'ROF' and msg_class='ROF') rof
    Where ...
    and mi.mid=Rof.mid (+)...
    and your code above would look like
    nvl(rof.payment_set,mi.payment_set) || nvl(rof.service,mi.service) HASH_KEY,
    nvl(rof.payment_set,mi.payment_set) PAYMENT_SET
    replace all the same decode above with corresponding nvl(...)Hope this helps.

  • Need help in writing a select query to pull required data from 3 tables.

    Hi,
    I have three tables EmpIDs,EmpRoles and LatestRoles. I need to write a select Query to get roles of all employees present in EmpIDs table by referring EmpRoles and LatestRoles.
    The condition is first look into table EmpRoles and if it has more than one entry for a particular Employee ID than only need to get the Role from LatestRoles other wise consider
    the role from EmpRoles .
    Sample Script:
    Create Table #EmpIDs
    (EmplID int )
    Create Table #EmpRoles
    (EMPID int,Designation varchar(50))
    Create Table #LatestRoles
    EmpID int,
    Designation varchar(50)
    Insert into #EmpIDs values (1),(2),(3)
    Insert into #EmpRoles values (1,'Role1'),(2,'Role1'),(2,'Role2'),(3,'Role1')
    Insert into #LatestRoles values (2,'Role2')
    Employee ID 2 is having two roles defined in EmpRoles so for EmpID 2 need to fetch Role from LatestRoles table and for
    remaining ID's need to fetch from EmpRoles .
    My Final Output of select query should be like below.
    EmpID Role
    1 Role1
    2 Role2
    3 Role1
    Please help.
    Mohan

    Mohan,
    Can you check if this answers your requirement:
    Create Table #EmpIDs
    (EmplID int )
    Create Table #EmpRoles
    (EMPID int,Designation varchar(50))
    Create Table #LatestRoles
    EmpID int,
    Designation varchar(50)
    Insert into #EmpIDs values (1)
    Insert into #EmpIDs values (2)
    Insert into #EmpIDs values (3)
    Insert into #EmpRoles values (1,'Role1')
    Insert into #EmpRoles values (2,'Role2')
    Insert into #EmpRoles values (2,'Role1')
    Insert into #EmpRoles values (3,'Role1')
    Insert into #LatestRoles values (2,'Role2')
    --Method 1
    select e.EmplID,MIN(ISNULL(l.Designation,r.Designation)) as Designation
    from #empids e
    left join #emproles r on e.emplID=r.EmpID
    left join #latestRoles l on e.emplID=l.EmpID
    group by e.EmplID
    --Method 2
    ;with cte
    as
    select distinct e.EmplID,r.Designation,count(*) over(partition by e.emplID) cnt
    from #empids e
    left join #emproles r on e.emplID=r.EmpID
    select emplID,Designation
    from cte
    where cnt=1
    UNION ALL
    select a.EmplID,l.Designation
    from
    (select distinct EmplID from cte where cnt>1) a
    join #Latestroles l on a.EmplID=l.EmpID
    order by emplID
    Thanks,
    Jay
    <If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>

  • Need help in Report From SQL Query

    Hi All,
    I am facing a problem with a report. I need your help.
    I am creating a Report From SQL Query (Portal) with some arguments passed at runtime. I am able to view the output, if the query returns few rows ( arount 1000 rows). But for some inputs it needs to generate >15000 records, at this point the page is getting time out (i think!) and showing error page. I am able to execute query from the SQL Plus console ot using TOAD editor. Here the query is not taking more that 2 mins time to show the result.
    If i am executing from Portal i observed that, once i give the appropriate input and hit submit button a new oracle process is getting created for the query on UNIX (I am usign "TOP" command to check processes). The browser page will be shown error page after 5 minutes (i am assuming session time out!) , but on the backend the process will be executed for more than 30 mins.
    I tried also increase the page time out in httpd.conf, but no use.
    The data returned as a result of the query is sized more than 10 MB. Is caching this much data is possible by the browser page? is the returned data is creating any problem here.
    Please help me to find appropriate reasone for the failure?

    user602513 wrote:
    Hi All,
    I am facing a problem with a report. I need your help.
    I am creating a Report From SQL Query (Portal) with some arguments passed at runtime. I am able to view the output, if the query returns few rows ( arount 1000 rows). But for some inputs it needs to generate >15000 records, at this point the page is getting time out (i think!) and showing error page. I am able to execute query from the SQL Plus console ot using TOAD editor. Here the query is not taking more that 2 mins time to show the result.
    If i am executing from Portal i observed that, once i give the appropriate input and hit submit button a new oracle process is getting created for the query on UNIX (I am usign "TOP" command to check processes). The browser page will be shown error page after 5 minutes (i am assuming session time out!) , but on the backend the process will be executed for more than 30 mins.
    I tried also increase the page time out in httpd.conf, but no use.
    The data returned as a result of the query is sized more than 10 MB. Is caching this much data is possible by the browser page? is the returned data is creating any problem here.
    Please help me to find appropriate reasone for the failure?Do you get any errors or warnings or it is just the slow speed which is the issue?
    There could be a variety of reasons for the delayed processing of this report. That includes parameter settings for that page, cache settings, network configurations, etc.
    - explore best optimization for your query;
    - evaluate portal for best performance configuration; you may follow this note (Doc ID: *438794.1* ) for ideas;
    - third: for that particular page carrying that report, you can use caching wisely. browser cache is neither decent for large files, nor practical. instead, explore the page cache settings that portal provides.
    - also look for various log files (application.log and apache logs) if you are getting any warnings reflecting on some kind of processing halt.
    - and last but not the least: if you happen to bring up a portal report with more than 10000 rows for display then think about the usage of the report. Evaluate whether that report is good/useful for anything?
    HTH
    AMN

  • Need help in framing an SQL query

    Hi ,
    Requirement is that
    Let’s say I have a table say X
    I am passing two input params from UI and in DAO i am querying these input prams against the table X(has c1,c2 as columns ) (as it has two columns mapping the input params A,B from UI).
    if either one or Both of the input params matches ,only then i should fetch the records accordingly. It's understood that there won't be a scenario that both input params are null from UI.
    I have three conditions here,
    1.     A match against X, B doesnt Match
    2.     B match against X, A doesnt Match
    3.     Both A & B match against X
    if i use let's say,
    SELECT *FROM X WHERE (c1= A OR c2= B) .
    •     if A match against X B doesnt Match It is fetching all the records matching A - requirement fullfilled
    •     B match against X A doesnt Match It is fetching all the records matching B- requirement fullfilled.
    •     Both A & B match against X It is fetching all the records from the table matching the first condition (which here is A) . requirement not fullfilled.
    I am thinking of using the following query but I need to frame it in a way that based on ACHK & BCHK we need to add the conditions.
    SELECT CASE WHEN C1 = A THEN 0 ELSE 9 END AS ACHK, CASE WHEN C2 = B THEN 0 ELSE 9 END AS BCHK FROM X
    Based on ACHK & BCHK append the conditions. i.e.
    IF ACHK = 0 AND BCHK = 0 THEN
    AND C1 = A AND C2 = B
    ELSE
    AND (C1 = A OR C2 = B)
    Please help.

    Hi,
    963022 wrote:
    Would be glad if you can shed some light on role of DENSE_RANK here (ofcourse i did read the forums but i am confused on what basis a row is ranked).Complicated queries and expressions are usually built of smaller, simpler parts. To understand how the big, complicated thing works, look first at the smaller, simpler components of it, and make sure you understand how they work.
    In this case, the query is composed of a sub-query and a main query. Start by looking at the sub-query only. Display all rows and all columns of the sub-query.
    Break apart the complicated components of that sub-query. Rnk depends on an ORDER BY clause, but the expression used in that ORDER BY clause isn't displayed anywhere. Copy and display just that expression. (I called this case_1_2 in the query below.) Even that may be too complicated to understand, so break it apart. Case_1_2 is formed by adding 2 smaller CASE expressions; in the query below, I displayed each of the in separate columns (case_1 and case_2).
    So here's a query you might use to understand and debug the query I posted:
    WITH     targets          AS
         SELECT     'ABC' AS c1, 10 AS c2  FROM dual     UNION ALL
         SELECT     'ABC',          20            FROM dual     UNION ALL
         SELECT     'FOO',          10            FROM dual     UNION ALL
         SELECT     'FOO',          20            FROM dual     UNION ALL
         SELECT     'FOO',          99            FROM dual
    ,     got_rnk          AS
         SELECT     x.c1, x.c2
         ,     t.c1          AS target_c1
         ,     t.c2          AS target_c2
         ,     DENSE_RANK () OVER ( PARTITION BY  t.c1, t.c2
                                   ORDER BY          CASE
                                                 WHEN  x.c1  = t.c1
                                         THEN  1
                                         ELSE  0
                                             END
                                   + CASE
                                                 WHEN  x.c2  = t.c2
                                         THEN  2
                                         ELSE  0
                                             END
                             DESC
                           )          AS rnk
    --     *****  DEBUGGING SECTION  *****     The following columns are included only
    --                                       to see how the function above works.
         ,                               CASE
                                                 WHEN  x.c1  = t.c1
                                         THEN  1
                                         ELSE  0
                                             END
                                   + CASE
                                                 WHEN  x.c2  = t.c2
                                         THEN  2
                                         ELSE  0
                                             END           AS case_1_2
         ,                               CASE
                                                 WHEN  x.c1  = t.c1
                                         THEN  1
                                         ELSE  0
                                             END           AS case_1
         ,                            CASE
                                                 WHEN  x.c2  = t.c2
                                         THEN  2
                                         ELSE  0
                                             END           AS case_2
    --     *****  END OF DEBUGGING SECTION  *****
         FROM     targets  t
         JOIN           x  ON   x.c1     = t.c1
                       OR   x.c2     = t.c2
    --     The following main query is only for debugging
    SELECT       *
    FROM       got_rnk
    ORDER BY  target_c1, target_c2
    ,            rnk
    ;Output:
                  TARGET TARGET          CASE
    C1         C2 _C1       _C2    RNK   _1_2 CASE_1 CASE_2
    ABC        10 ABC        10      1      3      1      2
    ZZZ        10 ABC        10      2      2      0      2
    ABC         5 ABC        10      3      1      1      0
    ABC         6 ABC        10      3      1      1      0
    ABC         7 ABC        10      3      1      1      0
    ABC         1 ABC        10      3      1      1      0
    ABC         3 ABC        10      3      1      1      0
    ABC         2 ABC        10      3      1      1      0
    ABC         8 ABC        10      3      1      1      0
    ABC         9 ABC        10      3      1      1      0
    ABC         4 ABC        10      3      1      1      0
    ZZZ        20 ABC        20      1      2      0      2
    ABC        10 ABC        20      2      1      1      0
    ABC         2 ABC        20      2      1      1      0
    ABC         1 ABC        20      2      1      1      0
    ABC         9 ABC        20      2      1      1      0
    ABC         8 ABC        20      2      1      1      0
    ABC         7 ABC        20      2      1      1      0
    ABC         6 ABC        20      2      1      1      0
    ABC         5 ABC        20      2      1      1      0
    ABC         4 ABC        20      2      1      1      0
    ABC         3 ABC        20      2      1      1      0
    ABC        10 FOO        10      1      2      0      2
    ZZZ        10 FOO        10      1      2      0      2
    ZZZ        20 FOO        20      1      2      0      2Study this output to see how the different components work.
    For example, the first 12 rows of output show what we found when we were looking for ('ABC', 10). There were 12 rows in table x that had either ca='ABC' or c2=10 (or both). We used the rnk column to find the best match: lower numbers mean better matches. How did we do that? By using the DENSE_RANK function with a DESCending order by clause, that is, we used <tt> DENSE_RANK () OVER (... ORDER BY exp DESC) </tt>, which means that higher values of exp produce lower values from DENSE_RANK. What is exp? It's the column I called case_1_2. As you can see, when there was a perfect match ('ABC', 10), then case_1_2 had the value 3. Less perfect matches got lower values of case_1_2; for example ('ZZZ', 10) only had 2 in the case_1_2 column, and ('ABC', 5) only had 1. Why did case_1_2 have values of 3, 2 or 1 on those rows? Well, it's the sum of case_1 and case_2, so look at those individual columns, and see how they are computed.

  • Need Help on Joining multiple tables in Golden Gate

    Hi,
    Can you please help me with some examples on joining multiple tables in Golden Gate. i.e, my requirement is to Join Table 1 & Table 2 in Source and Load it in Target with 10 fields from Table 1 & 5 fields from Table 2 based on the join condition between Table 1.key = Table2.key
    I have been trying to do that using SQLEXEC command in Golden Gate. But, is there a way I can do this in the Extract parameter file?
    Thanks for your time
    Regards
    Suresh

    Hi,
    Thanks a lot for the prompt reply. I am able to do that for the below scenario
    Source.T1.Field1
    Source.T1.Field2
    Source.T2.Field1
    Source.T2.Field2
    Target Table
    T1.Field1, T1.Field2, T2.Field1, T2.Field2.
    But, if I already have T2.Field1 in T1 table, then T1.Field1 takes the precendence and getting loaded. i.e., I wanted to join the table 1 & Table 2 and based on the matching condition, I will need to populate the data either from T1 or T2.
    Hope you got my requirement.
    Below the Data Dump file & Replicat File.
    EXTRACT dpump
    USERID ********, PASSWORD ********
    RMTHOST *******, MGRPORT 7809
    RMTTRAIL /oracle/gg/dirdat/rt
    --PASSTHRU
    TABLE TABLE1,
    SQLEXEC (ID LOOKUP,
    QUERY "SELECT FIELD1 FROM SOURCE.TABLE2 WHERE FIELD1 = :v_field1",
    PARAMS ( v_field1 = field1 )),
    TOKENS (tk_field_1 = @GETVAL (lookup.field1));
    Replicat file
    REPLICAT repjoin
    ASSUMETARGETDEFS
    HANDLECOLLISIONS
    USERID *******, PASSWORD ********
    MAP SOURCE.T1, TARGET TARGET.GG_TABLE_T1,
    COLMAP ( USEDEFAULTS ,
    field1 = @token ("tk_party_id"));
    I eventually wanted to join like below.
    select t1.field1, t1.field2, t2.field1 from t1, t2
    where t1.field1 = t2.field1;
    Thanks for your time again
    Regards
    Suresh

  • Help tuning this connect by query

    Hi,
    Does anybody know how I can tune this query to run faster?:
    SELECT COUNT(*)
    FROM (
    SELECT PAR_ROW_ID, PAR_DIVN_ID, X_CHEIF, NAME, ATTRIB_01, LEVEL FROM (
    SELECT A.ATTRIB_01,A.PAR_ROW_ID, B.PAR_DIVN_ID,C.X_CHEIF, D.NAME FROM S_ORG_EXT_XM A
    JOIN S_ORG_EXT B ON A.PAR_ROW_ID=B.ROW_ID
    JOIN CX_SAP_POSTN C ON A.ATTRIB_01=C.X_BELONGSORGUNIT
    JOIN S_POSTN D ON C.X_SAP_ID = D.X_SAP_POSTN_ID )
    START WITH ATTRIB_01 = :B1
    CONNECT BY PRIOR PAR_DIVN_ID=PAR_ROW_ID
    ORDER BY LEVEL )
    WHERE X_CHEIF IS NOT NULL
    Explain Plan:
    30 SELECT STATEMENT
    29 SORT [AGGREGATE]
    28 SIEBEL. VIEW
    27 SORT [ORDER BY]
    26 CONNECT BY [WITH FILTERING]
    12 FILTER
    11 COUNT
    10 NESTED LOOPS
    7 NESTED LOOPS
    4 NESTED LOOPS
    1 SIEBEL.CX_SAP_POSTN TABLE ACCESS [FULL]
    3 SIEBEL.S_ORG_EXT_XM TABLE ACCESS [BY INDEX ROWID]
    2 SIEBEL.S_ORG_EXT_XM_ATT01_X INDEX [RANGE SCAN]
    6 SIEBEL.S_ORG_EXT TABLE ACCESS [BY INDEX ROWID]
    5 SIEBEL.S_ORG_EXT_P1 INDEX [UNIQUE SCAN]
    9 SIEBEL.S_POSTN TABLE ACCESS [BY INDEX ROWID]
    8 SIEBEL.S_POSTN_SAPID_X INDEX [RANGE SCAN]
    25 HASH JOIN
    13 CONNECT BY PUMP
    24 COUNT
    23 NESTED LOOPS
    20 NESTED LOOPS
    17 NESTED LOOPS
    14 SIEBEL.CX_SAP_POSTN TABLE ACCESS [FULL]
    16 SIEBEL.S_ORG_EXT_XM TABLE ACCESS [BY INDEX ROWID]
    15 SIEBEL.S_ORG_EXT_XM_ATT01_X INDEX [RANGE SCAN]
    19 SIEBEL.S_ORG_EXT TABLE ACCESS [BY INDEX ROWID]
    18 SIEBEL.S_ORG_EXT_P1 INDEX [UNIQUE SCAN]
    22 SIEBEL.S_POSTN TABLE ACCESS [BY INDEX ROWID]
    21 SIEBEL.S_POSTN_SAPID_X INDEX [RANGE SCAN]

    Who says it is not already running as fast as possible?
    In order to solve a problem, you need to know the problem. Stating something like 'a query is slow and should be faster' is stating an opinion - it is not describing a problem that can be resolved.
    It is easy to comment on the obvious, such as there are two full table scans on SIEBEL.CX_SAP_POSTN. But without additional information, those FTSs could well be a better choice.
    My suggestion is to turn a complex problem, into a bunch of smaller and simpler problems. If you suspect that the query could be faster, pull it apart. Test each step/component of the query in isolation. E.g. start with a single table and progressively add joins to determine what the CBO does with each additional join, what you're asking Oracle to do ito processing, and not only checking that the CBO does not make obvious errors, but that what you're asking via SQL is the best approach to get to the answer.

  • SQL tuning for extremely slow query

    Hi,
    We have a requirement to display sales data by month. The sales data should be summed based on groups. The whole query is dynamically generated so the WHERE clause as well as the GROUP BY columns will be dynamically generated. Please find below the query which has been dynamically generated. The query is extremely slow and is not returning any data even after several minutes.
    Please can anyone suggest possible ways of tuning this query? We are evaluating the option of using Materialied Views with Fast Refresh but the number of tables involved in this query runs into several hundreds and creating log in each table would be tedious.
    Regards,
    Balu
    SELECT trantype, cmp, fyr, nam, cno, loc, or#, prd, siz, dat, ter, reg, gra,
    mjr, mrk, fiscdat, GROUP_ID, class_id, group_name, class_name,
    cmp_sreg, channel, bt_dsc, SUM (CASE fpr
    WHEN 1
    THEN amt
    ELSE 0
    END) AS a1,
    SUM (CASE fpr
    WHEN 2
    THEN amt
    ELSE 0
    END) AS a2, SUM (CASE fpr
    WHEN 3
    THEN amt
    ELSE 0
    END) AS a3,
    SUM (CASE fpr
    WHEN 4
    THEN amt
    ELSE 0
    END) AS a4, SUM (CASE fpr
    WHEN 5
    THEN amt
    ELSE 0
    END) AS a5,
    SUM (CASE fpr
    WHEN 6
    THEN amt
    ELSE 0
    END) AS a6, SUM (CASE fpr
    WHEN 7
    THEN amt
    ELSE 0
    END) AS a7,
    SUM (CASE fpr
    WHEN 8
    THEN amt
    ELSE 0
    END) AS a8, SUM (CASE fpr
    WHEN 9
    THEN amt
    ELSE 0
    END) AS a9,
    SUM (CASE fpr
    WHEN 10
    THEN amt
    ELSE 0
    END) AS a10, SUM (CASE fpr
    WHEN 11
    THEN amt
    ELSE 0
    END) AS a11,
    SUM (CASE fpr
    WHEN 12
    THEN amt
    ELSE 0
    END) AS a12, SUM (CASE fpr
    WHEN 1
    THEN qty
    ELSE 0
    END) AS q1,
    SUM (CASE fpr
    WHEN 2
    THEN qty
    ELSE 0
    END) AS q2, SUM (CASE fpr
    WHEN 3
    THEN qty
    ELSE 0
    END) AS q3,
    SUM (CASE fpr
    WHEN 4
    THEN qty
    ELSE 0
    END) AS q4, SUM (CASE fpr
    WHEN 5
    THEN qty
    ELSE 0
    END) AS q5,
    SUM (CASE fpr
    WHEN 6
    THEN qty
    ELSE 0
    END) AS q6, SUM (CASE fpr
    WHEN 7
    THEN qty
    ELSE 0
    END) AS q7,
    SUM (CASE fpr
    WHEN 8
    THEN qty
    ELSE 0
    END) AS q8, SUM (CASE fpr
    WHEN 9
    THEN qty
    ELSE 0
    END) AS q9,
    SUM (CASE fpr
    WHEN 10
    THEN qty
    ELSE 0
    END) AS q10, SUM (CASE fpr
    WHEN 11
    THEN qty
    ELSE 0
    END) AS q11,
    SUM (CASE fpr
    WHEN 12
    THEN qty
    ELSE 0
    END) AS q12,
    SUM (CASE fpr
    WHEN 1
    THEN (amt - (((frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cm1,
    SUM (CASE fpr
    WHEN 2
    THEN (amt - (((frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cm2,
    SUM (CASE fpr
    WHEN 3
    THEN (amt - (((frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cm3,
    SUM (CASE fpr
    WHEN 4
    THEN (amt - (((frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cm4,
    SUM (CASE fpr
    WHEN 5
    THEN (amt - (((frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cm5,
    SUM (CASE fpr
    WHEN 6
    THEN (amt - (((frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cm6,
    SUM (CASE fpr
    WHEN 7
    THEN (amt - (((frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cm7,
    SUM (CASE fpr
    WHEN 8
    THEN (amt - (((frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cm8,
    SUM (CASE fpr
    WHEN 9
    THEN (amt - (((frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cm9,
    SUM (CASE fpr
    WHEN 10
    THEN (amt - (((frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cm10,
    SUM (CASE fpr
    WHEN 11
    THEN (amt - (((frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cm11,
    SUM (CASE fpr
    WHEN 12
    THEN (amt - (((frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cm12,
    SUM (CASE fpr
    WHEN 0
    THEN (amt - (((lrt + frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cml0,
    SUM (CASE fpr
    WHEN 1
    THEN (amt - (((lrt + frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cml1,
    SUM (CASE fpr
    WHEN 2
    THEN (amt - (((lrt + frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cml2,
    SUM (CASE fpr
    WHEN 3
    THEN (amt - (((lrt + frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cml3,
    SUM (CASE fpr
    WHEN 4
    THEN (amt - (((lrt + frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cml4,
    SUM (CASE fpr
    WHEN 5
    THEN (amt - (((lrt + frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cml5,
    SUM (CASE fpr
    WHEN 6
    THEN (amt - (((lrt + frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cml6,
    SUM (CASE fpr
    WHEN 7
    THEN (amt - (((lrt + frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cml7,
    SUM (CASE fpr
    WHEN 8
    THEN (amt - (((lrt + frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cml8,
    SUM (CASE fpr
    WHEN 9
    THEN (amt - (((lrt + frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cml9,
    SUM (CASE fpr
    WHEN 10
    THEN (amt - (((lrt + frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cml10,
    SUM (CASE fpr
    WHEN 11
    THEN (amt - (((lrt + frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cml11,
    SUM (CASE fpr
    WHEN 12
    THEN (amt - (((lrt + frt + mrt + csc)) * qty))
    ELSE 0
    END
    ) AS cml12,
    SUM (amt) AS a, SUM (qty) AS q,
    SUM ((amt - (((frt + mrt + csc)) * qty))) AS cm,
    SUM ((amt - (((lrt + frt + mrt + csc)) * qty))) AS cml
    FROM (SELECT ruec_a.seq, ruec_a.trantype, ruec_a.cmp, ruec_a.fyr,
    ruec_a.fpr, ruec_a.csc, ruec_a.lrt, ruec_a.mrt, ruec_a.frt,
    ruec_a.typ, ruec_a.nam, ruec_a.cno, ruec_a.loc, ruec_a.or#,
    ruec_a.prd, ruec_a.bulk_item_no, ruec_a.siz, ruec_a.dat,
    NVL (ruec_a.qty, 0) qty, ruec_a.amt, ruec_a.ter, ruec_a.reg,
    ruec_a.gra, ruec_a.mjr, ruec_a.mrk, ruec_a.fiscdat,
    ruec_a.group_name, ruec_a.class_name, ruec_a.GROUP_ID,
    ruec_a.cur, ruec_a.conversion_rate, ruec_a.grpnum,
    ruec_a.rgnshi, ruec_a.mktshi, ruec_a.slmshi, ruec_a.mjrshi,
    ruec_a.cmpid, ruec_a.chnshi, ruec_a.srgshi, ruec_a.sh_sreg,
    ruec_a.cmp_sreg, ruec_a.channel, ruec_a.srgcmp,
    ruec_a.biz_typ, ruec_a.bt_dsc, amt / NVL (qty, 1) qty$,
    NVL ((amt - ((qty * csc) + (qty * frt) + (qty * mrt))),
    0) cm,
    NVL ((amt - (((frt + mrt + csc)) * qty)) / NVL (qty, 1),
    0
    ) cm$,
    NVL (( (( amt
    - ( (qty * csc)
    + (qty * frt)
    + (qty * mrt * 100)
    + (qty * lrt)
    / 100
    0
    ) gp,
    ((CASE amt
    WHEN 0
    THEN 0
    ELSE NVL (( ( amt
    - ( (qty * csc)
    + (qty * frt)
    + (qty * mrt * 100)
    + (qty * lrt)
    / amt
    0
    END
    ) pm,
    ruec_a.customer_trx_id, ruec_a.customer_trx_line_id,
    ruec_a.inventory_item_id, ruec_a.item_id, line_id, header_id,
    ruec_a.customer_id, ruec_a.site_use_id, ruec_a.class_id
    FROM (SELECT xxsrg.line_number seq, xxsrg.trantype,
    xxsrg.co_code cmp, xxsrg.period_year fyr,
    xxsrg.period_num fpr, csc_invcur * conv_rate csc,
    lrt_invcur * conv_rate lrt,
    mrt_invcur * conv_rate mrt,
    xxsrg.frt_invcur * conv_rate frt,
    xxsrg.inv_class typ, xxsrg.site_name nam,
    xxsrg.customer_number cno, xxsrg.site_number loc,
    xxsrg.ct_reference "OR#", xxsrg.item_no prd,
    xxsrg.bulk_item_no, xxsrg.container_type siz,
    xxsrg.trx_date dat, qty,
    xxsrg.amt_invcur * conv_rate amt,
    xxsrg.sales_territory_name ter,
    xxsrg.sales_region_name reg,
    xxsrg.customer_group_name gra,
    xxsrg.major_market_name mjr,
    xxsrg.minor_market_name mrk, xxsrg.trx_date fiscdat,
    xxsrg.group_name group_name,
    xxsrg.class_name class_name,
    NVL (xxsrg.GROUP_ID, 0) GROUP_ID, xxsrg.inv_cur cur,
    conv_rate conversion_rate,
    xxsrg.customer_group_code grpnum,
    xxsrg.sales_region_code rgnshi,
    xxsrg.minor_market_id mktshi,
    xxsrg.salesrep_id slmshi,
    xxsrg.major_market_id mjrshi,
    xxsrg.organization_id cmpid,
    xxsrg.sales_channel_code chnshi, xxsrg.ssr_id srgshi,
    xxsrg.ssr_name sh_sreg, xxsrg.psr_name cmp_sreg,
    xxsrg.sales_channel_code channel,
    xxsrg.psr_id srgcmp, xxsrg.biz_typ,
    xxsrg.biz_typ_dsc bt_dsc, xxsrg.customer_trx_id,
    xxsrg.customer_trx_line_id, xxsrg.inventory_item_id,
    xxsrg.item_id, xxsrg.line_id, xxsrg.customer_id,
    xxsrg.site_use_id, 0 class_id, 0 header_id
    FROM (SELECT xxsrg.*,
    CASE
    WHEN 'CAD' = xxsrg.inv_cur
    THEN 1
    ELSE xxaoc_int_srg_util.get_dly_rate
    (xxsrg.inv_cur,
    'CAD',
    xxsrg.trx_date
    END conv_rate,
    CASE
    WHEN 'KG' = 'LB'
    THEN xxsrg.qty_lbs
    ELSE xxsrg.qty_kgs
    END qty
    FROM apps.xxaoc_bs_srg_details_vw xxsrg) xxsrg) ruec_a
    WHERE (fiscdat >= '01-APR-06' AND fiscdat <= '01-APR-09')
    AND (prd LIKE '%H864%')
    AND grpnum IN (274, 275)
    AND class_id IN (54)
    AND GROUP_ID IN (10)
    AND mjrshi IN ('4')
    AND mktshi IN ('21')
    AND rgnshi IN ('ER')
    AND slmshi IN (10045)
    AND cmpid IN (462)) ruec_a
    GROUP BY trantype,
    cmp,
    fyr,
    nam,
    cno,
    loc,
    or#,
    prd,
    siz,
    dat,
    ter,
    reg,
    gra,
    mjr,
    mrk,
    fiscdat,
    GROUP_ID,
    class_id,
    group_name,
    class_name,
    GROUP_ID,
    class_id,
    chnshi,
    srgshi,
    sh_sreg,
    cmp_sreg,
    channel,
    srgcmp,
    biz_typ,
    bt_dsc

    The database version is 10.2.0.3.0. Explain Plan is provided below please:
    Plan
    SELECT STATEMENT CHOOSECost: 435 Bytes: 10,402 Cardinality: 1                                                                                                                                                                                               
         182 SORT GROUP BY Cost: 435 Bytes: 10,402 Cardinality: 1                                                                                                                                                                                          
              181 VIEW SRG. Cost: 409 Bytes: 10,402 Cardinality: 1                                                                                                                                                                                     
                   180 FILTER                                                                                                                                                                                
                        166 NESTED LOOPS Cost: 399 Bytes: 10,736 Cardinality: 1                                                                                                                                                                           
                             163 NESTED LOOPS OUTER Cost: 396 Bytes: 10,693 Cardinality: 1                                                                                                                                                                      
                                  160 HASH JOIN OUTER Cost: 393 Bytes: 10,646 Cardinality: 1                                                                                                                                                                 
                                       117 HASH JOIN Cost: 299 Bytes: 10,636 Cardinality: 1                                                                                                                                                            
                                            32 HASH JOIN Cost: 240 Bytes: 299 Cardinality: 1                                                                                                                                                       
                                                 27 FILTER                                                                                                                                                  
                                                      26 NESTED LOOPS OUTER Cost: 22 Bytes: 3,060 Cardinality: 12                                                                                                                                             
                                                           23 HASH JOIN OUTER Cost: 19 Bytes: 232 Cardinality: 1                                                                                                                                        
                                                                18 NESTED LOOPS OUTER Cost: 12 Bytes: 216 Cardinality: 1                                                                                                                                   
                                                                     15 VIEW VIEW APPS.XXAOC_RA_CUST_TRX_LINES_VW Cost: 9 Bytes: 147 Cardinality: 1                                                                                                                              
                                                                          14 FILTER                                                                                                                         
                                                                               10 FILTER                                                                                                                    
                                                                                    9 NESTED LOOPS Cost: 5 Bytes: 195 Cardinality: 1                                                                                                               
                                                                                         6 NESTED LOOPS Cost: 4 Bytes: 171 Cardinality: 1                                                                                                          
                                                                                              4 NESTED LOOPS Cost: 4 Bytes: 163 Cardinality: 1                                                                                                     
                                                                                                   1 TABLE ACCESS FULL TABLE AR.RA_CUSTOMER_TRX_LINES_ALL Cost: 3 Bytes: 34 Cardinality: 1                                                                                                
                                                                                                   3 TABLE ACCESS BY INDEX ROWID TABLE AR.RA_CUSTOMER_TRX_ALL Cost: 1 Bytes: 129 Cardinality: 1                                                                                                
                                                                                                        2 INDEX UNIQUE SCAN INDEX (UNIQUE) AR.RA_CUSTOMER_TRX_U1 Cardinality: 1                                                                                           
                                                                                              5 INDEX UNIQUE SCAN INDEX (UNIQUE) AR.RA_BATCH_SOURCES_U2 Bytes: 8 Cardinality: 1                                                                                                     
                                                                                         8 TABLE ACCESS BY INDEX ROWID TABLE AR.RA_CUST_TRX_TYPES_ALL Cost: 1 Bytes: 24 Cardinality: 1                                                                                                          
                                                                                              7 INDEX UNIQUE SCAN INDEX (UNIQUE) AR.RA_CUST_TRX_TYPES_U1 Cardinality: 1                                                                                                     
                                                                               13 COUNT STOPKEY                                                                                                                    
                                                                                    12 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_SYSTEM_ITEMS_B Cost: 4 Bytes: 22 Cardinality: 1                                                                                                               
                                                                                         11 INDEX RANGE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_B_U1 Cost: 3 Cardinality: 1                                                                                                          
                                                                     17 TABLE ACCESS BY INDEX ROWID TABLE APPLSYS.FND_LOOKUP_VALUES Cost: 3 Bytes: 69 Cardinality: 1                                                                                                                              
                                                                          16 INDEX RANGE SCAN INDEX (UNIQUE) APPLSYS.FND_LOOKUP_VALUES_U1 Cost: 2 Cardinality: 1                                                                                                                         
                                                                22 VIEW VIEW APPS.CM_CLDR_HDR_VL Cost: 6 Bytes: 1,632 Cardinality: 102                                                                                                                                   
                                                                     21 NESTED LOOPS Cost: 6 Bytes: 2,346 Cardinality: 102                                                                                                                              
                                                                          19 TABLE ACCESS FULL TABLE GMF.CM_CLDR_HDR_B Cost: 6 Bytes: 1,632 Cardinality: 102                                                                                                                         
                                                                          20 INDEX RANGE SCAN INDEX GMF.CM_CLDR_HDR_TL_PK Bytes: 7 Cardinality: 1                                                                                                                         
                                                           25 TABLE ACCESS BY INDEX ROWID TABLE GMF.CM_CLDR_DTL Cost: 3 Bytes: 276 Cardinality: 12                                                                                                                                        
                                                                24 INDEX RANGE SCAN INDEX (UNIQUE) GMF.CM_CLDR_DTL_PK Cost: 1 Cardinality: 12                                                                                                                                   
                                                 31 VIEW VIEW APPS.XXAOC_IC_ITEM_MST_VW Cost: 217 Bytes: 82,632 Cardinality: 1,878                                                                                                                                                  
                                                      30 NESTED LOOPS Cost: 217 Bytes: 61,974 Cardinality: 1,878                                                                                                                                             
                                                           28 TABLE ACCESS FULL TABLE GMI.IC_ITEM_MST_B Cost: 217 Bytes: 46,950 Cardinality: 1,878                                                                                                                                        
                                                           29 INDEX UNIQUE SCAN INDEX (UNIQUE) GMI.IC_ITEM_MST_TL_PK Bytes: 8 Cardinality: 1                                                                                                                                        
                                            116 VIEW VIEW APPS.XXAOC_BS_CUST_SITE_VW Cost: 58 Bytes: 10,337 Cardinality: 1                                                                                                                                                       
                                                 115 SORT ORDER BY Cost: 58 Bytes: 1,149 Cardinality: 1                                                                                                                                                  
                                                      114 FILTER                                                                                                                                             
                                                           113 NESTED LOOPS OUTER Cost: 33 Bytes: 1,149 Cardinality: 1                                                                                                                                        
                                                                110 FILTER                                                                                                                                   
                                                                     109 NESTED LOOPS OUTER Cost: 31 Bytes: 1,130 Cardinality: 1                                                                                                                              
                                                                          106 NESTED LOOPS OUTER Cost: 30 Bytes: 1,111 Cardinality: 1                                                                                                                         
                                                                               104 NESTED LOOPS OUTER Cost: 29 Bytes: 1,088 Cardinality: 1                                                                                                                    
                                                                                    101 NESTED LOOPS Cost: 29 Bytes: 1,041 Cardinality: 1                                                                                                               
                                                                                         99 NESTED LOOPS OUTER Cost: 29 Bytes: 1,037 Cardinality: 1                                                                                                          
                                                                                              97 NESTED LOOPS Cost: 28 Bytes: 1,001 Cardinality: 1                                                                                                     
                                                                                                   94 NESTED LOOPS Cost: 27 Bytes: 910 Cardinality: 1                                                                                                
                                                                                                        92 NESTED LOOPS Cost: 26 Bytes: 902 Cardinality: 1                                                                                           
                                                                                                             89 NESTED LOOPS Cost: 25 Bytes: 796 Cardinality: 1                                                                                      
                                                                                                                  86 NESTED LOOPS Cost: 24 Bytes: 773 Cardinality: 1                                                                                 
                                                                                                                       83 NESTED LOOPS OUTER Cost: 23 Bytes: 678 Cardinality: 1                                                                            
                                                                                                                            81 NESTED LOOPS Cost: 23 Bytes: 675 Cardinality: 1                                                                       
                                                                                                                                 78 NESTED LOOPS OUTER Cost: 22 Bytes: 666 Cardinality: 1                                                                  
                                                                                                                                      76 NESTED LOOPS OUTER Cost: 22 Bytes: 662 Cardinality: 1                                                             
                                                                                                                                           70 NESTED LOOPS OUTER Cost: 22 Bytes: 649 Cardinality: 1                                                        
                                                                                                                                                64 NESTED LOOPS OUTER Cost: 22 Bytes: 636 Cardinality: 1                                                   
                                                                                                                                                     54 NESTED LOOPS OUTER Cost: 21 Bytes: 609 Cardinality: 1                                              
                                                                                                                                                          52 NESTED LOOPS OUTER Cost: 20 Bytes: 573 Cardinality: 1                                         
                                                                                                                                                               50 NESTED LOOPS OUTER Cost: 18 Bytes: 515 Cardinality: 1                                    
                                                                                                                                                                    47 NESTED LOOPS OUTER Cost: 17 Bytes: 457 Cardinality: 1                               
                                                                                                                                                                         45 NESTED LOOPS OUTER Cost: 15 Bytes: 421 Cardinality: 1                          
                                                                                                                                                                              43 NESTED LOOPS Cost: 13 Bytes: 385 Cardinality: 1                     
                                                                                                                                                                                   40 NESTED LOOPS Cost: 12 Bytes: 290 Cardinality: 1                
                                                                                                                                                                                        37 NESTED LOOPS OUTER Cost: 11 Bytes: 237 Cardinality: 1           
                                                                                                                                                                                             35 HASH JOIN Cost: 10 Bytes: 143 Cardinality: 1      
                                                                                                                                                                                                  33 TABLE ACCESS FULL TABLE AR.RA_TERRITORIES Cost: 3 Bytes: 34 Cardinality: 1
                                                                                                                                                                                                  34 TABLE ACCESS FULL TABLE AR.HZ_CUST_SITE_USES_ALL Cost: 6 Bytes: 11,336 Cardinality: 104
                                                                                                                                                                                             36 INDEX RANGE SCAN INDEX (UNIQUE) JTF.JTF_RS_SALESREPS_U1 Cost: 1 Cardinality: 11      
                                                                                                                                                                                        39 TABLE ACCESS BY INDEX ROWID TABLE AR.HZ_CUST_ACCT_SITES_ALL Cost: 1 Bytes: 53 Cardinality: 1           
                                                                                                                                                                                             38 INDEX UNIQUE SCAN INDEX (UNIQUE) AR.HZ_CUST_ACCT_SITES_U1 Cardinality: 1      
                                                                                                                                                                                   42 TABLE ACCESS BY INDEX ROWID TABLE AR.HZ_CUST_ACCOUNTS Cost: 1 Bytes: 95 Cardinality: 1                
                                                                                                                                                                                        41 INDEX UNIQUE SCAN INDEX (UNIQUE) AR.HZ_CUST_ACCOUNTS_U1 Cardinality: 1           
                                                                                                                                                                              44 INDEX RANGE SCAN INDEX (UNIQUE) APPLSYS.FND_LOOKUP_VALUES_U1 Cost: 2 Bytes: 36 Cardinality: 1                     
                                                                                                                                                                         46 INDEX RANGE SCAN INDEX (UNIQUE) APPLSYS.FND_LOOKUP_VALUES_U1 Cost: 2 Bytes: 36 Cardinality: 1                          
                                                                                                                                                                    49 TABLE ACCESS BY INDEX ROWID TABLE APPLSYS.FND_LOOKUP_VALUES Cost: 1 Bytes: 58 Cardinality: 1                               
                                                                                                                                                                         48 INDEX UNIQUE SCAN INDEX (UNIQUE) APPLSYS.FND_LOOKUP_VALUES_U1 Cost: 1 Cardinality: 1                          
                                                                                                                                                               51 INDEX UNIQUE SCAN INDEX (UNIQUE) APPLSYS.FND_LOOKUP_VALUES_U1 Cost: 1 Cardinality: 1                                    
                                                                                                                                                          53 INDEX UNIQUE SCAN INDEX (UNIQUE) APPLSYS.FND_LOOKUP_VALUES_U1 Cost: 1 Bytes: 36 Cardinality: 1                                         
                                                                                                                                                     63 VIEW PUSHED PREDICATE VIEW APPS.RA_SALESREPS Cost: 1 Bytes: 27 Cardinality: 1                                              
                                                                                                                                                          62 NESTED LOOPS Cost: 4 Bytes: 59 Cardinality: 1                                         
                                                                                                                                                               59 NESTED LOOPS Cost: 3 Bytes: 22 Cardinality: 1                                    
                                                                                                                                                                    56 TABLE ACCESS BY INDEX ROWID TABLE JTF.JTF_RS_SALESREPS Cost: 2 Bytes: 11 Cardinality: 1                               
                                                                                                                                                                         55 INDEX RANGE SCAN INDEX (UNIQUE) JTF.JTF_RS_SALESREPS_U1 Cost: 1 Cardinality: 1                          
                                                                                                                                                                    58 TABLE ACCESS BY INDEX ROWID TABLE JTF.JTF_RS_RESOURCE_EXTNS Cost: 1 Bytes: 11 Cardinality: 1                               
                                                                                                                                                                         57 INDEX UNIQUE SCAN INDEX (UNIQUE) JTF.JTF_RS_RESOURCE_EXTNS_U1 Cardinality: 1                          
                                                                                                                                                               61 INLIST ITERATOR                                    
                                                                                                                                                                    60 INDEX UNIQUE SCAN INDEX (UNIQUE) JTF.JTF_RS_EXTNS_U1 Cardinality: 1                               
                                                                                                                                                69 VIEW PUSHED PREDICATE VIEW APPS.OE_PRICE_LISTS_115_VL Bytes: 13 Cardinality: 1                                                   
                                                                                                                                                     68 NESTED LOOPS Cost: 1 Bytes: 62 Cardinality: 1                                              
                                                                                                                                                          66 TABLE ACCESS BY INDEX ROWID TABLE QP.QP_LIST_HEADERS_B Cost: 1 Bytes: 45 Cardinality: 1                                         
                                                                                                                                                               65 INDEX UNIQUE SCAN INDEX (UNIQUE) QP.QP_LIST_HEADERS_B_PK Cardinality: 1                                    
                                                                                                                                                          67 INDEX UNIQUE SCAN INDEX (UNIQUE) QP.QP_LIST_HEADERS_TL_PK Bytes: 17 Cardinality: 1                                         
                                                                                                                                           75 VIEW PUSHED PREDICATE VIEW APPS.OE_ORDER_TYPES_115 Bytes: 13 Cardinality: 1                                                        
                                                                                                                                                74 NESTED LOOPS Cost: 1 Bytes: 43 Cardinality: 1                                                   
                                                                                                                                                     72 TABLE ACCESS BY INDEX ROWID TABLE ONT.OE_TRANSACTION_TYPES_ALL Cost: 1 Bytes: 26 Cardinality: 1                                              
                                                                                                                                                          71 INDEX UNIQUE SCAN INDEX (UNIQUE) ONT.OE_TRANSACTION_TYPES_ALL_U1 Cardinality: 1                                         
                                                                                                                                                     73 INDEX UNIQUE SCAN INDEX (UNIQUE) ONT.OE_TRANSACTION_TYPES_TL_U1 Bytes: 17 Cardinality: 1                                              
                                                                                                                                      77 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_ORGANIZATION_UNITS_PK Bytes: 4 Cardinality: 1                                                             
                                                                                                                                 80 TABLE ACCESS BY INDEX ROWID TABLE AR.HZ_CUSTOMER_PROFILES Cost: 1 Bytes: 9 Cardinality: 1                                                                  
                                                                                                                                      79 INDEX RANGE SCAN INDEX AR.HZ_CUSTOMER_PROFILES_N1 Cardinality: 1                                                             
                                                                                                                            82 INDEX UNIQUE SCAN INDEX (UNIQUE) AR.HZ_CUST_PROFILE_CLASSES_U1 Bytes: 3 Cardinality: 1                                                                       
                                                                                                                       85 TABLE ACCESS BY INDEX ROWID TABLE AR.HZ_CUST_ACCOUNTS Cost: 1 Bytes: 95 Cardinality: 1                                                                            
                                                                                                                            84 INDEX UNIQUE SCAN INDEX (UNIQUE) AR.HZ_CUST_ACCOUNTS_U1 Cardinality: 1                                                                       
                                                                                                                  88 TABLE ACCESS BY INDEX ROWID TABLE AR.HZ_PARTY_SITES Cost: 1 Bytes: 23 Cardinality: 1                                                                                 
                                                                                                                       87 INDEX UNIQUE SCAN INDEX (UNIQUE) AR.HZ_PARTY_SITES_U1 Cardinality: 1                                                                            
                                                                                                             91 TABLE ACCESS BY INDEX ROWID TABLE AR.HZ_LOCATIONS Cost: 1 Bytes: 106 Cardinality: 1                                                                                      
                                                                                                                  90 INDEX UNIQUE SCAN INDEX (UNIQUE) AR.HZ_LOCATIONS_U1 Cardinality: 1                                                                                 
                                                                                                        93 INDEX RANGE SCAN INDEX AR.HZ_LOC_ASSIGNMENTS_N1 Cost: 1 Bytes: 8 Cardinality: 1                                                                                           
                                                                                                   96 TABLE ACCESS BY INDEX ROWID TABLE AR.HZ_PARTIES Cost: 1 Bytes: 91 Cardinality: 1                                                                                                
                                                                                                        95 INDEX UNIQUE SCAN INDEX (UNIQUE) AR.HZ_PARTIES_U1 Cardinality: 1                                                                                           
                                                                                              98 INDEX UNIQUE SCAN INDEX (UNIQUE) APPLSYS.FND_LOOKUP_VALUES_U1 Cost: 1 Bytes: 36 Cardinality: 1                                                                                                     
                                                                                         100 INDEX UNIQUE SCAN INDEX (UNIQUE) AR.HZ_PARTIES_U1 Bytes: 4 Cardinality: 1                                                                                                          
                                                                                    103 TABLE ACCESS BY INDEX ROWID TABLE AR.HZ_CONTACT_PREFERENCES Bytes: 47 Cardinality: 1                                                                                                               
                                                                                         102 INDEX RANGE SCAN INDEX AR.HZ_CONTACT_PREFERENCES_N1 Cardinality: 1                                                                                                          
                                                                               105 INDEX RANGE SCAN INDEX AR.HZ_CONTACT_POINTS_N6 Cost: 1 Bytes: 23 Cardinality: 1                                                                                                                    
                                                                          108 TABLE ACCESS BY INDEX ROWID TABLE AR.HZ_ORGANIZATION_PROFILES Cost: 1 Bytes: 19 Cardinality: 1                                                                                                                         
                                                                               107 INDEX RANGE SCAN INDEX AR.HZ_ORGANIZATION_PROFILES_N1 Cardinality: 1                                                                                                                    
                                                                112 TABLE ACCESS BY INDEX ROWID TABLE AR.HZ_PERSON_PROFILES Cost: 2 Bytes: 19 Cardinality: 1                                                                                                                                   
                                                                     111 INDEX RANGE SCAN INDEX AR.HZ_PERSON_PROFILES_N1 Cost: 1 Cardinality: 1                                                                                                                              
                                       159 VIEW VIEW APPS.XXAOC_SALES_REGION_VW Cost: 94 Bytes: 40 Cardinality: 4                                                                                                                                                            
                                            158 SORT ORDER BY Cost: 94 Bytes: 2,736 Cardinality: 4                                                                                                                                                       
                                                 157 VIEW VIEW APPS.XXAOC_CT_KFF_VW Cost: 69 Bytes: 2,736 Cardinality: 4                                                                                                                                                  
                                                      156 SORT ORDER BY Cost: 69 Bytes: 800 Cardinality: 4                                                                                                                                             
                                                           155 CONCATENATION                                                                                                                                        
                                                                127 MERGE JOIN CARTESIAN Cost: 11 Bytes: 200 Cardinality: 1                                                                                                                                   
                                                                     123 NESTED LOOPS Cost: 5 Bytes: 82 Cardinality: 1                                                                                                                              
                                                                          120 NESTED LOOPS Cost: 4 Bytes: 54 Cardinality: 1                                                                                                                         
                                                                               118 TABLE ACCESS FULL TABLE APPLSYS.FND_ID_FLEX_SEGMENTS Cost: 4 Bytes: 28 Cardinality: 1                                                                                                                    
                                                                               119 INDEX UNIQUE SCAN INDEX (UNIQUE) APPLSYS.FND_ID_FLEX_SEGMENTS_TL_U1 Bytes: 26 Cardinality: 1                                                                                                                    
                                                                          122 TABLE ACCESS BY INDEX ROWID TABLE APPLSYS.FND_FLEX_VALUE_SETS Cost: 1 Bytes: 28 Cardinality: 1                                                                                                                         
                                                                               121 INDEX UNIQUE SCAN INDEX (UNIQUE) APPLSYS.FND_FLEX_VALUE_SETS_U1 Cardinality: 1                                                                                                                    
                                                                     126 BUFFER SORT Cost: 10 Bytes: 2,714 Cardinality: 23                                                                                                                              
                                                                          125 TABLE ACCESS BY INDEX ROWID TABLE APPLSYS.FND_LOOKUP_VALUES Cost: 6 Bytes: 2,714 Cardinality: 23                                                                                                                         
                                                                               124 INDEX RANGE SCAN INDEX (UNIQUE) APPLSYS.FND_LOOKUP_VALUES_U1 Cost: 2 Cardinality: 23                                                                                                                    
                                                                136 TABLE ACCESS BY INDEX ROWID TABLE APPLSYS.FND_LOOKUP_VALUES Cost: 6 Bytes: 2,714 Cardinality: 23                                                                                                                                   
                                                                     135 NESTED LOOPS Cost: 11 Bytes: 200 Cardinality: 1                                                                                                                              
                                                                          133 NESTED LOOPS Cost: 5 Bytes: 82 Cardinality: 1                                                                                                                         
                                                                               130 NESTED LOOPS Cost: 4 Bytes: 54 Cardinality: 1                                                                                                                    
                                                                                    128 TABLE ACCESS FULL TABLE APPLSYS.FND_ID_FLEX_SEGMENTS Cost: 4 Bytes: 28 Cardinality: 1                                                                                                               
                                      

Maybe you are looking for

  • Error while posting the transaction in F-02

    Dear Friends, Kindly give me acceptable solution to the below error/ticket while user posting a transaction in F-02. ERROR: " system error in routine FI_TAX_CHK_PRICING_DATA_ error code 13 function builder TAX2"

  • ITunes 10 - No longer sync PDFs to iBooks on iPad

    Immediately following the upgrade to iTunes 10, I can no longer sync PDF's to my iPad (v3.2.2) for use with iBooks. Is anyone else having the same issue and even more importantly, has anyone resolved this?

  • Need help for using at new command

    Hi   experts can u please help me .i want to execute the following : customer name       item no   gaurav                      1 gopi                          2 santosh                      1 raju                            2 gaurav                  

  • Battery sitting on 0% charged

    my macbook air 11 inch has never given an issue like this before. last night I plugged it in, seeing that the power was completely flat. the orange light on the charger never came on, but when I pressed the power button it came on. HOWEVER, after sev

  • [ID CS3 (Win)] - where does InDesign store my PDF file name?

    Have you run into this before? You have a document (let's call it "MyDoc.indd") and you want to use it as the basis for a new document ("NewDoc.indd"). So you open MyDoc, Save As "NewDoc". You now work on NewDoc. Some time later, you go to Export New