Tuning The Query By Using Xplain Plan

Hi Guys,
This particular query is taking a long time in the production reported by The SPE team .
SELECT
CASE
WHEN TPJRCSHDRW1.CASH_DRAWER_ID = 5000555
THEN 1
WHEN TPTRJO1.OTHER_CASH_DRAWER_ID = 5000555
THEN 2
END TRADE_TYPE,
TPDECO1.DENOMINATION_COUNT_ID,
TPDECO1.DENOMINATION_CATEGORY,
TPDECO1.DENOMINATION_VALUE,
TPDECO1.DENOMINATION_COUNT,
TPDECO1.DENOMINATION_TYPE,
TPDECO1.DENOMINATION_NAME,
TPTRJO1.TRANSACTION_ID,
TPTRJO1.TOTAL_VALUE,
TPTRJO1.TOTAL_VALUE_CCODE,
TPTRJO1.JOURNAL_ENTRY_ID,
TPJRCSHDRW1.CASH_DRAWER_ID,
TPTRJO1.OTHER_CASH_DRAWER_ID
FROM TRANSACTION_JOURNAL TPTRJO1
INNER JOIN JOURNAL_CASH_DRAWER TPJRCSHDRW1
ON TPTRJO1.JOURNAL_ENTRY_ID = TPJRCSHDRW1.JOURNAL_ENTRY_ID
LEFT OUTER JOIN DENOMINATION_COUNT TPDECO1
ON TPDECO1.JOURNAL_ENTRY_ID = TPJRCSHDRW1.JOURNAL_ENTRY_ID
WHERE ((TPJRCSHDRW1.CASH_DRAWER_ID = 5000555)
OR (TPTRJO1.OTHER_CASH_DRAWER_ID = 5000555))
AND (TPTRJO1.TRANSACTION_ID IN (563,590,1362,605,562,589,604))
AND (TPTRJO1.STATUS NOT IN ('I','V','R'))
AND ((TPTRJO1.REVERSED_BY) IS NULL) AND (TPJRCSHDRW1.CASH_DRAWER_DATE >= to_date('2009-07-24','yyyy-mm-dd') )
AND (TPTRJO1.TOTAL_VALUE <> 0)
AND ((TPTRJO1.OFFSET_ID) IS NULL);
When I am analysing the query by xplain_plan , I am getting this plan
Plan hash value: 3371088438
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 36557 | 3391K| 1445 (1)| 00:00:18 |
| 1 | CONCATENATION | | | | | |
| 2 | NESTED LOOPS OUTER | | 1 | 95 | 3 (0)| 00:00:01 |
| 3 | NESTED LOOPS | | 1 | 63 | 2 (0)| 00:00:01 |
|* 4 | TABLE ACCESS BY INDEX ROWID| TRANSACTION_JOURNAL | 1 | 40 | 1 (0)| 00:00:01 |
|* 5 | INDEX RANGE SCAN | I26_TRANSACTION_JOURNAL | 1 | | 1 (0)| 00:00:01 |
|* 6 | TABLE ACCESS BY INDEX ROWID| JOURNAL_CASH_DRAWER | 1 | 23 | 1 (0)| 00:00:01 |
|* 7 | INDEX RANGE SCAN | PKC_JOURNAL_CASH_D | 1 | | 1 (0)| 00:00:01 |
| 8 | TABLE ACCESS BY INDEX ROWID | DENOMINATION_COUNT | 12 | 384 | 1 (0)| 00:00:01 |
|* 9 | INDEX RANGE SCAN | PKC_DENOMINATION_COUNT | 20 | | 1 (0)| 00:00:01 |
| 10 | NESTED LOOPS OUTER | | 36556 | 3391K| 1442 (1)| 00:00:18 |
| 11 | NESTED LOOPS | | 1817 | 111K| 715 (0)| 00:00:09 |
| 12 | TABLE ACCESS BY INDEX ROWID| JOURNAL_CASH_DRAWER | 1817 | 41791 | 351 (0)| 00:00:05 |
|* 13 | INDEX RANGE SCAN | SPE099_JOURNALCASHDRWR | 1817 | | 7 (0)| 00:00:01 |
|* 14 | TABLE ACCESS BY INDEX ROWID| TRANSACTION_JOURNAL | 1 | 40 | 1 (0)| 00:00:01 |
|* 15 | INDEX UNIQUE SCAN | PKC_TRANSACTION_JOURNAL | 1 | | 1 (0)| 00:00:01 |
| 16 | TABLE ACCESS BY INDEX ROWID | DENOMINATION_COUNT | 20 | 640 | 1 (0)| 00:00:01 |
|* 17 | INDEX RANGE SCAN | PKC_DENOMINATION_COUNT | 20 | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
4 - filter("TPTRJO1"."TOTAL_VALUE"<>0 AND "TPTRJO1"."REVERSED_BY" IS NULL AND
"TPTRJO1"."OFFSET_ID" IS NULL)
5 - access("TPTRJO1"."OTHER_CASH_DRAWER_ID"=5000555)
filter("TPTRJO1"."STATUS"<>U'I' AND "TPTRJO1"."STATUS"<>U'V' AND "TPTRJO1"."STATUS"<>U'R'
AND ("TPTRJO1"."TRANSACTION_ID"=562 OR "TPTRJO1"."TRANSACTION_ID"=563 OR
"TPTRJO1"."TRANSACTION_ID"=589 OR "TPTRJO1"."TRANSACTION_ID"=590 OR
"TPTRJO1"."TRANSACTION_ID"=604 OR "TPTRJO1"."TRANSACTION_ID"=605 OR
"TPTRJO1"."TRANSACTION_ID"=1362))
6 - filter("TPJRCSHDRW1"."DRAWER_SEQ" IS NOT NULL)
7 - access("TPTRJO1"."JOURNAL_ENTRY_ID"="TPJRCSHDRW1"."JOURNAL_ENTRY_ID" AND
"TPJRCSHDRW1"."CASH_DRAWER_DATE">=TO_DATE(' 2009-07-24 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
filter("TPJRCSHDRW1"."CASH_DRAWER_DATE">=TO_DATE(' 2009-07-24 00:00:00', 'syyyy-mm-dd
hh24:mi:ss'))
9 - access("TPDECO1"."JOURNAL_ENTRY_ID"(+)="TPJRCSHDRW1"."JOURNAL_ENTRY_ID")
13 - access("TPJRCSHDRW1"."CASH_DRAWER_ID"=5000555 AND
"TPJRCSHDRW1"."CASH_DRAWER_DATE">=TO_DATE(' 2009-07-24 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
filter("TPJRCSHDRW1"."DRAWER_SEQ" IS NOT NULL)
14 - filter("TPTRJO1"."STATUS"<>U'I' AND "TPTRJO1"."STATUS"<>U'V' AND "TPTRJO1"."STATUS"<>U'R'
AND ("TPTRJO1"."TRANSACTION_ID"=562 OR "TPTRJO1"."TRANSACTION_ID"=563 OR
"TPTRJO1"."TRANSACTION_ID"=589 OR "TPTRJO1"."TRANSACTION_ID"=590 OR
"TPTRJO1"."TRANSACTION_ID"=604 OR "TPTRJO1"."TRANSACTION_ID"=605 OR
"TPTRJO1"."TRANSACTION_ID"=1362) AND "TPTRJO1"."TOTAL_VALUE"<>0 AND "TPTRJO1"."REVERSED_BY" IS
NULL AND "TPTRJO1"."OFFSET_ID" IS NULL AND LNNVL("TPTRJO1"."OTHER_CASH_DRAWER_ID"=5000555))
15 - access("TPTRJO1"."JOURNAL_ENTRY_ID"="TPJRCSHDRW1"."JOURNAL_ENTRY_ID")
17 - access("TPDECO1"."JOURNAL_ENTRY_ID"(+)="TPJRCSHDRW1"."JOURNAL_ENTRY_ID")
--There is an index  SPE099_JOURNALCASHDRWR which is on
CASH_DRAWER_ID
CASH_DRAWER_DATE
DRAWER_SEQ
But I am wondering why there is TABLE ACCESS BY INDEX ROWID| JOURNAL_CASH_DRAWER when this col is availabe in the indexed table .
Can anyone Please suggest what improvements can be done on this query.WIll change in the table order will have some performance boost.
Please suggest ..
Thanks
Prafulla

Could you please execute your query reported here below (pay attention to the gather_plan_statistics hint)
select /*+ gather_plan_statistics */
      case
        when tpjrcshdrw1.cash_drawer_id = 5000555
        then 1
        when tptrjo1.other_cash_drawer_id = 5000555
        then 2
      end trade_type,
      tpdeco1.denomination_count_id,
      tpdeco1.denomination_category,
      tpdeco1.denomination_value,
      tpdeco1.denomination_count,
      tpdeco1.denomination_type,
      tpdeco1.denomination_name,
      tptrjo1.transaction_id,
      tptrjo1.total_value,
      tptrjo1.total_value_ccode,
      tptrjo1.journal_entry_id,
      tpjrcshdrw1.cash_drawer_id,
      tptrjo1.other_cash_drawer_id
from
      transaction_journal tptrjo1
inner join journal_cash_drawer tpjrcshdrw1
        on tptrjo1.journal_entry_id = tpjrcshdrw1.journal_entry_id
left outer join denomination_count tpdeco1
        on tpdeco1.journal_entry_id        = tpjrcshdrw1.journal_entry_id
where ((tpjrcshdrw1.cash_drawer_id = 5000555)
      or (tptrjo1.other_cash_drawer_id   = 5000555))
and (tptrjo1.transaction_id       in (563,590,1362,605,562,589,604))
and (tptrjo1.status not           in ('I','V','R'))
and ((tptrjo1.reversed_by)        is null)
and (tpjrcshdrw1.cash_drawer_date >= to_date('2009-07-24','yyyy-mm-dd') )
and (tptrjo1.total_value 0)
and ((tptrjo1.offset_id) is null);and post the formatted explain plan you will get using
select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));IS one of the following indexed columns NULLABLE?
CASH_DRAWER_ID
CASH_DRAWER_DATE
DRAWER_SEQ
Best Regards
Mohamed Houri
www.hourim.wordpress.com
Edited by: Mohamed Houri on 14-juin-2012 7:07

Similar Messages

  • How to find the query name using infoset name

    Hi Experts
           Iam new to the sap queries(SQ01,SQ02), some queries already created.
          now i want to do some modification, my problem is i am not able to find the query name.
          I know the infoset name, can you tell me how to find the query name using the infoset name, is ther any table for this.
    i tried in sq01 also, but its confusion, pls advice me on this.
    thanks in advance.
    regards
    rajaram

    Hi
    try like this..
    SQ02 --> go to --> Query Directory..
    from there you can get all the queries belong to a Infoset.

  • Error erase Queries in Query Manager- The query is used with user-define...

    Hello Experts
    I have deleted a User Field that had a Formatted Search and now I can not remove it because it is linked according to a UF, the error message is as follows:
    "The query is used with user-defined values [Message 952-23]"
    There will be a way to resolve this issue???
    Thanks in advance

    Hi Juan,
    I have tried this very limited, but the formid, is this a number in your case?
    SELECT * from cshs t0 inner join ouqr t1 on t0.queryid = t1.intrnalkey
    where t1.qname = '[%0]'
    Running this query I can get the form id that I need to recreate, but I have a feeling you already know the form id, is this correct?
    - Is there an error when you try to recreate the form id?
    - Will it not let you recreate the same form id because the id is given by the system?
    If it is not possible to recreate the form id, please prepare a backup and log a message. Support should be able to correct the entry in table cshs.
    Hope it helps.
    Jesper

  • Program name for the query generated using sq0102-03

    Hi Folks,
    How can we know the proggram  name for the query generated using sq01 and all?
    K.Kiran.

    Hi Kiran,
    U can get program name of nay transaction code by following this procedure
    after entering tcode it will direct u to the related screen then on the tool bar select system then go for status there u can find program name
    Rewards if helpfull
    Regards,
    Pavan

  • " The query cannot use the cache

    Hi , I am testing my query on RSRV and also running it using RSRT but neither RSRV is working and RSRV is throwing a error
    " The query cannot use the cache"
    How to resolve ?
    Tried RSRCACHE and everything looks fine there.

    Hi,
    Thanks for your update.
    for this new error try to Generate this query in RSRT.
    GOTO -> RSRT -> GENERATE tab is there.
    Try it and please update me back.
    Thanks & Regards,
    Vipin

  • Tuning the query : Very Urgent

    Hi
    We have query wich needs tuning.when we are putting REGULAR EXPRESSION query is running fine but whne we put like LIKE stmt it is taking time.Here is the query below.Please help on tuning.
    SELECT a.order_number, b.last_update_date,TO_CHAR( b.split_percent,'FM99999.009') SPLIT_PERCENTAGE,
    rs.NAME " SALES_PERSON_NAME ", rs.salesrep_number, b.effective_date,
    b.creation_date "CREATION_DATE", rt.NAME "TERRITORY_NAME",
    rt.segment1 "ERP_CODE", a.booked_date "DATE_BOOKED",
    TO_CHAR(ROUND((( (SELECT SUM (ordered_quantity * unit_selling_price)
    FROM apps.oe_order_lines_all ol
    WHERE ol.header_id = a.header_id)
    * b.split_percent
    / 100
    ) , 2),'FM99999999999999999999.009') order_total ,
    (SELECT user_name
    FROM fnd_user
    WHERE user_id = b.last_updated_by) requested_by,
    b.obsolete_date
    FROM oe_order_headers_all a,
    apps.csm_header_sales_cr_hist b,
    jtf_rs_salesreps rs,
    ra_territories rt
    WHERE 1 = 1
    AND a.header_id = b.source_header_id
    AND b.territory_id = rt.territory_id
    AND b.salesrep_id = rs.salesrep_id
    AND b.source_type = 'O'
    AND a.order_number IN (
    SELECT a.order_number
    FROM oe_order_headers_all a,
    apps.csm_header_sales_cr_hist b,
    jtf_rs_salesreps rs,
    ra_territories rt
    WHERE 1 = 1
    AND a.header_id = b.source_header_id
    AND b.territory_id = rt.territory_id
    AND b.salesrep_id = rs.salesrep_id
    AND b.source_type = 'O'
    -- AND b.obsolete_date IS NULL --ommented by andondap as per TD#9648 Changes
    AND  REGEXP_LIKE ( rs.name , '(svc)|(Muti.*Y)|(Multi.*Y)|(._MY)')  Commented by andondap as per TD#9648 Changes
    AND b.last_update_date BETWEEN TO_DATE ('2012/11/25', 'YYYY/MM/DD') AND TO_DATE ('2013/03/23', 'YYYY/MM/DD')+ 0.9999
    AND REGEXP_LIKE ( rs.name,'(.MY)|(Muti.*Y))|(Multi.*Y)|(._MY) |(mlti)')
    AND rs.name LIKE '%SVC%MULTI%' OR rs.name NOT LIKE '%DUMMY%' OR rs.name LIKE 'Svc%Multi%' OR rs.name LIKE 'Svc%MY%'
    OR rs.name LIKE 'Service%Multi%' OR rs.name LIKE '%MY_SHARE_TM' OR rs.name LIKE '%MY_SHARE_T')
    ORDER BY a.order_number, b.creation_date
    Thanks
    Hibin

    Hmmm, let's see...
    1. OP provided formatted code using {noformat}{noformat} tags.... - FAILED
    2. OP provided database version in full... - FAILED
    3. OP provided table structures and index information... - FAILED
    4. OP provided cardinality and selectivity information... - FAILED
    5. OP provided explain plans... - FAILED
    6. OP provided execution traces... - FAILED
    7. OP is a new member and can be excused for above failures... - FAILED
    8. OP has asked previous questions and followed forum etiquette by marking them as answered... - FAILED
    9. OP has respected volunteers and other questioners by not marking his question as Urgent... - FAILED
    10. OP has read the forum FAQ ({message:id=9360002}) for posting his question...  - FAILED
    11. OP has read the forum FAQ ({message:id=9360003}) for posting a tuning question... - FAILED
    It's a good job you're not a computer program, you wouldn't have even compiled.
    so, points to note:
    This is a forum of volunteers.  There's no such thing as an Urgent question here, and it's considered rude to suggest your question is urgent, as that indicates you want immediate attention from the people who are giving up their own time to help, and who have their own jobs to do.  It's also rude for the other people who are asking questions, as everyone would like an answer to their problem as soon as possible, so what makes you any more special?  An urgent issue is one where a live system is down potentially putting people's lives at risk or causing a company to lose money, or somehow damage their services.  Such issues should be logged with Oracle Support, not on the free OTN forums.
    Next, when you post your question, ensure you provide all the information that is needed for people to be able to help you.  Read the FAQ posts which point to useful threads indicating what information is required, especially for tuning requests.
    Finally, when your questions have been answered, it is common courtesy to mark them as answered (and award points if appropriate), otherwise it indicates that you have no respect for the people who are helping you.
    If you follow all the advice above, you will end up creating a good question that people will be willing to help you with.   If you don't follow the advice above, such as in this question you've posted, you will find that few experts will bother to help (or if they post it will not likely be helpful advise you receive).  The choice is yours.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Please help!!! Tuning the query

    Hi,
    I am using Oracle BDBXML 2.4.16. In the following, policyContainer.dbxml has around 1000 documents and productsContainer.dbxml around 10 documents. The following query is taking around 6 - 8 seconds to fetch the data of around 300 records. I have created node-element-equality-string indexes on PolicyEvent, PolicyStatus, Archived, IsLatest, ProductID and CompanyID.
    I am novice on Query tuning. Can someone please help me to tune the following query. I have posted the query plan as well.
    Thanks in Advance!!
    Balakrishna.
    Query:
    query ' for $policy in collection("policyContainer.dbxml")/Policy[PolicyState/PolicyEvent=("APPLICATION","QUOTE","BINDER","POLICY","ENDORSEMENT QUOTE")]
    [PolicyHeader/ProductID = (for $product in collection("productsContainer.dbxml")/Product/ProductsHeader[CompanyID=(1)] return $product/ProductID)]
    [PolicyState/PolicyStatus !=("RATE","DECLINED ENDORSEMENT QUOTE","DECLINED NON-PRE ENDORSEMENT QUOTE","DECLINED EXTENSION QUOTE")]
    [PolicyState/Archived !="true"]
    [(PolicyState/IsLatest !="false"
    and (PolicyState/PolicyStatus != ("ENDORSEMENT QUOTE","NON-PRE ENDORSEMENT QUOTE","EXTENSION QUOTE")))
    or (PolicyState/IsLatest !="true"
    and (PolicyState/PolicyStatus =("ENDORSEMENT QUOTE","NON-PRE ENDORSEMENT QUOTE","EXTENSION QUOTE")))]
    let $state := $policy/PolicyState 
    let $header := $policy/PolicyHeader
    let $datatable := $policy/DataTable/DataTableInfo
    return
    <policyDetail>
    {$policy/SubmissionNumber},
    {$policy/DocumentNumber},
    {$policy/QuoteVersionNumber},
    {$state/*,$header/*,$datatable/*}
    </policyDetail>'
    Query plan:
    <XQuery>
      <Return>
        <LetTuple uri="" name="datatable">
          <LetTuple uri="" name="header">
            <LetTuple uri="" name="state">
              <ForTuple uri="" name="policy">
                <ContextTuple/>
                <QueryPlanToAST>
                  <BufferQP id="2">
                    <NegativeNodePredicateFilterQP uri="" name="#tmp67">
                      <NegativeNodePredicateFilterQP uri="" name="#tmp73">
                        <NodePredicateFilterQP uri="" name="#tmp404">
                          <ParentOfChildJoinQP>
                            <StepQP axis="parent-of-child" name="PolicyState" nodeType="element">
                              <UnionQP>
                                <ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="PolicyEvent" value="ENDORSEMENT QUOTE"/>
                                <ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="PolicyEvent" value="APPLICATION"/>
                                <ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="PolicyEvent" value="POLICY"/>
                                <ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="PolicyEvent" value="BINDER"/>
                                <ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="PolicyEvent" value="QUOTE"/>
                              </UnionQP>
                            </StepQP>
                            <StepQP axis="child" name="Policy" nodeType="element">
                              <SequentialScanQP container="policyContainer.dbxml" nodeType="document"/>
                            </StepQP>
                          </ParentOfChildJoinQP>
                          <ValueFilterQP comparison="eq" general="true">
                            <StepQP axis="child" name="ProductID" nodeType="element">
                              <StepQP axis="child" name="PolicyHeader" nodeType="element">
                                <VariableQP name="#tmp404"/>
                              </StepQP>
                            </StepQP>
                            <Atomize>
                              <Return>
                                <ForTuple uri="" name="product">
                                  <ContextTuple/>
                                  <QueryPlanToAST>
                                    <ParentOfChildJoinQP>
                                      <ValueFilterQP comparison="eq" general="true">
                                        <PresenceQP container="productsContainer.dbxml" index="node-element-equality-string" operation="prefix" child="CompanyID"/>
                                        <Sequence>
                                          <NumericTypeConstructor value="1.0E0" typeuri="http://www.w3.org/2001/XMLSchema" typename="integer"/>
                                        </Sequence>
                                      </ValueFilterQP>
                                      <StepQP axis="child" name="ProductsHeader" nodeType="element">
                                        <StepQP axis="child" name="Product" nodeType="element">
                                          <SequentialScanQP container="productsContainer.dbxml" nodeType="document"/>
                                        </StepQP>
                                      </StepQP>
                                    </ParentOfChildJoinQP>
                                  </QueryPlanToAST>
                                </ForTuple>
                                <QueryPlanToAST>
                                  <StepQP axis="child" name="ProductID" nodeType="element">
                                    <VariableQP name="product"/>
                                  </StepQP>
                                </QueryPlanToAST>
                              </Return>
                            </Atomize>
                          </ValueFilterQP>
                        </NodePredicateFilterQP>
                        <ValueFilterQP comparison="ne" general="true">
                          <ValueFilterQP comparison="ne" general="true">
                            <ValueFilterQP comparison="ne" general="true">
                              <ValueFilterQP comparison="ne" general="true">
                                <StepQP axis="child" name="PolicyStatus" nodeType="element">
                                  <StepQP axis="child" name="PolicyState" nodeType="element">
                                    <VariableQP name="#tmp73"/>
                                  </StepQP>
                                </StepQP>
                                <Sequence>
                                  <AnyAtomicTypeConstructor value="RATE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                                  <AnyAtomicTypeConstructor value="DECLINED ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                                  <AnyAtomicTypeConstructor value="DECLINED NON-PRE ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                                  <AnyAtomicTypeConstructor value="DECLINED EXTENSION QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                                </Sequence>
                              </ValueFilterQP>
                              <Sequence>
                                <AnyAtomicTypeConstructor value="RATE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                                <AnyAtomicTypeConstructor value="DECLINED ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                                <AnyAtomicTypeConstructor value="DECLINED NON-PRE ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                                <AnyAtomicTypeConstructor value="DECLINED EXTENSION QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                              </Sequence>
                            </ValueFilterQP>
                            <Sequence>
                              <AnyAtomicTypeConstructor value="RATE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                              <AnyAtomicTypeConstructor value="DECLINED ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                              <AnyAtomicTypeConstructor value="DECLINED NON-PRE ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                              <AnyAtomicTypeConstructor value="DECLINED EXTENSION QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                            </Sequence>
                          </ValueFilterQP>
                          <Sequence>
                            <AnyAtomicTypeConstructor value="RATE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                            <AnyAtomicTypeConstructor value="DECLINED ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                            <AnyAtomicTypeConstructor value="DECLINED NON-PRE ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                            <AnyAtomicTypeConstructor value="DECLINED EXTENSION QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                          </Sequence>
                        </ValueFilterQP>
                      </NegativeNodePredicateFilterQP>
                      <ChildJoinQP>
                        <StepQP axis="child" name="PolicyState" nodeType="element">
                          <VariableQP name="#tmp67"/>
                        </StepQP>
                        <ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="Archived" value="true"/>
                      </ChildJoinQP>
                    </NegativeNodePredicateFilterQP>
                    <UnionQP>
                      <NegativeNodePredicateFilterQP uri="" name="#tmp18">
                        <NegativeNodePredicateFilterQP uri="" name="#tmp46">
                          <BufferReferenceQP id="2"/>
                          <ChildJoinQP>
                            <StepQP axis="child" name="PolicyState" nodeType="element">
                              <VariableQP name="#tmp46"/>
                            </StepQP>
                            <ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="IsLatest" value="false"/>
                          </ChildJoinQP>
                        </NegativeNodePredicateFilterQP>
                        <ValueFilterQP comparison="ne" general="true">
                          <ValueFilterQP comparison="ne" general="true">
                            <ValueFilterQP comparison="ne" general="true">
                              <StepQP axis="child" name="PolicyStatus" nodeType="element">
                                <StepQP axis="child" name="PolicyState" nodeType="element">
                                  <VariableQP name="#tmp18"/>
                                </StepQP>
                              </StepQP>
                              <Sequence>
                                <AnyAtomicTypeConstructor value="ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                                <AnyAtomicTypeConstructor value="NON-PRE ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                                <AnyAtomicTypeConstructor value="EXTENSION QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                              </Sequence>
                            </ValueFilterQP>
                            <Sequence>
                              <AnyAtomicTypeConstructor value="ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                              <AnyAtomicTypeConstructor value="NON-PRE ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                              <AnyAtomicTypeConstructor value="EXTENSION QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                            </Sequence>
                          </ValueFilterQP>
                          <Sequence>
                            <AnyAtomicTypeConstructor value="ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                            <AnyAtomicTypeConstructor value="NON-PRE ENDORSEMENT QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                            <AnyAtomicTypeConstructor value="EXTENSION QUOTE" typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
                          </Sequence>
                        </ValueFilterQP>
                      </NegativeNodePredicateFilterQP>
                      <NegativeNodePredicateFilterQP uri="" name="#tmp56">
                        <ParentOfChildJoinQP>
                          <StepQP axis="parent-of-child" name="PolicyState" nodeType="element">
                            <UnionQP>
                              <ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="PolicyStatus" value="NON-PRE ENDORSEMENT QUOTE"/>
                              <ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="PolicyStatus" value="EXTENSION QUOTE"/>
                              <ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="PolicyStatus" value="ENDORSEMENT QUOTE"/>
                            </UnionQP>
                          </StepQP>
                          <BufferReferenceQP id="2"/>
                        </ParentOfChildJoinQP>
                        <ChildJoinQP>
                          <StepQP axis="child" name="PolicyState" nodeType="element">
                            <VariableQP name="#tmp56"/>
                          </StepQP>
                          <ValueQP container="policyContainer.dbxml" index="node-element-equality-string" operation="eq" child="IsLatest" value="true"/>
                        </ChildJoinQP>
                      </NegativeNodePredicateFilterQP>
                    </UnionQP>
                  </BufferQP>
                </QueryPlanToAST>
              </ForTuple>
              <QueryPlanToAST>
                <StepQP axis="child" name="PolicyState" nodeType="element">
                  <VariableQP name="policy"/>
                </StepQP>
              </QueryPlanToAST>
            </LetTuple>
            <QueryPlanToAST>
              <StepQP axis="child" name="PolicyHeader" nodeType="element">
                <VariableQP name="policy"/>
              </StepQP>
            </QueryPlanToAST>
          </LetTuple>
          <QueryPlanToAST>
            <StepQP axis="child" name="DataTableInfo" nodeType="element">
              <StepQP axis="child" name="DataTable" nodeType="element">
                <VariableQP name="policy"/>
              </StepQP>
            </StepQP>
          </QueryPlanToAST>
        </LetTuple>
        <DOMConstructor type="element">
          <Name>
            <Sequence>
              <ATQNameConstructor uri="" prefix="" localname="policyDetail" typeuri="http://www.w3.org/2001/XMLSchema" typename="QName"/>
            </Sequence>
          </Name>
          <Children>
            <ContentSequence>
              <QueryPlanToAST>
                <StepQP axis="child" name="SubmissionNumber" nodeType="element">
                  <VariableQP name="policy"/>
                </StepQP>
              </QueryPlanToAST>
            </ContentSequence>
            <ContentSequence>
              <Sequence>
                <AnyAtomicTypeConstructor value="," typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
              </Sequence>
            </ContentSequence>
            <ContentSequence>
              <QueryPlanToAST>
                <StepQP axis="child" name="DocumentNumber" nodeType="element">
                  <VariableQP name="policy"/>
                </StepQP>
              </QueryPlanToAST>
            </ContentSequence>
            <ContentSequence>
              <Sequence>
                <AnyAtomicTypeConstructor value="," typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
              </Sequence>
            </ContentSequence>
            <ContentSequence>
              <QueryPlanToAST>
                <StepQP axis="child" name="QuoteVersionNumber" nodeType="element">
                  <VariableQP name="policy"/>
                </StepQP>
              </QueryPlanToAST>
            </ContentSequence>
            <ContentSequence>
              <Sequence>
                <AnyAtomicTypeConstructor value="," typeuri="http://www.w3.org/2001/XMLSchema" typename="string"/>
              </Sequence>
            </ContentSequence>
            <ContentSequence>
              <Parenthesized>
                <QueryPlanToAST>
                  <ChildJoinQP>
                    <VariableQP name="state"/>
                    <SequentialScanQP container="policyContainer.dbxml" nodeType="element"/>
                  </ChildJoinQP>
                </QueryPlanToAST>
                <QueryPlanToAST>
                  <StepQP axis="child" uri="*" name="*" nodeType="element">
                    <VariableQP name="header"/>
                  </StepQP>
                </QueryPlanToAST>
                <QueryPlanToAST>
                  <ChildJoinQP>
                    <VariableQP name="datatable"/>
                    <SequentialScanQP container="policyContainer.dbxml" nodeType="element"/>
                  </ChildJoinQP>
                </QueryPlanToAST>
              </Parenthesized>
            </ContentSequence>
          </Children>
        </DOMConstructor>
      </Return>
    </XQuery>

    The good news is that your indexes are being used (anywhere in the query plan where you see index="node-element-equality-string"), the bad news is that the entire policyContainer is being scanned several times (<SequentialScanQP container="policyContainer.dbxml" nodeType="element"/>). Your best bet is to upgrade to dbxml-2.5.16, since that has several improvements to the optimizer that should optimize away those scans. Failing that, use the shell command (dbxml) to add and remove indexes and see how that changes the query plan and speed. The following line is what is causing the scans:
    {$state/*,$header/*,$datatable/*}So add indexes that will help to locate those nodes, or change that line so that the query is faster.
    Lauren Foutz

  • Parameters to be considered for tuning the QUERY Performance.

    Hi Guys
    I wanted to identify the Query which is taking more resources through the Dynamic performance views and not through OEM.I wanter to tune the Query.
    Please suggest me on this. Also i wanted to know what are all the parameters to be considered for tuning a query like Query execution time, I/O Hits, Library cache hits, etc and from which performance view these paramaters can be taken. I also wanted to know how to find the size of library cache and how much queries can be holded in a library cache and what will be the retention of queries in library cache and how to retrive the queries from Library cache.
    Thanks a lot
    Edited by: user448837 on Sep 23, 2008 9:24 PM

    Hmm there is a parameter called makemyquery=super_fast, check that ;-).
    Ok jokes apart, your question is like asking a doctor that when a person is sick than how to troubleshoot his sickeness? So does a doctor start giving medicine immediately? No right? He has to check some symptoms of the patient. The same is applicable to the query also. There is no view as such which would tell you the performance of the query ie it is good or bad. Tell me if a query is taking up 5 minutes and I come and tell you this, what would you say its good or bad or the query took this much CPU time what would you say, its too much or too less? I am sure your answers would be "it depends". That's the key point.
    The supermost point in the performance check is two things, one the plan of the query. What kind of plan optimizer took for the query and whether it was really good or not? There are millions os ways to do som ething but the idea is to do it in the best way. That's what the idea of reading explain plan. I would suggest get your self familiar with explain plan's various paths and their pros and cons. Also about the query's charectristics, you can check V$sql, v$sqlarea , V$sql_text views.
    Your other question that you want to check the size of the library cache , its contents and the retention, I would say that its all internally managed. You never size library cache but shared pool only. Similary the best bet for a dba/developer is to check the queries are mostly shareable and there wont be any duplicate sqls. So the cursor_sharing parameter can be used for this. The control is not given to us to manage the rentention or the flushing of the queries from the cache.
    HTH
    Aman....

  • SQL Query C# Using Execution Plan Cache Without SP

    I have a situation where i am executing an SQL query thru c# code. I cannot use a stored procedure because the database is hosted by another company and i'm not allowed to create any new procedures. If i run my query on the sql mgmt studio the first time
    is approx 3 secs then every query after that is instant. My query is looking for date ranges and accounts. So if i loop thru accounts each one takes approx 3 secs in my code. If i close the program and run it again the accounts that originally took 3 secs
    now are instant in my code. So my conclusion was that it is using an execution plan that is cached. I cannot find how to make the execution plan run on non-stored procedure code. I have created a sqlcommand object with my queary and 3 params. I loop thru each
    one keeping the same command object and only changing the 3 params. It seems that each version with the different params are getting cached in the execution plans so they are now fast for that particular query. My question is how can i get sql to not do this
    by either loading the execution plan or by making sql think that my query is the same execution plan as the previous? I have found multiple questions on this that pertain to stored procedures but nothing i can find with direct text query code.
    Bob;
     

    I did the query running different accounts and different dates with instant results AFTER the very first query that took the expected 3 secs. I changed all 3 fields that i've got code for parameters for and it still remains instant in the mgmt studio but
    still remains slow in my code. I'm providing a sample of the base query i'm using.
    select i.Field1, i.Field2, 
    d.Field3  'Field3',
    ip.Field4 'Field4', 
    k.Field5 'Field5'
    from SampleDataTable1 i, 
    SampleDataTable2 k, 
    SampleDataTable3 ip,
    SampleDataTable4 d 
    where i.Field1 = k.Field1 and i.Field4 = ip.Field4 
    i.FieldDate between '<fromdate>' and  '<thrudate>' 
    and k.Field6 = <Account>
    Obviously the field names have been altered because the database is not mine but other then the actual names it is accurate. It works it just takes too long in code as described in the initial post. 
    My params setup during the init for the connection and the command.
    sqlCmd.Parameters.Add("@FromDate", SqlDbType.DateTime);
            sqlCmd.Parameters.Add("@ThruDate", SqlDbType.DateTime);
            sqlCmd.Parameters.Add("@Account", SqlDbType.Decimal);
    Each loop thru the code changes these 3 fields.
        sqlCommand.Parameters["@FromDate"].Value = dtFrom;
        sqlCommand.Parameters["@ThruDate"].Value = dtThru;
        sqlCommand.Parameters["@Account"].Value = sAccountNumber;
    SqlDataReader reader = sqlCommand.ExecuteReader();
            while (reader.Read())
                reader.Close();
    One thing i have noticed is that the account field is decimal(20,0) and by default the init i'm using defaults to decimal(10) so i'm going to change the init to 
       sqlCmd.Parameters["@Account"].Precision = 20;
       sqlCmd.Parameters["@Account"].Scale = 0;
    I don't believe this would change anything but at this point i'm ready to try anything to get the query running faster. 
    Bob;

  • Tuning the query..

    Hi guys,
    I have written a demand view query which is working perfectly and is giving demand betnwen specified date range. Can you suggest any modification in the query which will tune it to run faster and improve performance:
    --Demand View query
    --Data to use
    --date: give any date range for this month
    SELECT calendar_date,man_days_demand,/*total_fsr_count,*/
    (total_fsr_count - MAN_DAYS_DEMAND) man_days_unstaffed,
    /*FSR_Assigned_Serv_Req , FSR_Assigned_OT_Req ,*/
    (total_fsr_count-(FSR_Assigned_Serv_Req + FSR_Assigned_OT_Req)) Man_days_avail
    FROM (
    SELECT TRUNC(cal.calendar_date) calendar_date,
    (-- in line column qry to count the service reqs falling on that specific day
    SELECT nvl(sum(count(ssrj.assigned_field_service_rep)),0)
    FROM sop_service_request_job ssrj, sop_service_request ssr
    WHERE (((cal.calendar_date between ssrj.scheduled_start_date AND
    get_end_date(ssrj.scheduled_start_date,
    ssrj.expected_service_hours,
    ssrj.weekend)))
    OR
    (cal.calendar_date < ssrj.scheduled_start_date and
    cal.calendar_date > get_end_date(ssrj.scheduled_start_date,
    ssrj.expected_service_hours,
    ssrj.weekend)))
    and ssrj.service_request_id = ssr.service_request_id
    and ssrj.assigned_field_service_rep is not null
    GROUP BY calendar_date
    ) Man_Days_demand,
    SELECT nvl(sum(count(ssrj.assigned_field_service_rep)),0)
    FROM sop_service_request_job ssrj, sop_service_request ssr
    WHERE (((cal.calendar_date between ssrj.scheduled_start_date AND
    get_end_date(ssrj.scheduled_start_date,
    ssrj.expected_service_hours,
    ssrj.weekend)))
    OR
    (cal.calendar_date < ssrj.scheduled_start_date and
    cal.calendar_date > get_end_date(ssrj.scheduled_start_date,
    ssrj.expected_service_hours,
    ssrj.weekend)))
    and ssrj.service_request_id = ssr.service_request_id
    and ssrj.assigned_field_service_rep is not null
    and ssrj.job_status = 'ASSIGNED'
    GROUP BY calendar_date
    ) FSR_Assigned_Serv_Req,
    select nvl(sum(count(fsr_sso_id)),0)
    from sop_other_time_alloc_det sotad
    where ((cal.calendar_date between trunc(sotad.start_date) AND
    trunc(sotad.end_date)) OR
    (cal.calendar_date < trunc(sotad.start_date) AND
    cal.calendar_date > trunc(sotad.end_date)))
    GROUP BY calendar_date
    ) FSR_Assigned_OT_Req,
    select nvl(count(distinct sso_id),0)
    from sop_user_map
    where role_id = 1
    ) total_fsr_count
    FROM sop_fiscal_calendar_v cal, sop_service_user ssu, sop_service_request ssr,
    sop_service_request_job ssrj, CSA_PLATFORM_MASTER cpm
    WHERE
    calendar_date BETWEEN trunc(to_date('&date_range_start_date','mm/dd/yyyy'))
    AND trunc(to_date('&date_range_end_date','mm/dd/yyyy'))
    and ssu.sso_id = ssrj.assigned_field_service_rep
    and ssrj.service_request_id = ssr.service_request_id
    and trim(ssu.sso_id) = trim('&ssoid')
    and upper(ssu.qualification) like upper('%&qualification%')
    and upper(cpm.platform_name) like upper('%&platform_name%')
    and upper(ssu.country) like upper('%&country%')
    and upper(ssr.region_id) like upper('%&region_id')
    and upper(ssrj.weekend) like upper('%&weekend%')
    and upper(ssu.state) like upper('%&state%')
    GROUP BY calendar_date
    ) order by calendar_date
    Thx,,
    JP

    Hello
    To preserve the formatting any text you post you need surround them with the UBB Code tags [pre] and [/pre]. i.e.
    [pre]
    SQL> select * from dual;
    D
    X
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE
       1    0   TABLE ACCESS (FULL) OF 'DUAL'
    Statistics
              0  recursive calls
              4  db block gets
              1  consistent gets
              0  physical reads
              0  redo size
            544  bytes sent via SQL*Net to client
            643  bytes received via SQL*Net from client
              4  SQL*Net roundtrips to/from client
              1  sorts (memory)
              0  sorts (disk)
              1  rows processed
    [/pre]
    HTH
    David

  • Query Performance - Query not using proper plan

    Hello,
    I am experiencing a performance issue with queries that span multiple partitions/tablespaces. Specifically, a query utilizing a stored procedure does not use the indices, rather, full table scans are being done resulting in the query taking 30+ minutes to complete. The same query, when removed from the SP, returns results in milliseconds.
    In an attempt to correct the issue, table stats were updated, the stored procedure was re-compiled as well packages that may have been affected after the table stats update. In addition, the database was bounced (shutdown, restarted) but no noticable performance increase was acheived.
    I'm looking for any insight on how to correct this issue.
    I can provide additional information if required.
    Thanks,
    Scott.

    Post the query, the stored procedure, and the table structure. My first quess here is that the stored procedure is binding an incorrect datatype, but I need to see the requested info to be certain.

  • Help in tuning the Query

    Pls see this attached query. This is hitting a table which has around 110 mil recs. And this takes around 60 min to execute. IS there any way to tune it better? I am assuming that because this uses the ' With tmp as' clauses, it might be using the Indexes.
    Can anyone suggest some tuning tips?
    Satish
    WITH all_edbc_pending_edg
         AS (SELECT
                    a.day_sk,
                    a.case_num,
                    a.edg_num,
                    a.edg_trace_id,
                    a.application_dt, 
                    a.current_elig_ind,
                    a.payment_begin_dt payment_beg_dt
             FROM   fct_eligibility_2 a,
                    dim_edg_activity_type b
             WHERE  a.current_elig_ind IN ('P','S','A')
    and mod(case_num,2)=0
                    AND b.eff_end_dt IS NULL
                    AND b.activity_type_cd IN ('IN','RE','IR','PR','OG')
                    AND a.activity_type_sk=b.activity_type_sk
    , Pick_Latest_Prior_Med as
    SELECT  t3.case_num,
            t3.edg_num,
            t3.current_elig_ind,
            t3.application_dt,
            t3.day_sk,
            t3.payment_beg_dt,
            t3.edg_trace_id
    FROM   (SELECT t2.*,
                   Row_number()
                     OVER(PARTITION BY t2.case_num,t2.edg_num, t2.application_dt ORDER BY t2.day_sk DESC, t2.payment_beg_dt DESC, t2.edg_trace_id DESC) AS rn
            FROM   all_edbc_pending_edg t2) t3
    WHERE  t3.rn = 1
    Select
           case_num,
           edg_num,
           application_dt,
           payment_beg_dt,
           edg_trace_id,
           current_elig_ind
    FROM
            SELECT  t1.case_num,
                   t1.edg_num, 
                   t1.application_dt, 
                   t1.payment_beg_dt,
                   t1.edg_trace_id,
                   t1.current_elig_ind
            FROM   (SELECT  t.*,
                           Row_number()
                             OVER(PARTITION BY t.case_num,t.edg_num ORDER BY t.day_sk DESC, t.payment_beg_dt DESC, t.edg_trace_id DESC) AS rn
                    FROM   Pick_Latest_Prior_Med  t) t1
            WHERE  t1.rn = 1
            ) p
    WHERE
           current_elig_ind IN ('P','S')

    Check this link and post what is required as mentioned in the link.
    SQL and PL/SQL FAQ
    >
    I am assuming that because this uses the ' With tmp as' clauses, it might be using the Indexes.
    >
    You don't need to assume. You can find out what's exactly happening if you follow the steps described in the above mentioned link.
    Regards
    Raj

  • SQL Tuning- slow query on GL_BALANCES- Explain plan provided

    Hi- I really need some help here.
    The following SQL statement has been identified to perform poorly.
    It currently takes from 2-3 minutes to execute. I see it is because GL_BALANCES has so many rows.
    Is there any way around this? Explain and info below. Thanks gurus!
    This is the SQL statement:
    SELECT DISTINCT GLB.CODE_COMBINATION_ID CCID
    FROM gl_balances GLB, gl_code_combinations GCC
    WHERE GLB.ACTUAL_FLAG = 'A'
    AND GLB.Last_Update_Date > to_date('11-JAN-2010','DD-MON-YYYY')
    AND GLB.code_combination_id = GCC.code_combination_id
    AND EXISTS (
                  SELECT 1
                  FROM fnd_flex_value_sets A, fnd_flex_values B
                  WHERE A.flex_value_set_name = 'XXX_XXX'
                  AND UPPER(B.ATTRIBUTE3) = 'APPORTIONMENT'
                  AND A.flex_value_set_id = b.flex_value_set_id
                  AND GCC.segment11 = b.flex_value
               );The version of the database is 11.1.0.7.
    These are the parameters relevant to the optimizer:
    NAME TYPE VALUE
    optimizerautostats_job boolean FALSE
    optimizerextended_cursor_sharing_r string NONE
    el
    optimizer_capture_sql_plan_baselines boolean FALSE
    optimizer_dynamic_sampling integer 2
    optimizer_features_enable string 11.1.0.7
    optimizer_index_caching integer 0
    optimizer_index_cost_adj integer 100
    optimizer_mode string ALL_ROWS
    optimizer_secure_view_merging boolean FALSE
    optimizer_use_invisible_indexes boolean FALSE
    NAME TYPE VALUE
    optimizer_use_pending_statistics boolean FALSE
    optimizer_use_sql_plan_baselines boolean TRUE
    SQL> show parameter db_file_multi
    NAME TYPE VALUE
    db_file_multiblock_read_count integer 128
    SQL> show parameter db_block_size
    NAME TYPE VALUE
    db_block_size integer 8192
    SQL> show parameter cursor_sharing
    NAME TYPE VALUE
    optimizerextended_cursor_sharing_r string NONE
    el
    cursor_sharing string EXACT
    select
    2 sname
    3 , pname
    4 , pval1
    5 , pval2
    6 from
    7 sys.aux_stats$;
    SNAME PNAME PVAL1
    PVAL2
    SYSSTATS_INFO STATUS
    COMPLETED
    SYSSTATS_INFO DSTART
    09-02-2006 14:35
    SYSSTATS_INFO DSTOP
    09-02-2006 14:35
    SNAME PNAME PVAL1
    PVAL2
    SYSSTATS_INFO FLAGS 1
    SYSSTATS_MAIN CPUSPEEDNW 451.262136
    SYSSTATS_MAIN IOSEEKTIM 10
    SNAME PNAME PVAL1
    PVAL2
    SYSSTATS_MAIN IOTFRSPEED 4096
    SYSSTATS_MAIN SREADTIM
    SYSSTATS_MAIN MREADTIM
    SNAME PNAME PVAL1
    PVAL2
    SYSSTATS_MAIN CPUSPEED
    SYSSTATS_MAIN MBRC
    SYSSTATS_MAIN MAXTHR
    SNAME PNAME PVAL1
    PVAL2
    SYSSTATS_MAIN SLAVETHR
    13 rows selected.
    SQL> explain plan for
    2 SELECT DISTINCT GLB.CODE_COMBINATION_ID CCID
    3 FROM gl_balances GLB, gl_code_combinations GCC
    4 WHERE GLB.code_combination_id = GCC.code_combination_id
    5 AND GLB.ACTUAL_FLAG = 'A'
    6 AND GLB.Last_Update_Date > '11-JAN-2010'
    7 AND EXISTS (SELECT 1
    8 FROM fnd_flex_value_sets A, fnd_flex_values B
    9 WHERE A.flex_value_set_id = b.flex_value_set_id
    10 AND A.flex_value_set_name = 'XXX_XXX'
    11 AND UPPER(B.ATTRIBUTE3) = 'APPORTIONMENT'
    12 AND GCC.segment11 = b.flex_value);
    Explained.
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 1839014065
    | Id | Operation | Name | Rows | By
    tes | Cost (%CPU)| Time |
    PLAN_TABLE_OUTPUT
    | 0 | SELECT STATEMENT | | 4102 |
    296K| 955K (3)| 03:11:03 |
    | 1 | HASH UNIQUE | | 4102 |
    296K| 955K (3)| 03:11:03 |
    |* 2 | HASH JOIN | | 4102 |
    296K| 955K (3)| 03:11:03 |
    | 3 | NESTED LOOPS | | |
    | | |
    PLAN_TABLE_OUTPUT
    | 4 | NESTED LOOPS | | 23907 | 1
    354K| 2598 (1)| 00:00:32 |
    | 5 | NESTED LOOPS | | 1 |
    45 | 5 (0)| 00:00:01 |
    | 6 | TABLE ACCESS BY INDEX ROWID| FND_FLEX_VALUE_SETS | 1 |
    28 | 2 (0)| 00:00:01 |
    |* 7 | INDEX UNIQUE SCAN | FND_FLEX_VALUE_SETS_U2 | 1 |
    PLAN_TABLE_OUTPUT
    | 1 (0)| 00:00:01 |
    |* 8 | TABLE ACCESS BY INDEX ROWID| FND_FLEX_VALUES | 1 |
    17 | 3 (0)| 00:00:01 |
    |* 9 | INDEX RANGE SCAN | FND_FLEX_VALUES_N2 | 53 |
    | 1 (0)| 00:00:01 |
    |* 10 | INDEX RANGE SCAN | GL_CODE_COMBINATIONS_N11 | 25427 |
    | 106 (1)| 00:00:02 |
    PLAN_TABLE_OUTPUT
    | 11 | TABLE ACCESS BY INDEX ROWID | GL_CODE_COMBINATIONS | 18664 |
    236K| 2593 (1)| 00:00:32 |
    |* 12 | TABLE ACCESS FULL | GL_BALANCES | 1022K|
    15M| 952K (3)| 03:10:32 |
    Predicate Information (identified by operation id):
    PLAN_TABLE_OUTPUT
    2 - access("GLB"."CODE_COMBINATION_ID"="GCC"."CODE_COMBINATION_ID")
    7 - access("A"."FLEX_VALUE_SET_NAME"='SSA_SGL')
    8 - filter(UPPER("B"."ATTRIBUTE3")='APPORTIONMENT')
    9 - access("A"."FLEX_VALUE_SET_ID"="B"."FLEX_VALUE_SET_ID")
    10 - access("GCC"."SEGMENT11"="B"."FLEX_VALUE")
    12 - filter("GLB"."LAST_UPDATE_DATE">TO_DATE(' 2010-01-11 00:00:00', 'syyyy-mm
    -dd hh24:mi:ss') AND
    "GLB"."ACTUAL_FLAG"='A')
    30 rows selected.

    As per the other replies, you've not really given enough information to go on - what are you trying to achieve, versions, etc.
    On my old apps 11.5.8 system, the explain plan for your query uses GL_CODE_COMBINATIONS_U1 rather than a full scan of gl_code_combinations.
    Check your stats are up to date (select table_name, num_rows, last_analyzed from dba_tables where ...)
    See if you can also use period_name and/or period_set_name (or period_num) from GL_Periods rather than period_year (i.e. use P_YEAR to lookup the period_name/period_set_name/period_num from gl_periods). It might be faster to do per period and then consolidate for the whole year, as there are indexes on gl_balances for columns period_name, period_set_name, period_num.
    regards, Ivan

  • Fine tunning the query which uses /*+ USE_CONCAT */ table hint

    Some of the queries in our application uses the /*+ USE_CONCAT */ table hint which takes huge time for the execution in Oracle database.when we fire the below query in 250Million production database it takes approx.3min for the execution.
    Because of this we are facing a performance issue in the application.
    Below is the sample query :
    SELECT /*+ USE_CONCAT */ * FROM DI_MATCH_KEY WHERE NORM_COUNTRY_CD = 'US'
    AND ((( NORM_CONAME_KEY1 ='WILM I' OR NORM_CONAME_KEY2 = 'WILM I' OR NORM_CONAME_KEY23 = 'WILM I'
    OR NORM_CONAME_KEYFIRST ='WILLIAM' ) AND NORM_STATE_PROVINCE = 'CA' ) OR NORM_ADDR_KEY2 = 'CALMN 12 3 OSAI')
    Regarding the indexes almost for all the columns combination for the above sql index already created in table.
    Your suggestions will be appreciated
    Thanks,
    Regards,
    Krishna kumar

    Hi,
    Thanks for our valuable inputs.
    As suggested find attached explain plan and trace file details in the excel sheet.
    TRACE FILE:
    <pre>
    TKPROF: Release 10.2.0.1.0 - Production on Thu Feb 14 11:11:59 2008
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Trace file: implhr01_ora_26457.trc
    Sort options: prsela exeela fchela
    count = number of times OCI procedure was executed
    cpu = cpu time in seconds executing
    elapsed = elapsed time in seconds executing
    disk = number of physical reads of buffers from disk
    query = number of buffers gotten for consistent read
    current = number of buffers gotten in current mode (usually for update)
    rows = number of rows processed by the fetch or execute call
    SELECT /*+ USE_CONCAT */ COUNT(*) FROM DI_MATCH_KEY WHERE NORM_COUNTRY_CD = 'US'
    AND ((( NORM_CONAME_KEY1 ='WILM I' OR NORM_CONAME_KEY2 = 'WILM I' OR NORM_CONAME_KEY23 = 'WILM I'
    OR NORM_CONAME_KEYFIRST ='WILLIAM' ) AND NORM_STATE_PROVINCE = 'CA' ) OR NORM_ADDR_KEY2 = 'CALMN 12 3 OSAI')
    call count cpu elapsed disk query current rows
    Parse 1 0.03 0.05 0 0 0 0
    Execute 1 0.00 0.00 0 0 0 0
    Fetch 2 3.97 65.43 30633 64053 0 1
    total 4 4.00 65.49 30633 64053 0 1
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 76
    Rows Row Source Operation
    1 SORT AGGREGATE (cr=64053 pr=30633 pw=0 time=65436584 us)
    73914 CONCATENATION (cr=64053 pr=30633 pw=0 time=61623673 us)
    0 TABLE ACCESS BY INDEX ROWID DI_MATCH_KEY (cr=4 pr=2 pw=0 time=32617 us)
    0 INDEX RANGE SCAN MKADDR_KEY2 (cr=4 pr=2 pw=0 time=32599 us)(object id 122583)
    75 TABLE ACCESS BY INDEX ROWID DI_MATCH_KEY (cr=80 pr=20 pw=0 time=1369427 us)
    75 INDEX RANGE SCAN MK_CY_KEY1_ST_PROV (cr=5 pr=0 pw=0 time=2119 us)(object id 122666)
    2 TABLE ACCESS BY INDEX ROWID DI_MATCH_KEY (cr=81 pr=2 pw=0 time=26723 us)
    77 INDEX RANGE SCAN MK_CY_KEY2_ST_PROV (cr=4 pr=0 pw=0 time=3641 us)(object id 122667)
    2 TABLE ACCESS BY INDEX ROWID DI_MATCH_KEY (cr=6 pr=0 pw=0 time=47 us)
    2 INDEX RANGE SCAN MK_CY_KEY1_AGN (cr=4 pr=0 pw=0 time=28 us)(object id 122670)
    73835 TABLE ACCESS BY INDEX ROWID DI_MATCH_KEY (cr=63882 pr=30609 pw=0 time=61503773 us)
    73905 INDEX RANGE SCAN MK_CY_KEY2_AGN (cr=266 pr=176 pw=0 time=148198 us)(object id 122745)
    alter session set sql_trace true
    call count cpu elapsed disk query current rows
    Parse 0 0.00 0.00 0 0 0 0
    Execute 1 0.00 0.00 0 0 0 0
    Fetch 0 0.00 0.00 0 0 0 0
    total 1 0.00 0.00 0 0 0 0
    Misses in library cache during parse: 0
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 76
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call count cpu elapsed disk query current rows
    Parse 1 0.03 0.05 0 0 0 0
    Execute 2 0.00 0.00 0 0 0 0
    Fetch 2 3.97 65.43 30633 64053 0 1
    total 5 4.00 65.50 30633 64053 0 1
    Misses in library cache during parse: 1
    Misses in library cache during execute: 1
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    call count cpu elapsed disk query current rows
    Parse 9 0.05 0.03 0 0 0 0
    Execute 23 0.05 0.08 0 0 0 0
    Fetch 98 0.01 0.01 0 137 0 76
    total 130 0.11 0.13 0 137 0 76
    Misses in library cache during parse: 9
    Misses in library cache during execute: 9
    2 user SQL statements in session.
    23 internal SQL statements in session.
    25 SQL statements in session.
    Trace file: implhr01_ora_26457.trc
    Trace file compatibility: 10.01.00
    Sort options: prsela exeela fchela
    1 session in tracefile.
    2 user SQL statements in trace file.
    23 internal SQL statements in trace file.
    25 SQL statements in trace file.
    11 unique SQL statements in trace file.
    561 lines in trace file.
    91 elapsed seconds in trace file.
    </pre>
    EXPLAIN PLAN:
    <pre>
    ID     OPERATION     OBJECT_NAME     CARDINALITY     BYTES     COST     CPU_COST
    0     SELECT STATEMENT          1     53     1886     15753172
    1     SORT          1     53          
    2     CONCATENATION                         
    3     TABLE ACCESS     DI_MATCH_KEY     8     424     10     78334
    4     INDEX     MKADDR_KEY2     8          4     30086
    5     TABLE ACCESS     DI_MATCH_KEY     3     159     7     53574
    6     INDEX     MK_CY_KEY1_ST_PROV     3          4     29286
    7     TABLE ACCESS     DI_MATCH_KEY     3     159     7     53740
    8     INDEX     MK_CY_KEY2_ST_PROV     3          4     29286
    9     TABLE ACCESS     DI_MATCH_KEY     5     265     7     55941
    10     INDEX     MK_CY_KEY1_AGN     5          4     29686
    11     TABLE ACCESS     DI_MATCH_KEY     2192     116176     1855     15511582
    12     INDEX     MK_CY_KEY2_AGN     2228          12     524136
    </pre>
    Kindly help us regarding this.
    Thanks,
    Krishna Kumar.

  • Help tuning the query on NAST table .

    I have the below query on NAST table which is performin very badly:
    SELECT objky INTO TABLE i_objky
         FROM nast
         WHERE kappl = c_kappl            
         AND   ( ( kschl = c_kschl_zbax ) 
               OR ( kschl = c_kschl_zoem ) )
         AND   vstat = c_vstat_comp       
         AND   objtype = c_likp
          AND ( ( datvr EQ w_start_date AND
                  uhrvr GE w_start_time ) OR
                ( datvr EQ w_end_date AND
                  uhrvr LE w_end_time ) OR
                ( datvr GT w_start_date AND
                  datvr LT w_end_date ) ).
    Further there is already an index on KAPPL and KSCHL.
    Message was edited by:
            Ashish kumar

    If I understood your logic correctly - you are trying to select objects which have outputs processed within your date/time interval.
    You can try to rewrite your select to force index 'A' usage as suggested by Christian, but it is not very helpful if you have too many records in NAST as in this case this index is not very selective and optimizer usually ignores it. Of course, you can ask your BASIS folks to tell you if you can use 'hint' addition in your select to force index usage as it depends on DB and some DBs require some work to be done on DB level to enable hints.
    Other options could be
    - try to provide a range (even if it is wide enough) for object key... it may really help as NAST contains too many records for different objects and this range may help with primary key usage.
    - OR if you are interested in these 2 output types only - you can increase the speed of your select significally if you define a separate database table which you will update with these outputs (when they are just created in NAST) and your program (if it usually runs just once per your date.time range) will check the status of these outputs and then delete records from your table or just update them with "processed" status.
    You can actually just create a copy of NAST table which is going to be updated when these outputs are processed (from corresponding processing program), so you will have records there with at least date, and then based on these records you can select actual date/time from NAST. It will be much faster... but it requires more design/coding.

Maybe you are looking for

  • How can I get photos from my iPhone?

    Hi, I used to sync photos to my iPhone from my old pc. Now I am using a new PC and try to get all the photos on my iPhone. I tried to use Adobe Photoshop Album, but it doesn't work. It simply can't find the photos that synced from my old pc, except t

  • Is there no professional DVD program running on Mavericks?

    DVD studio Pro and Adobe Encore is not working on Mavericks. You can't no longer install a Power PC program on Mavericks, therefor DVD studio Pro is out. Right now you cant do a professional DVD with a Mac running on Mavericks? Why have Apple stopped

  • Table declaration in Standard Program

    Hi to all, I just want to know that I have seen in the standard program the declaration of table in the following way. TABLES: bkdf,         bkpf,         *bkpf. then what is this *bkpf means. Thanks Dharmishta

  • Mx.automation.* where is it?

    I wonder why this package is not within th Flex SDK beta 3 release? The compiler produces many quirky errors cause it is not available.

  • I can't see the photo tab when trying to sync my iphone from itunes

    For some reason, all the tabs are not showing on itunes when trying to sync my iphone. The 'photos' tab in particular is missing. It shows I can scroll to the right to possibly see the rest of the tabs, but when I scroll across to the right, it moves