Hpw to tune the performance of following query?

Hi all,
           I want a particular set of G/L acct nos for the list of billing documents that i have in an internal table ie. pt_vbrk. I am using table BSIS.However ,when i use the following query it is taking  very very long time .I even tried using LOOP...ENDLOOP statement.Can anyone tell me how to enhance the performance of the query?Thanks in advance.
i = 0.
loop at pt_vbrk.
i = i + 1.
endloop.
while j <= i.
read table pt_vbrk index j.
select single hkont  from bsis into  corresponding fields of
pt_vbrk where
( hkont = '0013100000' or hkont = '0013105000'
or hkont = '0013110000' or hkont = '0013112000'
or hkont = '0013115000' or hkont = '0013120000'
or hkont = '0013125000' or hkont = '0013135500'
or hkont = '0013140000' or hkont = '0013145000'
or hkont = '0013155000' or hkont = '0013165000'
or hkont = '0013175000' or hkont = '0013170000' )
and belnr = pt_vbrk-belnr and  gjahr = pt_vbrk-gjahr   . "#EC CI_NOFIRST
modify pt_vbrk from pt_vbrk index j.
j = j + 1.
endwhile.
Moderator message - Moved to the correct forum
Edited by: Rob Burbank on Sep 22, 2009 9:06 AM

Try the following approach.
TYPES: BEGIN OF ty_bsis,
         bukrs TYPE bsis-bukrs,
         hkont TYPE bsis-hkont,
         augdt TYPE bsis-augdt,
         augbl TYPE bsis-augbl,
         zuonr TYPE bsis-zuonr,
         gjahr TYPE bsis-gjahr,
         belnr TYPE bsis-belnr,
         buzei TYPE bsis-buzei,
       END OF ty_bsis.
DATA: w_bsis     TYPE                 ty_bsis ,
      w_index    TYPE                 sy-tabix,
      t_bsis     TYPE SORTED TABLE OF ty_bsis
        WITH NON-UNIQUE KEY bukrs belnr gjahr ,
      t_vbrk_tmp LIKE        TABLE OF pt_vbrk .
RANGES: r_hkont FOR bsis-hkont.
IF NOT pt_vbrk[] IS INITIAL.
  REFRESH r_hkont.
  r_hkont-sign   = 'I'.
  r_hkont-option = 'EQ'.
  r_hkont-low = '0013100000'.
  APPEND r_hkont.
  r_hkont-low = '0013105000'.
  APPEND r_hkont.
  r_hkont-low = '0013110000'.
  APPEND r_hkont.
  r_hkont-low = '0013112000'.
  APPEND r_hkont.
  r_hkont-low = '0013115000'.
  APPEND r_hkont.
  r_hkont-low = '0013120000'.
  APPEND r_hkont.
  r_hkont-low = '0013125000'.
  APPEND r_hkont.
  r_hkont-low = '0013135500'.
  APPEND r_hkont.
  r_hkont-low = '0013140000'.
  APPEND r_hkont.
  r_hkont-low = '0013145000'.
  APPEND r_hkont.
  r_hkont-low = '0013155000'.
  APPEND r_hkont.
  r_hkont-low = '0013165000'.
  APPEND r_hkont.
  r_hkont-low = '0013175000'.
  APPEND r_hkont.
  r_hkont-low = '0013170000'.
  APPEND r_hkont.
  t_vbrk_tmp[] = pt_vbrk[].
  SORT t_vbrk_tmp BY bukrs gjahr belnr.
  DELETE ADJACENT DUPLICATES FROM t_vbrk_tmp
    COMPARING bukrs gjahr belnr.
  SELECT bukrs
         hkont
         augdt
         augbl
         zuonr
         gjahr
         belnr
         buzei
    FROM bsis
    INTO TABLE t_bsis
    FOR ALL ENTRIES IN t_vbrk_tmp
    WHERE bukrs EQ t_vbrk_tmp-bukrs
    AND   hkont IN r_hkont
    AND   gjahr EQ t_vbrk_tmp-gjahr
    AND   belnr EQ t_vbrk_tmp-belnr.
  IF sy-subrc EQ 0.
    LOOP AT pt_vbrk.
      w_index = sy-tabix.
      READ TABLE t_bsis INTO w_bsis
        WITH KEY bukrs = pt_vbrk-bukrs
                 belnr = pt_vbrk-belnr
                 gjahr = pt_vbrk-gjahr
                 TRANSPORTING
                   hkont.
      IF sy-subrc EQ 0.
        pt_vbrk-hkont = w_bsis-hkont.
        MODIFY pt_vbrk INDEX w_index
          TRANSPORTING
            hkont.
      ENDIF.
    ENDIF.
  ENDIF.

Similar Messages

  • Imporving the performance of a query

    Hi,
    I have the following query in Oracle:
    SELECT distinct VECTOR_ID FROM SUMMARY_VECTOR where CASE_NAME like 'BASECASE_112_ECLIPSE100'
    "SUMMARY_VECTOR" contains approximately 120 million records or tuples. So the total time for this query is about 62 seconds
    I want to improve the performance of this query. How can I achieve this ?
    any hint ?
    Thanks

    PLAN_TABLE_OUTPUT
    Plan hash value: 3042243244
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time
    |
    PLAN_TABLE_OUTPUT
    | 0 | SELECT STATEMENT | | 1 | 29 | 182K (3)| 00:36
    :28 |
    | 1 | SORT AGGREGATE | | 1 | 29 | |
    |
    |* 2 | TABLE ACCESS FULL| SUMMARY_VECTOR | 4323K| 119M| 182K (3)| 00:36
    :28 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
    2 - filter("CASE_NAME"='BASECASE_112_ECLIPSE100')
    14 rows selected.

  • How can I fine tune the performance of my IMS5.1 mailserver?

    I installed the IMS5.1 on Solaris 8 with default parameters, without IDA. It is used as a mail relay. It seems to have/keep about 700 msgs in the tcp_local channel but none in the process channel. It uses the cpu very much, in my opinion too much (100% is no exception. It uses the swap file for only 30%. How can I tune the performance of my system. Don't laugh: the "server" is only a SUN Ultra 5 workstation.

    I've been working with this MTA since '95. Unfortunately there is no easy answer. The number of msgs in queue is not an indication of performance, it can be, but it can also be that the hosts your system is trying to reach are not available. You can use tools like imsimta qtop to see top subjects or top domains. Poke around and see just why you have 700 msgs in your queues.
    Channels like process or say conversion channel are internal while channnels like tcp_local deal with external systems. If you had mail backing up in the conversion channel then you'd have a good sign of local performance problems. Mail backing up in tcp_local is not necessarily a sign of performance problems on your end.
    I don't see a problem with the software using all available CPU. What is wrong with that?
    If you've made any changes to the configuration it could be that you have introduced something that is causing say a mapping process to loop and thus eat more CPU that would otherwise be normal.
    What process is using all of this CPU? Knowing this would help to determine what part of the MTA might be using lots of CPU.

  • Need help in optimising the performance of a query

    Need help in optimising the performance of a query. Below is the query that is executed on TABLE_A, TABLE_B and TABLE_C with record counts as 10M, 10m and 42 (only) respectively and it takes around 5-7 minutes to get 40 records:
    SELECT DISTINCT a.T_ID_, a.FIRSTNAME, b.T_CODE, b.PRODUCT,
    CASE WHEN TRUNC(b.DATE) +90 = TRUNC(SYSDATE) THEN -90 WHEN TRUNC(b.DATE) +30 = TRUNC(SYSDATE) THEN -30 ELSE 0 END AS T_DATE FROM TABLE_B b
    INNER JOIN TABLE_A a ON (a.T_ID_ = b.T_ID_) LEFT JOIN TABLE_C c ON b.PRODUCT = c.PRODUCT
    WHERE b.STATUS = 'T' AND (b.TYPE = 'ACTION'
    AND ( TRUNC(b.DATE) + 1 = TRUNC(SYSDATE) ) ) AND b.PRODUCT = 2;
    Note: Indices on the join columns are available in the respective tables
    Please let me know if there is any better way to write it.
    Edited by: 862944 on Aug 18, 2011 9:52 AM

    862944 wrote:
    Need help in optimising the performance of a query. Below is the query that is executed on TABLE_A, TABLE_B and TABLE_C with record counts as 10M, 10m and 42 (only) respectively and it takes around 5-7 minutes to get 40 records:
    SELECT DISTINCT a.T_ID_, a.FIRSTNAME, b.T_CODE, b.PRODUCT,
    CASE WHEN TRUNC(b.DATE) +90 = TRUNC(SYSDATE) THEN -90 WHEN TRUNC(b.DATE) +30 = TRUNC(SYSDATE) THEN -30 ELSE 0 END AS T_DATE FROM TABLE_B b
    INNER JOIN TABLE_A a ON (a.T_ID_ = b.T_ID_) LEFT JOIN TABLE_C c ON b.PRODUCT = c.PRODUCT
    WHERE b.STATUS = 'T' AND (b.TYPE = 'ACTION'
    AND ( TRUNC(b.DATE) + 1 = TRUNC(SYSDATE) ) ) AND b.PRODUCT = 2;
    Note: Indices on the join columns are available in the respective tables
    Please let me know if there is any better way to write it.
    Edited by: 862944 on Aug 18, 2011 9:52 AM[When Your Query Takes Too Long|https://forums.oracle.com/forums/thread.jspa?messageID=1812597]

  • HI All, How to improve the performance in given query?

    HI All,
    How to improve the performance in given query?
    Query is..
    PARAMETERS : p_vbeln type lips-vbeln.
    DATA : par_charg TYPE LIPS-CHARG,
    par_werks TYPE LIPS-WERKS,
    PAR_MBLNR TYPE MSEG-MBLNR .
    SELECT SINGLE charg
    werks
    INTO (par_charg, par_werks)
    FROM lips
    WHERE vbeln = p_vbeln.
    IF par_charg IS NOT INITIAL.
    SELECT single max( mblnr )
    INTO par_mblnr
    FROM mseg
    WHERE bwart EQ '101'
    AND werks EQ par_werks (index on werks only)
    AND charg EQ par_charg.
    ENDIF.
    Regards
    Steve

    Hi steve,
    Can't you use the material in your query (and not only the batch)?
    I am assuming your system has an index MSEG~M by MANDT + MATNR + WERKS (+ other fields). Depending on your system (how many different materials you have), this will probably speed up the query considerably.
    Anyway, in our system we ended up by creating an index by CHARG, but leave as a last option, only if selecting by matnr and werks is not good enough for your scenario.
    Hope this helps,
    Rui Dantas

  • Please help me how to improve the performance of this query further.

    Hi All,
    Please help me how to improve the performance of this query further.
    Thanks.

    Hi,
    this is not your first SQL tuning request in this community -- you really should learn how to obtain performance diagnostics.
    The information you posted is not nearly enough to even start troubleshooting the query -- you haven't specified elapsed time, I/O, or the actual number of rows the query returns.
    The only piece of information we have is saying that your query executes within a second. If we believe this, then your query doesn't need tuning. If we don't, then we throw it away
    and we're left with nothing.
    Start by reading this blog post: Kyle Hailey &amp;raquo; Power of DISPLAY_CURSOR
    and applying this knowledge to your case.
    Best regards,
      Nikolay

  • Ways to improve the performance of my query?

    Hi all,
    I have created a multi provider which enables to fetch the data from 3 ods. And each ods contains huge amount of data. As a result my query performance is very slow..
    apart from creating indexes on ods? is there any other to be carried out to improve the performance of my query. Since all the 3 info providers are ods.
    thanxs
    haritha

    Haritha,
    If you still need more info, just have a look below:
    There are few ways your queries can be improved:
    1. Your Data volume in your InfoProviders.
    2. Dim table, how you have manage your objects into your dim table.
    3. Query that runs from multiprovider vs cube itself. when running from multiproviders at the time of execution the system has to create more tables hence the query performance will be affected.
    4. Aggregates into the cube, and they perfection of designing the aggregates.
    5. OLAPCHACHE
    6. Calculation formula
    etc.
    and also you can go thru the links below:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/cccad390-0201-0010-5093-fd9ec8157802
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/ce7fb368-0601-0010-64ba-fadc985a1f94
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c8c4d794-0501-0010-a693-918a17e663cc
    Hope this helps you.
    ****Assign Points*******
    Gattu

  • How to measure the performance of sql query?

    Hi Experts,
    How to measure the performance, efficiency and cpu cost of a sql query?
    What are all the measures available for an sql query?
    How to identify i am writing optimal query?
    I am using Oracle 9i...
    It ll be useful for me to write efficient query....
    Thanks & Regards

    psram wrote:
    Hi Experts,
    How to measure the performance, efficiency and cpu cost of a sql query?
    What are all the measures available for an sql query?
    How to identify i am writing optimal query?
    I am using Oracle 9i... You might want to start with a feature of SQL*Plus: The AUTOTRACE (TRACEONLY) option which executes your statement, fetches all records (if there is something to fetch) and shows you some basic statistics information, which include the number of logical I/Os performed, number of sorts etc.
    This gives you an indication of the effectiveness of your statement, so that can check how many logical I/Os (and physical reads) had to be performed.
    Note however that there are more things to consider, as you've already mentioned: The CPU bit is not included in these statistics, and the work performed by SQL workareas (e.g. by hash joins) is also credited only very limited (number of sorts), but e.g. it doesn't cover any writes to temporary segments due to sort or hash operations spilling to disk etc.
    You can use the following approach to get a deeper understanding of the operations performed by each row source:
    alter session set statistics_level=all;
    alter session set timed_statistics = true;
    select /* findme */ ... <your query here>
    SELECT
             SUBSTR(LPAD(' ',DEPTH - 1)||OPERATION||' '||OBJECT_NAME,1,40) OPERATION,
             OBJECT_NAME,
             CARDINALITY,
             LAST_OUTPUT_ROWS,
             LAST_CR_BUFFER_GETS,
             LAST_DISK_READS,
             LAST_DISK_WRITES,
    FROM     V$SQL_PLAN_STATISTICS_ALL P,
             (SELECT *
              FROM   (SELECT   *
                      FROM     V$SQL
                      WHERE    SQL_TEXT LIKE '%findme%'
                               AND SQL_TEXT NOT LIKE '%V$SQL%'
                               AND PARSING_USER_ID = SYS_CONTEXT('USERENV','CURRENT_USERID')
                      ORDER BY LAST_LOAD_TIME DESC)
              WHERE  ROWNUM < 2) S
    WHERE    S.HASH_VALUE = P.HASH_VALUE
             AND S.CHILD_NUMBER = P.CHILD_NUMBER
    ORDER BY ID
    /Check the V$SQL_PLAN_STATISTICS_ALL view for more statistics available. In 10g there is a convenient function DBMS_XPLAN.DISPLAY_CURSOR which can show this information with a single call, but in 9i you need to do it yourself.
    Note that "statistics_level=all" adds a significant overhead to the processing, so use with care and only when required:
    http://jonathanlewis.wordpress.com/2007/11/25/gather_plan_statistics/
    http://jonathanlewis.wordpress.com/2007/04/26/heisenberg/
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • How to tune the performance of Oracle SQL/XML query?

    Hi all,
    I am running Oracle 9i and like to run the following Oracle SQL/XML query. It takes about 3+ hour and still not finish. If I get rid all the XML stuffs it only take minutes to run. Does anybody know how to what's the reason of this slow and how to tune it?
    SELECT XMLElement("CUSTOMER",
    XMLForest(C_CUSTKEY "C_CUSTKEY", C_NAME "C_NAME", C_ADDRESS "C_ADDRESS", C_PHONE "C_PHONE", C_MKTSEGMENT "C_MKTSEGMENT", C_COMMENT "C_COMMENT"),
    (SELECT XMLAgg(XMLElement("ORDERS",
    XMLForest(O_ORDERKEY "O_ORDERKEY", O_CUSTKEY "O_CUSTKEY", O_ORDERSTATUS "O_ORDERSTATUS", O_ORDERPRIORITY "O_ORDERPRIORITY", O_CLERK "O_CLERK", O_COMMENT "O_COMMENT"),
    (SELECT XMLAgg(XMLElement("LINEITEM",
    XMLForest(L_ORDERKEY "L_ORDERKEY", L_RETURNFLAG "L_RETURNFLAG", L_LINESTATUS "L_LINESTATUS", L_SHIPINSTRUCT "L_SHIPINSTRUCT", L_SHIPMODE "L_SHIPMODE", L_COMMENT "L_COMMENT")
    FROM LINEITEM
    WHERE LINEITEM.L_ORDERKEY = ORDERS.O_ORDERKEY)
    FROM ORDERS
    WHERE ORDERS.O_CUSTKEY = CUSTOMER.C_CUSTKEY)
    FROM CUSTOMER ;
    Thanks very much in advance for your time,
    Jinghao Liu

    ajallen wrote:
    Why not something more like
    SELECT *
    FROM fact1 l,
    FULL OUTER JOIN fact1 d
    ON l.company = d.company
    AND l.transactiontypeid = 1
    AND d.transactiontypeid = 2;
    Because this is not an equivalent of the original query.
    drop table t1 cascade constraints purge;
    drop table t2 cascade constraints purge;
    create table t1 as select rownum t1_id from dual connect by level <= 5;
    create table t2 as select rownum+2 t2_id from dual connect by level <= 5;
    select * from (select * from t1 where t1_id > 2) t1 full outer join t2 on (t1_id = t2_id);
    select * from t1 full outer join t2 on (t1_id = t2_id and t1_id > 2);
         T1_ID      T2_ID
             3          3
             4          4
             5          5
                        6
                        7
         T1_ID      T2_ID
             1
             2
             3          3
             4          4
             5          5
                        6
                        7

  • Improving the performance of this query

    Hi, Do you see any change we could do on this to improve its performance, pls, I appreciate you taking few minutes to help with analysing and tuining it
    select hoc.hoc_id,
    hoc.mstr_key_id,
    address.DISP_NME,
    blck.st_blck_id,
    blck.mstr_key_id as blck_mstr_key,
    bldg.BLDG_ID,
    hoc.BLDG_KEY_ID,
    address.OCPD_IND,
    address.TP_TYPE_CDE,
    '' as cmbcNumber,
    '' as tpSiteNumber,
    case
    when address.cmbc_id is not null then amsowner.ams_038_direct_connect.GetMobilierForCMB(address.cmbc_id)
    when address.lbc_id is not null and address.cmbc_id is null then amsowner.ams_038_direct_connect.GetMobilierForLBC(address.lbc_id)
    END as Mobilier,
    choice.cnsmr_chce_ind,
    hoc.SRT_IND,
    hoc.DLVRY_IND,
    case valRES_STAT_CDE
    when 123444 then hoc.cse_sprtn_wdth
    when 123555 then hoc_pend.cse_sprtn_wdth
    when 123666 then hoc_pend.cse_sprtn_wdth
    end as cse_sprtn_wdth,
    case valRES_STAT_CDE
    when 123444 then hoc.admail_color_id
    when 123555 then hoc.admail_color_id
    when 123666 then hoc_pend.admail_color_id
    end as admail_color_id,
    case valRES_STAT_CDE
    when 123444 then hoc.tieout
    when 123555 then hoc_pend.tieout
    when 123666 then hoc_pend.tieout
    end as tieout,
    hoc.callr_Ind,
    hoc.PCKUP_ind,
    case
    when hldout.hld_out_id > 0 then 33
    else 34
    end as HLDOUT_IND,
    case valRES_STAT_CDE
    when 123444 then hoc.BREAKER_CARD_NUM
    when 123555 then hoc_pend.BREAKER_CARD_NUM
    when 123666 then hoc_pend.BREAKER_CARD_NUM
    end as BREAKER_CARD_IND,
    Case
    when valRES_STAT_CDE = 123444 and hoc.MP_ID is not null and hoc.MP_ID <> 0 then 33
    when valRES_STAT_CDE = 123555 and hoc_pend.MP_ID is not null and hoc_pend.MP_ID <> 0 then 33
    when valRES_STAT_CDE = 123666 and hoc_pend.MP_ID is not null and hoc_pend.MP_ID <> 0 then 33
    else 34 END as MP_IND,
    case
    when valRES_STAT_CDE = 123444 then hoc.LCRMS_SEQ_NUM
    when valRES_STAT_CDE = 123555 then hoc_pend.DEL_SEQ
    when valRES_STAT_CDE = 123666 then hoc_pend.DEL_SEQ
    END as DEL_SEQ,
    case
    when (hoc_type_cde = 154 and hoc.MP_ID is not null ) then (NVL(mp.SLCLRES_RATE , 0)+ NVL(mp.OSSDRES_RATE,0))
    when (hoc_type_cde = 154 and hoc.MP_ID is null ) then (NVL(asmt.SLCLRES_RATE , 0)+ NVL(asmt.OSSDRES_RATE,0))
    when (hoc_type_cde = 156 and hoc.MP_ID is not null )then (NVL(mp.SLCLCOM_RATE,0) + NVL(mp.OSSDCOM_RATE,0))
    when (hoc_type_cde = 156 and hoc.MP_ID is null ) then (NVL(asmt.SLCLCOM_RATE,0) + NVL(asmt.OSSDCOM_RATE,0))
    else 0
    END As AvgMail,
    Case
    when valRES_STAT_CDE = 123444 then hoc.drct_ind
    when valRES_STAT_CDE = 123555 then hoc_pend.drct_ind
    when valRES_STAT_CDE = 123666 then hoc_pend.drct_ind
    END as drct_ind,
    Case
    when pc.ldu_type_cde in (492, 564, 565, 566, 567 ) then 33
    else 34
    end as lvr_ind,
    hoc.A12_CARD_IND,
    hoc.DNC_CARD_IND,
    hoc.CARD_IND,
    hoc.FRCE_CARD_IND,
    hoc.EXTRA_CARD_NBR,
    hoc.TTL_HOC_CNT,
    --(select BSNS_NME_EN from occupant where occupant.ADDR_MAIL_ID = address.addr_id and occupant.prmry_ind = 33 and rownum <= 1 )as PRIMARY_BUS_NME_EN,
    --(select BSNS_NME_FR from occupant where occupant.ADDR_MAIL_ID = address.addr_id and occupant.prmry_ind = 33 and rownum <= 1 )as PRIMARY_BUS_NME_FR,
    blck.blck_seq,
    address.ADDR_NUM,
    address.ADDR_SFX_CDE,
    address.ADDR_STE_NUM,
    hoc.HOC_TYPE_CDE,
    hoc.CSE_SPRTN_GRP_ID,
    pc.pc_id As pc_id,
    pc.disp_nme as pc_disp_nme,
    hoc.bag_ind,
    hoc.CASETAG,
    occupant.BSNS_NME_EN as PRIMARY_BUS_NME_EN , occupant.BSNS_NME_FR as PRIMARY_BUS_NME_FR
    from amsowner.AMS_038_HOC hoc
    left join amsowner.ams_038_hoc_pndng hoc_pend
    on hoc.MSTR_KEY_ID = hoc_pend.MSTR_KEY_ID
    inner join amsowner.AMS_038_ST_BlCK blck
    on hoc.st_blck_key_id = blck.mstr_key_id
    inner join amsowner.postal_code pc
    on blck.pc_id = pc.pc_id
    left join amsowner.AMS_038_bldg bldg
    on hoc.BLDG_KEY_ID = bldg.MSTR_KEY_ID
    inner join amsowner.address address
    on address.addr_id = hoc.addr_mail_id
    inner join amsowner.addr_lctn_to_mail locToMail
    on locToMail.addr_mail_id = address.addr_id
    inner join amsowner.addr_chce choice
    on choice.addr_id = locToMail.addr_lctn_id
    left join occupant on (occupant.ADDR_MAIL_ID = address.addr_id and occupant.prmry_ind = 33)
    left join amsowner.ams_038_hld_out hldout
    on (hldout.mstr_key_id = hoc.mstr_key_id and hldout.end_dte is null)
    left join amsowner.ams_038_dm dm
    on dm.dm_id = blck.dm_id
    left join ams_038_assmt asmt
    on blck.pc_id = asmt.pc_id and asmt.dpt_cde_nme = valDpt_cde_nme and ((asmt.case_type_cde = 1220 and dm.a62_cse_ind = 33) or (asmt.case_type_cde = 1219 and dm.a62_cse_ind = 34))
    left join ams_038_mail_prfl mp
    on hoc.mp_id = mp.mp_id and ((mp.case_type_cde = 1220 and dm.a62_cse_ind = 33) or (mp.case_type_cde = 1219 and dm.a62_cse_ind = 34))
    where hoc.mstr_key_id = valMSTR_KEY_ID and blck.DPT_CDE_NME = valDpt_cde_nme and hoc.DPT_CDE_NME = valDpt_cde_nme and blck.RSTRCTR_STAT_CDE = restCode;
    Thanks a lot :)

    Hi and welcome to the forum.
    I appreciate you taking few minutes to help with analysing and tuining itUnfortunatly it's not that simple.
    We would need some more input here, like:
    - database version
    - optimizer settings
    - execution plans
    -etc..
    Tuning is a complex matter, since many parameters come into play here.
    If you want some useful responses then see:
    [When your query takes too long...|http://forums.oracle.com/forums/thread.jspa?messageID=3299435]
    [How to post a SQLStatement tuning request|http://forums.oracle.com/forums/thread.jspa?threadID=863295&tstart=0]
    to understand what information would also be very useful to us (and, if needed, have your DBA participating in this as well).

  • I'm trying to improve the performance on a query that is running very slowly.

    SELECT p.book_id AS payment_book_id, b.status AS book_status,
           p.status AS payment_status, p.supplier_ref_no AS data_cash_ref,
           f.train_pnr_no AS train_pnr, f.train_id AS train_ref_id,
           f.service_no AS train_service_no, h.hotel_pnr_no AS hotel_pnr,
           h.hotel_id AS hotel_ref_id, h.service_no AS hotel_service_no,
           b.total_book_amt AS hotel_amt, c.car_pnr_no AS car_pnr,
           c.car_id AS car_ref_id, c.service_no AS car_service_no,
           b.book_date, b.promo_code
      FROM gk_payment p
      LEFT JOIN gk_book b ON b.book_id = p.book_id
      LEFT JOIN gk_train_itiner_det f ON p.book_id = f.book_id
      LEFT JOIN gk_hotel_itiner_det h ON p.book_id = h.book_id
      LEFT JOIN gk_car_itiner_det c ON p.book_id = c.book_id
    WHERE ((b.status IN ('8') AND p.status IN ('2', '0', '1', '8', '7')) OR
           (b.status IN ('5') AND p.status IN ('3')) OR
           (b.status IN ('11') AND p.status IN ('4', '5')))
           AND p.service_no IS NOT NULL
           AND b.book_type = 1
    ORDER BY train_id, car_id

    Some small comments about the query.
    1) The first left join is not needed, since the where filter "  AND b.book_type = 1" eliminates all cases where table b would be outer join (=empty).
    FROM gk_payment p
      LEFT JOIN gk_book b ON b.book_id = p.book_id
    2) The status comparison can be written in a different way. This will probably not change anything performancewise
    instead of
    WHERE ((b.status IN ('8') AND p.status IN ('2', '0', '1', '8', '7')) OR
           (b.status IN ('5') AND p.status IN ('3')) OR
           (b.status IN ('11') AND p.status IN ('4', '5')))
    you can write
    WHERE ((b.status,p.status))
        IN (('8','0')
            ,('8','1')
            ,('8','2')
            ,('8','7')
            ,('8','8')
            ,('5','3')
            ,('11','4')
            ,('11',53')
    Which is imo much easier to read, maintain and checkable for completeness.
    Furthermore: If the status fields are number columns then by all means compare them with numbers and not as strings.
    3) Remove the order by condition
    Is it faster without it? If yes, do you really need to order the output?

  • How to tune the query and difference between CBO AND RBO.. Which is good

    Hello Friends,
    Here are some questions I have pls reply back with complete description and url if any ..
    1)How Did you tune Query,
    2)What approach you take to tune query? Do you use Hints?
    3)Where did you tune the query and what are the issue with query?
    4)What is difference between RBO and CBO? where u use RBO and CBO.
    5)Give some information about hash join?
    6) Using explain plan how do u know where the bottle neck in query .. how u will identify where the bottle neck is from explain plan .
    thanks/Kumar

    Hi,
    kumar73 wrote:
    Hello Friends,
    Here are some questions I have pls reply back with complete description and url if any ..
    1)How Did you tune Query, Use EXPLAIN PLAN to see exactly where it is spending its time, and address those areas.
    See the forum FAQ
    SQL and PL/SQL FAQ
    "3. How to improve the performance of my query?"
    2)What approach you take to tune query? Do you use Hints?Hints can help.
    Even more helpful is writing the SQL efficiently (avoiding multiple scans of the same table, filtering early, using built-in rather than user-defined functions, ...), creating and using indexes, and, for large tables, partitioning.
    Table design can have a big impact on performace.
    Look for ways to do part of what you need before the query. This includes denormalizing (when appropriate), the kind of pre-digesting that often takes place in data warehouses, function-based indexes, and, starting in Oracle 11, virtual columns.
    3)Where did you tune the query and what are the issue with query?Either this question is a vague summary of the entire thread, or I don't understand it. Can you re-phrase this part?
    4)What is difference between RBO and CBO? where u use RBO and CBO.Basically, use RBO if you have Oracle 7 or earlier.

  • OT: How can we tune the search performance from the HTMLDB side?

    This might be not an issue that can be solved by HTMLDB itself. However, I'd like to give a shot because our HTMLDB apps are 'killing' the server, according to our DBA. One app I made is querying a 50 million records table, so everytime the query is fairly slow. Is there any way to tune the performance? Our DBA suggests using other tools like Discoverer or Orable Form to do the work of HTMLDB.
    Thanks for the inputs.
    Luc

    not OT.
    as noted, you need to determine which SQL statements are the culprit (various ways, your DBA should be very happy to help)
    but if you are using wizards that include a search field, you may be falling victim to some very inefficient SQL generated by HTML-DB/Apex, for instance (created by the application wizard for an application based on a table, creating a page with a report and a form):
    select
    "ID",
    "OBJECT_OWNER",
    "OBJECT_TYPE",
    "OBJECT_NAME",
    "TAB_COMMENTS",
    "OBJECT_CREATED",
    "OBJECT_MODIFIED",
    "USAGE_NOTES",
    "OBSOLETE_FLAG"
    from "DEV_TAB_COMMENTS"
    where
    instr(upper("OBJECT_OWNER"),upper(nvl(:P1_REPORT_SEARCH,"OBJECT_OWNER"))) > 0 or
    instr(upper("OBJECT_TYPE"),upper(nvl(:P1_REPORT_SEARCH,"OBJECT_TYPE"))) > 0 or
    instr(upper("OBJECT_NAME"),upper(nvl(:P1_REPORT_SEARCH,"OBJECT_NAME"))) > 0 or
    instr(upper("TAB_COMMENTS"),upper(nvl(:P1_REPORT_SEARCH,"TAB_COMMENTS"))) > 0 or
    instr(upper("USAGE_NOTES"),upper(nvl(:P1_REPORT_SEARCH,"USAGE_NOTES"))) > 0 or
    instr(upper("OBSOLETE_FLAG"),upper(nvl(:P1_REPORT_SEARCH,"OBSOLETE_FLAG"))) > 0
    which will do a full table scan no matter what search criteria you enter, and cannot be fixed on the database side -- sometimes SQL can be fixed with the creation of function-based-indexes( FBI), that won't work here.
    if your pages have such SQL, it needs to be rewritten to take advantage of indexes (FBI or otherwise)

  • Please guide to improve the performance of XML column reading query.

    Hi Experts,
    The below query is taking 45 seconds to return 170 records.
    Due to selecting XMLTYPE column in query.
    select *
    from RANGE where WSNO = 3
    order by PREFERENCE desc;
    The total number of records in the table is 1060.
    Even it's a very small table why it's taking 45 seconds.
    Can anybody please help me on how to get the output in 2 to 3 seconds.
    I want all the columns from the table.
    The problem only with REST column XMLTYPE.
    If I am not selecting this column I am getting output in 1 to 2 seconds.
    I am posting the execution plan and DDL for table and index.
    PLAN_TABLE_OUTPUT
    Plan hash value: 3593186720
    | SNO  | Operation                    | EMPNAME                   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |                        |    31 | 23281 |    21   (5)| 00:00:01 |
    |   1 |  SORT ORDER BY               |                        |    31 | 23281 |    21   (5)| 00:00:01 |
    |   2 |   TABLE ACCESS BY INDEX ROWID | RANGE                 |    31 | 23281 |    20   (0)| 00:00:01 |
    |*  3 |    INDEX RANGE SCAN          | INDX_WSNO              |    31 |       |     1   (0)| 00:00:01 |
    Predicate Information (SNOentified by operation SNO):
       3 - access("WSNO"=3)
    CREATE TABLE RANGE
      SNO                              NUMBER,
      BUSNO                            NUMBER,
      EMPNAME                          NVARCHAR2(64),
      PREFERENCE                       NUMBER,
      TSNO                             NUMBER,
      MEMBER                          CHAR(1 CHAR) ,
      EQU                             CHAR(1 CHAR) ,
      REMAIL                          CHAR(1 CHAR) ,
      SSR                             CHAR(1 CHAR) ,
      SUB                             CHAR(1 CHAR) ,
      SPN                             CHAR(1 CHAR) ,
      SEMPNAME                        NVARCHAR2(128),
      FVL                             NUMBER(32),
      TVL                             NUMBER(32),
      ISD                             CHAR(1 CHAR),
      CHANGED                         NVARCHAR2(64),
      CDATE                           TIMESTAMP(6) ,
      UDBY                            NVARCHAR2(64),
      UDATE                           TIMESTAMP(6),
      LSTU                            CLOB,
      WSNO                            NUMBER,
      ASTN                            CHAR(1 CHAR),
      ASTNPL                          CHAR(1 CHAR),
      AVAF                            CHAR(1 CHAR),
      REST                            SYS.XMLTYPE
    TABLESPACE USERS
    PCTUSED    0
    PCTFREE    10
    INITRANS   11
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                NEXT             1M
                MINEXTENTS       1
                MAXEXTENTS       UNLIMITED
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    XMLTYPE REST STORE AS CLOB
          ( TABLESPACE  USERS
            ENABLE      STORAGE IN ROW
            CHUNK       8192
            PCTVERSION  10
            NOCACHE
            INDEX       (
              TABLESPACE USERS
              STORAGE    (
                          INITIAL          64K
                          NEXT             1
                          MINEXTENTS       1
                          MAXEXTENTS       UNLIMITED
                          PCTINCREASE      0
                          BUFFER_POOL      DEFAULT
            STORAGE    (
                        INITIAL          64K
                        NEXT             1M
                        MINEXTENTS       1
                        MAXEXTENTS       UNLIMITED
                        PCTINCREASE      0
                        BUFFER_POOL      DEFAULT
      LOB (LSTU) STORE AS
          ( TABLESPACE  USERS
            ENABLE      STORAGE IN ROW
            CHUNK       8192
            RETENTION
            NOCACHE
            INDEX       (
              TABLESPACE USERS
              STORAGE    (
                          INITIAL          64K
                          NEXT             1
                          MINEXTENTS       1
                          MAXEXTENTS       UNLIMITED
                          PCTINCREASE      0
                          BUFFER_POOL      DEFAULT
            STORAGE    (
                        INITIAL          64K
                        NEXT             1M
                        MINEXTENTS       1
                        MAXEXTENTS       UNLIMITED
                        PCTINCREASE      0
                        BUFFER_POOL      DEFAULT
    NOCACHE
    NOPARALLEL
    MONITORING;
    CREATE INDEX INDX_WSNO ON RANGE(WSNO);
    CREATE UNIQUE INDEX RULE_EMPNAME ON RANGE(BUSNO, EMPNAME);
    Please help me how to improve the performance of this query.
    Thanks.

    Can you try something like this and check if its faster? (this is just my guess as I dont have your data )
    SELECT SNO,
           BUSNO,
           EMPNAME,
           PREFERENCE,
           TSNO,
           MEMBER,
           EQU,
           REMAIL,
           SSR,
           SUB,
           SPN,
           SEMPNAME,
           FVL,
           TVL,
           ISD,
           CHANGED,
           CDATE,
           UDBY,
           UDATE,
           LSTU,
           WSNO,
           ASTN,
           ASTNPL,
           AVAF,
           xmltype.getclobval (rest) rest
      FROM RANGE
    WHERE wsno = 3
    order by PREFERENCE desc;
    Cheers,
    Manik.

  • Tuning the Performance of Knowledge Management

    Hi
    How can i Tune the Performance of Knowledge Management

    Hi,
       Please go through the following articles, this will help you.
    <a href="https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/2eeebb86-0c01-0010-10af-9ac7101da81c">How to tune the Performance of Knowledge Management1</a>
    <a href="https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3bcdedb3-0801-0010-a3af-cf9292d181b4">How to tune the Performance of Knowledge Management2</a>
    <a href="https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/002fb447-d670-2910-67a5-bfbbf0bb287d">How to tune the Performance of Knowledge Management3</a>
    Regards,
    Venkatesh. K
    /* Points are Welcome */

Maybe you are looking for

  • ORABPEL-11017 Error while translating message to native format

    Hello I and trying to do a simple read and write file adapter. When I try and map the variables in the xls file it seems to work right but I run the BPEL and I get this output :( ORABPEL-11017 [2010/01/20 15:52:19] Faulted while invoking operation "W

  • How to customize Details dialog?

    Hi everyone, I’ve created an iView and I would like to add it into folder details dialog. It is possible? How it could be done? Thanks in advanced, Alcides Flach

  • Translated content in Portal Favourites iView

    Hi All, I have Portal roles in two languages English and German. I set the browser language to check the translations. Initially the browser language is English.  When we add the role to Portal Favourites and then change the browser language to Germa

  • SQL Query analysis plan

    Hi, Please explain how to analysis the below plan to improve the performance. STATEMENT_ID TIMESTAMP OPERATION OPTIONS OBJECT_NODE OBJECT_OWNER OBJECT_NAME OBJECT_INSTANCE OBJECT_TYPE OPTIMIZER SEARCH_COLUMNS ID PARENT_ID POSITION OTHER 31 08/14/2008

  • Transferring from PC to iMac?

    Hello, I wanted to know if anyone can explain how to get all my old various email from Microsoft Outlook 2007 to my new iMac? I have lots of old emails that I need to keep for future reference? There are to many to re email to myself too! Also I need