Joining select statements-performance problem

Here two cases are there.Is it posiible to combine the two cases and make it one? I am using OR in the select statement, performance is very bad, i want to improve it.Is there any chance of avoiding that...
1.
select vbeln from vbfa into itab-vbeln where vbelv = final_data-xblnr1
or vbelv = final_data-xblnr2.
select single vbeln from vbrk into tabvbrk-vbeln
where vbeln = itab-vbeln and fkart = 'RTS'.
if sy-subrc eq 0.
move tabvbrk-vbeln to final_data-vbeln1.
modify final_data.
endif.
endselect.
2.
select vbeln from vbfa into itab-vbeln where vbelv = final_data-xblnr1
or vbelv = final_data-xblnr2.
select single vbeln from vbrk into tabvbrk-vbeln
where vbeln = itab-vbeln and fkart = 'ZTR'.
if sy-subrc eq 0.
move tabvbrk-vbeln to final_data-vbeln2.
modify final_data.
endif.
endselect.
Thanks,
fractal

The first main thing is dont use select... endselect.
select vbeln from vbfa into itab-vbeln where vbelv = final_data-xblnr1
or vbelv = final_data-xblnr2.
U can use
select vbeln from vbfa into
corresponding fields of table itab
for all entries in final_data
where vbelv = final_data-xblnr1
or   vbelv = final_data-xblnr2.
Instead of this
select single vbeln from vbrk into tabvbrk-vbeln
where vbeln = itab-vbeln and fkart = 'RTS'.
if sy-subrc eq 0.
move tabvbrk-vbeln to final_data-vbeln1.
modify final_data.
endif.
endselect.
Use
select vbeln from vbrk
        appending table final_data
        where vbeln = itab-vbeln
        and fkart = 'RTS'.
if sy-subrc eq 0.
endif.
Try like this.
Hope this helps.
Kindly reward points for the answer which helped u and helped to solve the problem.

Similar Messages

  • How to find for which select statement performance is more

    hi gurus
    can anyone suggest me
    if we have 2 select statements than
    how to find for which select statement performance is more
    thanks&regards
    kals.

    hi check this..
    1 .the select statement in which the primary and secondary keys are used will gives the good performance .
    2.if the select statement had select up to  i row is good than the select single..
    go to st05 and check the performance..
    regards,
    venkat

  • ABAP Select statement performance (with nested NOT IN selects)

    Hi Folks,
    I'm working on the ST module and am working with the document flow table VBFA. The query takes a large amount of time, and is timing out in production. I am hoping that someone would be able to give me a few tips to make this run faster. In our test environment, this query take 12+ minutes to process.
        SELECT vbfa~vbeln
               vbfa~vbelv
               Sub~vbelv
               Material~matnr
               Material~zzactshpdt
               Material~werks
               Customer~name1
               Customer~sortl
          FROM vbfa JOIN vbrk AS Parent ON ( Parentvbeln = vbfavbeln )
                 JOIN vbfa AS Sub ON ( Subvbeln = vbfavbeln )
                 JOIN vbap AS Material ON ( Materialvbeln = Subvbelv )
                 JOIN vbak AS Header ON ( Headervbeln = Subvbelv )
                 JOIN vbpa AS Partner ON ( Partnervbeln = Subvbelv )
                 JOIN kna1 AS Customer ON ( Customerkunnr = Partnerkunnr )
          INTO (WA_Transfers-vbeln,
                WA_Transfers-vbelv,
                WA_Transfers-order,
                WA_Transfers-MATNR,
                WA_Transfers-sdate,
                WA_Transfers-sfwerks,
                WA_Transfers-name1,
                WA_Transfers-stwerks)
          WHERE vbfa~vbtyp_n = 'M'       "Invoice
          AND vbfa~fktyp = 'L'           "Delivery Related Billing Doc
          AND vbfa~vbtyp_v = 'J'         "Delivery Doc
          AND vbfa~vbelv IN S_VBELV
          AND Sub~vbtyp_n = 'M'          "Invoice Document Type
          AND Sub~vbtyp_v = 'C'          "Order Document Type
          AND Partner~parvw = 'WE'       "Ship To Party(actual desc. is SH)
          AND Material~zzactshpdt IN S_SDATE
          AND ( Parentfkart = 'ZTRA' OR Parentfkart = 'ZTER' )
          AND vbfa~vbelv NOT IN
             ( SELECT subvbfa~vbelv
               FROM vbfa AS subvbfa
               WHERE subvbfavbelv = vbfavbelv
               AND   subvbfa~vbtyp_n = 'V' )           "Purchase Order
          AND vbfa~vbelv NOT IN
             ( SELECT DelList~vbeln
               FROM vbfa AS DelList
               WHERE DelListvbeln = vbfavbelv
               AND   DelList~vbtyp_v = 'C'             "Order Document Type
               AND   DelList~vbelv IN                  "Delivery Doc
                  ( SELECT OrderList~vbelv
                    FROM vbfa AS OrderList
                    WHERE OrderList~vbtyp_n = 'H' )    "Return Ord
          APPEND WA_Transfers TO ITAB_Transfers.
        ENDSELECT.
    Cheers,
    Chris

    I am sending u some of the performance isuues that are to be kept in mind while coding.
    1.Donot use Select *...... instead use Select <required list>......
    2.Donot fetch data from CLUSTER tables.
    3.Donot use Nested Select statements as. U have used nested select which reduces performance to a greater extent.
      Instead  use  views/join .
    Also keep in mind that not use join condition for more for more than three tables unless otherwise required.
    So split select statements into three or four and use Select ......for all entries....
    4.Extract  the data from the database  atonce consolidated upfront into table.
      i.e. use INTO TABLE <ITAB> clause instead of using
    Select----
    End Select.
    5.Never use order by clause in Select ..... statement. instead use SORT<itab>.
    6.When  ever u need to calculate max,min,avg,sum,count use AGGREGATE FUNCTIONS and GROUP BY clause insted of calculating by userself..
    7.Donot use the same table once for Validation and another time for data extraction.select data  only once.
    8.When the intention is for validation use Select single ....../Select.......up to one rows ......statements.
    9.If possible always use array operations to update the database tables.
    10.Order of the fields in the where clause select statement  must be in the same order in the index of table.
    11.Never release the object unless throughly checked by st05/se30/slin.
    12.Avoid using identical select statements.

  • Dynamic table name in an inner join - select statement

    Hi,
    Please can you let me know if is possible to use a Dynamic table name in an inner join?
    Something like the statement below? (It works in a simple select statement but not in an inner join)
    SELECT  *
         INTO CORRESPONDING FIELDS OF <t_itab>
          FROM <Dynamic table name> INNER JOIN pa0050 ON
          ( <Dynamic table name>pernr =  pa0050pernr )
           WHERE <Dynamic table name>~pernr = it_pernr-l_pernr
           AND pa0050~bdegr = f_bdegr.
    Any help would be apprecited very much.
    Thanks & Regards.

    Hi,
    Check this link.
    [http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb39c4358411d1829f0000e829fbfe/frameset.htm]
    [Re: accessing dynamic internal table's fields??;
    hope it'll help u.
    Regards,
    Sneha.
    Edited by: sneha kumari on Jun 18, 2009 1:57 PM

  • Select statement performance improvement.

    HI Guru's,
    I am new to ABAP.
    I have the below select stement
    000304         SELECT mandt msgguid pid exetimest
    000305           INTO TABLE lt_key
    000306           UP TO lv_del_rows ROWS
    000307           FROM (gv_master)
    000308           WHERE
    000309 *          msgstate   IN rt_msgstate
    000310 *          AND   ( adapt_stat =  cl_xms_persist=>co_stat_adap_processed
    000311 *          OR      adapt_stat =  cl_xms_persist=>co_stat_adap_undefined )
    000312 *          AND     itfaction  =  ls_itfaction
    000313 *          AND     msgtype    =  cl_xms_persist=>co_async
    000314 *          AND
    000315           exetimest  LE lv_timestamp
    000316           AND     exetimest  GE last_ts
    000317           AND     reorg      =  cl_xms_persist=>co_reorg_ini
    000318           ORDER BY mandt itfaction reorg exetimest.
    Can anyone help me how i can improve the performance of this statement?
    Here is the sql trace for the statement:
    SELECT
    /*+
      FIRST_ROWS (100)
      "MANDT" , "MSGGUID" , "PID" , "EXETIMEST"
    FROM
      "SXMSPMAST"
    WHERE
      "MANDT" = :A0 AND "EXETIMEST" <= :A1 AND "EXETIMEST" >= :A2 AND "REORG" = :A3
    ORDER BY
      "MANDT" , "ITFACTION" , "REORG" , "EXETIMEST"
    Execution Plan
    SELECT STATEMENT ( Estimated Costs = 3 , Estimated #Rows = 544 )
            4 SORT ORDER BY
              ( Estim. Costs = 2 , Estim. #Rows = 544 )
              Estim. CPU-Costs = 15.671.852 Estim. IO-Costs = 1
                3 FILTER
                    2 TABLE ACCESS BY INDEX ROWID SXMSPMAST
                      ( Estim. Costs = 1 , Estim. #Rows = 544 )
                      Estim. CPU-Costs = 11.130 Estim. IO-Costs = 1
                        1 INDEX RANGE SCAN SXMSPMAST~TST
                          Search Columns: 2
                          Estim. CPU-Costs = 3.329 Estim. IO-Costs = 0
    Do I need to create any new index ? Do i need to remove the Order By clause?
    Thanks in advance.

    why is there an
    UP TO lv_del_rows ROWS
    together with an ORDER BY?
    The database will find all rows fulfilling the condition but returns only the largest Top lv_del_rows.
    Therefore it can take a while.
    Your index, always put the client field at first position.
    actually I am not really convinced by your logic:
    itfaction reorg exetimest.
    itfaction is the first in the sort order, so all records with the smallest itfactio will come first, but itfaction is not specified, is this really what you want?
    Change the index to mandt reorg exetimest reorg
    and change the ORDER BY to mandt reorg exetimest
    then it will become fast.
    * AND ( adapt_stat = cl_xms_persist=>co_stat_adap_processed
    000311 * OR adapt_stat = cl_xms_persist=>co_stat_adap_undefined )
    000312 * AND itfaction = ls_itfaction
    000313 * AND msgtype = cl_xms_persist=>co_async
    000314 * AND
    000315 exetimest LE lv_timestamp
    000316 AND exetimest GE last_ts
    000317 AND reorg = cl_xms_persist=>co_reorg_ini
    000318 ORDER BY mandt itfaction reorg exetimest.

  • Outer Join (select) statement

    hI
    Im BW-Consultant. I have two tables with some fileds.
    ZTABLE1 ---> MATNR, PRCTR, BUKRS, LIGNG, MATGR.And this table has 5-materials
    ZTABLE2 --> MATNR, PRCTR, BUKRS, FKMNG, VERID. And this table has 10-materials.
    These two tables(ZTABLE1, ZTABLE2) has 3-materials are common.
    But i want all 15-materials in an another table ZTABLE3. So how can i write an <b>outer join statement.</b> .
    Please give the OuterJoinCode(select statement) to get all 15-materials
    regards
    kumar

    Example
    SELECT KNA1~KUNNR KNA1~ADRNR ADR6~SMTP_ADDR
    INTO (A, B, C)
    FROM KNA1 LEFT OUTER JOIN ADR6
    ON KNA1~ADRNR = ADR6~ADDRNUMBER
    WHERE KUNNR BETWEEN '0000000000' AND '0000500000'.
    DATA: BEGIN OF wa,
            carrid   TYPE scarr-carrid,
            carrname TYPE scarr-carrname,
            connid   TYPE spfli-connid,
          END OF wa,
          itab LIKE SORTED TABLE OF wa
                    WITH NON-UNIQUE KEY carrid.
    SELECT s~carrid s~carrname p~connid
      INTO CORRESPONDING FIELDS OF TABLE itab
      FROM scarr AS s
           LEFT OUTER JOIN spfli AS p ON s~carrid   =  p~carrid AND
                                         p~cityfrom = 'FRANKFURT'.
    LOOP AT itab INTO wa.
      WRITE: / wa-carrid, wa-carrname, wa-connid.
    ENDLOOP.
    A

  • Performance wise, a select statement is faster on a view or on a table??

    Performance wise, a complex (with multi join) select statement is faster on a view or on a table??

    Hi,
    the purpose of a view is not to provide performance benefits, it's basically a way to better structure database code and data access. A view is nothing but a stored query. When the optimizer sees references to a view in a query, it tries to merge it (i.e. replace the view with its definition), but it some cases it may be unable to do so (in presence of analytic functions, rownum pseudocolumn etc.) -- in such cases views can lead to a performance degradation.
    If you are interested in performance, what you need is a materialized view, which is basically a table built from a query, but then you need to decide how you would refresh it. Please refer to the documentation for details.
    Best regards,
    Nikolay

  • Help needed with a SELECT statement. How can I make it run faster?

    Hi,
    not sure if my brain is just too tired but I can't seem to crack this problem today.
    Here is my scenario.
    I have 2 tables
    TABLE1 (searchId INTEGER, routeId INTEGER);
    TABLE2 (routeId INTEGER, cityId INTEGER);
    There are indexes on all 4 columns.
    (routeId on TABLE1 is a primary key).
    In the data I am using, a given search has more than 500 routes, each route has between 10 and 300 cities among more than 4000 possible different cities.
    Now, what I want to create is the list of route couple, within a certain search, that do not have a single city in common.
    That list should populate a table with the following structure
    TABLE3 (searchId INTEGER, routeId1 INTEGER, routeId2 INTEGER)
    Here is the fastest select statement I have found so far.
    SELECT :searchId, t1.routeId, t2.routeId FROM table1 t1, table1 t2
    WHERE t1.searchId=:searchId AND t2.searchId=:searchId
    AND t1.routeId>t2.routeId
    AND NOT EXISTS (
    SELECT cityId FROM table2
    WHERE routeId=t1.routeId
    INTERSECT
    SELECT cityId FROM table2
    WHERE routeId=t2.routeId);
    But it still seem really slow to me.
    Any suggestion for an improved version is welcome.
    Thanks,
    Martin.
    Title was edited by:
    user453358

    I originaly posted this thread because I tought I was missing something "obvious" that would perform better that would make my SELECT statement perform better.
    So I did not want to go as deep as using TKPROOF yet.
    Here is the statistics I gets on my statement.
      1   SELECT t1.searchId,t1.routeId, t2.routeId id2
      2      FROM table1 t1, table1 t2
      3     WHERE t1.searchid=t2.searchid
      4      AND t1.searchId=91
      5      AND t1.routeId>t2.routeId
      6      AND NOT EXISTS (
      7             SELECT cityId FROM table2
      8              WHERE routeId=t1.routeId
      9             INTERSECT
    10             SELECT cityId FROM table2
    11*            WHERE routeId=t2.routeId)
    SQL> /
    43302 rows.
    Tidsåtgång: 00:01:55.02
    Körschema
       0      SELECT STATEMENT Optimizer=ALL_ROWS (Cost=9 Card=1 Bytes=14)         
       1    0   FILTER                                                             
       2    1     TABLE ACCESS (BY INDEX ROWID) OF 'table1' (TABLE) (Cost=1 Card=1 Bytes=7)                                                
       3    2       NESTED LOOPS (Cost=3 Card=1 Bytes=14)                          
       4    3         TABLE ACCESS (BY INDEX ROWID) OF 'table1' (TABLE) (Cost=2 Card=1 Bytes=7)
       5    4           INDEX (RANGE SCAN) OF 'table1_IDX1' (INDEX) (Cost=1 Card=1)                                                    
       6    3         INDEX (RANGE SCAN) OF 'table1_IDX1' (INDEX) (Cost=0 Card=1)                                                      
       7    1     INTERSECTION                                                     
       8    7       SORT (UNIQUE) (Cost=3 Card=108 Bytes=864)                      
       9    8         TABLE ACCESS (BY INDEX ROWID) OF 'table2' (TABLE) (Cost=2 Card=108 Bytes=864)                                 
      10    9           INDEX (RANGE SCAN) OF 'table2_IDX1' (INDEX) (Cost=1 Card=108)                                               
      11    7       SORT (UNIQUE) (Cost=3 Card=108 Bytes=864)                      
      12   11         TABLE ACCESS (BY INDEX ROWID) OF 'table2' (TABLE) (Cost=2 Card=108 Bytes=864)                                 
      13   12           INDEX (RANGE SCAN) OF 'table2_IDX1' (INDEX) (Cost=1 Card=108)                                               
    Statistik
              1  recursive calls                                                   
              0  db block gets                                                     
        2872765  consistent gets                                                   
              0  physical reads                                                    
            812  redo size                                                         
         964172  bytes sent via SQL*Net to client                                  
          32245  bytes received via SQL*Net from client                            
           2888  SQL*Net roundtrips to/from client                                 
         860256  sorts (memory)                                                    
              0  sorts (disk)                                                      
          43302  rows processed  Looks like a big number of consistent gets! Any idea how to improve on that?
    Martin.

  • Performance problem(ANEA/ANEP table) in Select statement

    Hi
    I am using below select statement to fetch data.
    Does the below where statement have performance issue?
    can you Pls suggest.
    1)In select of ANEP table, i am not using all the Key field in where condition. will it have performance problem?
    2)does the order of where condition should be same as in table, if any one field order change also will have effect performance
    SELECT bukrs                           
             anln1                          
             anln2                          
             afabe                          
             gjahr                        
             peraf                         
             lnran                         
             bzdat                          
             bwasl                        
             belnr                         
             buzei                         
             anbtr                       
             lnsan                         
        FROM anep
        INTO TABLE o_anep
        FOR ALL ENTRIES IN i_anla
       WHERE bukrs = i_anla-bukrs          
         AND anln1 = i_anla-anln1          
         AND anln2 = i_anla-anln2          
         AND afabe IN s_afabe              
         AND bzdat =< p_date                
         AND bwasl IN s_bwasl.              
      SELECT bukrs      
             anln1      
             anln2      
             gjahr      
             lnran       
             afabe      
             aufwv       
             nafal   
             safal       
             aafal      
             erlbt    
             aufwl      
             nafav    
             aafav     
             invzv   
             invzl      
        FROM anea
        INTO TABLE o_anea
        FOR ALL ENTRIES IN o_anep
       WHERE bukrs = o_anep-bukrs    
         AND anln1 = o_anep-anln1    
         AND anln2 = o_anep-anln2    
         AND gjahr = o_anep-gjahr    
         AND lnran = o_anep-lnran   
         AND afabe = o_anep-afabe.
    Moderator message: Please Read before Posting in the Performance and Tuning Forum
    Edited by: Thomas Zloch on Aug 9, 2011 9:37 AM

    1. Yes. If you have only a few primary keys in youe WHERE condition that does affect the performance. But some times requirement itself may be in that way. We may not be knowing all the primary keys to given them in WHER conditon. If you know the values, then provide them without fail.
    2. Yes. It's better to always follow the sequence in WHERE condition and even in the fields being fetched.
    One important point is, whenever you use FOR ALL ENTRIES IN, please make sure that the itab IS NOT INITIAL i.e. the itab must have been filled in. So, place the same conditin before both the SELECT queries like:
    IF i_anla[] IS NOT INITIAL.
    SELECT bukrs                           
             anln1                          
             anln2                          
             afabe                          
             gjahr                        
             peraf                         
             lnran                         
             bzdat                          
             bwasl                        
             belnr                         
             buzei                         
             anbtr                       
             lnsan                         
        FROM anep
        INTO TABLE o_anep
        FOR ALL ENTRIES IN i_anla
       WHERE bukrs = i_anla-bukrs          
         AND anln1 = i_anla-anln1          
         AND anln2 = i_anla-anln2          
         AND afabe IN s_afabe              
         AND bzdat =< p_date                
         AND bwasl IN s_bwasl.              
    ENDIF.
    IF o_anep[] IS NOT INITIAL.
      SELECT bukrs      
             anln1      
             anln2      
             gjahr      
             lnran       
             afabe      
             aufwv       
             nafal   
             safal       
             aafal      
             erlbt    
             aufwl      
             nafav    
             aafav     
             invzv   
             invzl      
        FROM anea
        INTO TABLE o_anea
        FOR ALL ENTRIES IN o_anep
       WHERE bukrs = o_anep-bukrs    
         AND anln1 = o_anep-anln1    
         AND anln2 = o_anep-anln2    
         AND gjahr = o_anep-gjahr    
         AND lnran = o_anep-lnran   
         AND afabe = o_anep-afabe.
    ENDIF.

  • Select statement Table Join sequence (Performance)

    Hi,
    I have 3 tables Header (Hdr), Item (Itm) and Schedule Line (Sdl) table. The number of entries is max in Sdl table (Eg: Hdr = 1000; Item = 20000 and Sdl = 200000 records). I need to join these 3 tables in my SELECT statement to fetch the required records.
    Case A:
    Header AS HDR
    JOIN Item AS ITM
    ON HDRORDID = ITMORDID
    AND HDRVRSIOID = ITMVRSIOID
    JOIN ScheduleLine AS SDL
    ON ITMITMID = SDLITMID
    Case B:
    ScheduleLine AS SDL
    JOIN Item AS ITM
    ON ITMITMID = SDLITMID
    JOIN Header AS HDR
    ON HDRORDID = ITMORDID
    AND HDRVRSIOID = ITMVRSIOID
    Questions:
    1) The performance of the Select query is really bad with Case A and very good (really fast) with Case B. Will the number of records in the tables used determine the sequence of join in the Select statement ?
    2) If yes, is this independent of database used ? That is, will the behaviour be the same in all databases (Eg: Oracle, DB2, SQL Server, etc) ?
    Appreciate your help.
    Thanks,
    Karthik

    I believe that the performance discrepancy between the two versions is caused by you not specifying the joins correctly (i.e. not qualifying the header and item at schedule level as I mentioned previously).
    CAse A.
    Header AS HDR
    JOIN Item AS ITM
    ON HDRORDID = ITMORDID
    AND HDRVRSIOID = ITMVRSIOID
    JOIN ScheduleLine AS SDL
    ON ITMITMID = SDLITMID
    reads all 1000 hDRs, joins all 20000 items correctly to these BUT then joins schedule lines only by item id so there will be a very large number of matches. i.e. any item with itemid 10 will match to EVERY SDL with itemid 10. as there are 20000 items and 200000 schedule lines this will be massive!
    Case B:
    ScheduleLine AS SDL
    JOIN Item AS ITM
    ON ITMITMID = SDLITMID
    JOIN Header AS HDR
    ON HDRORDID = ITMORDID
    AND HDRVRSIOID = ITMVRSIOID
    This will not have the same amount of DB traffic as the SDL is now the driving force. It will still match more than you intend but will only be reading the items redundantly trather than the more voluminous schedules.
    Basically, your sql is wrong and should qualify the matches right down to schedule line level as per my earlier post. When you have changed the sql, try the two alternatives again and see if there is any performance differences. I suspect that there will not be, but it will be interesting to find out for sure.

  • Performance problem of asset selection statement.

    Hi guys quick question.
    SELECT a~bukrs
               a~anln1
               b~anln2
               a~anlkl
               a~aktiv
               a~txt50
               a~lvtnr
               b~afabe
               b~afabg
               b~ndjar
               b~ndper
               INTO TABLE it_anla
               FROM anla AS a
               INNER JOIN anlb AS b
               ON a~bukrs EQ b~bukrs
               AND a~anln1 EQ b~anln1
               WHERE a~bukrs IN s_bukrs
               AND a~anln1 IN s_anln1
               AND a~anln2 EQ '0000'
               AND a~anlkl IN s_anlkl
               AND a~aktiv EQ '00000000'
               AND a~lvtnr IN s_lvtnr
               AND b~afabe EQ 01.
    I have a select statement which is filtered by capitalization date which is the field AKTIV. This select alone has 450 thousand hits. Having an ANLN2 = 0 and AKTIV  = blank/no date means that the asset group is no longer active.
    Now for another scenario I have to retrieve table ANLA again excluding all the Main Asset Number/ANLN1 found on that table.
    Is there a way to select by doing it only once?
    I tried to pass all the anln1 to a range table but the program dumps. I think the range table can't handle too many entries.
    Retrieving all the entries from the DB then processing it takes longer.
    I tried to delete the table using a loop but it takes to long as it process the table every loop.
    LOOP AT it_anla WHERE anln2 EQ '0000' AND aktiv EQ '0000000'.
          DELETE it_anla WHERE bukrs EQ it_anla-bukrs AND anln1 EQ it_anla-anln1.
        ENDLOOP.
    Thanks.
    Edited by: Thomas Zloch on Sep 21, 2010 5:39 PM - please use code tags

    Moderator message - Welcome to SCN
    If the range table for anln1 is large and contains distinct values, you can try using it in a FOR ALL ENTRIES construct rather than IN.
    Rob

  • Serious performance problem - SELECT DISTINCT x.JDOCLASSX FROM x

    I am noticing a huge performance problem when trying to access a member that
    is lazily loaded:
    MonitorStatus previousStatus = m.getStatus();
    This causes the following query to be executed:
    SELECT DISTINCT MONITORSTATUSX.JDOCLASSX FROM MONITORSTATUSX
    This table has 3 million records and this SQL statement takes 3 minutes to
    execute! Even worse, my app heavily uses threads, so this statement is
    executed in each of the 32 threads. As a result the application stops.
    Is there any way that I can optimize this? And more importantly, can Kodo
    handle a multithreaded app like this with a huge database? I've been having
    a lot of performance problems since I've started doing stress & load
    testing, and I'm thinking Kodo isn't ready for this type of application.
    Thanks,
    Michael

    You can prevent this from happening by explicitly enumerating the valid
    persistent types in a property. See
    http://docs.solarmetric.com/manual.html#com.solarmetric.kodo.PersistentTypes
    for details.
    >
    Inconveniently, this nugget of performance info is not listed in the
    optimization guide. I'll add in an entry for it.This setting did in fact prevent the query from running which fixed the
    problem. It definitely belongs in the optimization guide.
    And more importantly, can Kodo
    handle a multithreaded app like this with a huge database? I've beenhaving
    a lot of performance problems since I've started doing stress & load
    testing, and I'm thinking Kodo isn't ready for this type of application.I'd like to find out more information about details about your issues. We
    do a decent amount of stress / load testing internally, but there are
    always use cases that we don't test. Please send me an email (I'm assuming
    that [email protected] is not really your address) and let's
    figure out some way to do an analysis of what you're seeing.This email is just for posting to usenet, to avoid spam. I'm now running my
    app through stress/load testing so I hope to discover any remaining issues
    before going into production. As of this morning the system seems to be
    performing quite well. Now the biggest performance problem for me is the
    lack of what I think is called "outer join". I know you'll have this in 3.0
    but I'm suprised you don't have this already because not having it really
    affects performance. I already had to code one query by hand with JDBC due
    to this. It was taking 15+ minutes with Kodo and with my JDBC version it
    only takes a few seconds. There are lots of anti-JDO people and performance
    issues like this really give them ammunition. Overall I just have the
    impression that Kodo hasn't been used on many really large scale projects
    with databases that have millions of records.
    Thanks for configuration fix,
    Michael

  • "Check Statistics" in the Performance tab. How to see SELECT statement?

    Hi,
    In a previous mail on SDN, it was explained (see below) that the "Check Statistics" in the Performance tab, under Manage in the context of a cube, executes the SELECT stament below.
    Would you happen to know how to see the SELECT statements that the "Check Statistics" command executes as mentioned in the posting below?
    Thanks
    ====================================
    When you hit the Check Statistics tab, it isn't just the fact tables that are checked, but also all master data tables for all the InfoObjects (characteristics) that are in the cubes dimensions.
    Checking nbr of rows inserted, last analyzed dates, etc.
    SELECT
    T.TABLE_NAME, M.PARTITION_NAME, TO_CHAR (T.LAST_ANALYZED, 'YYYYMMDDHH24MISS'), T.NUM_ROWS,
    M.INSERTS, M.UPDATES, M.DELETES, M.TRUNCATED
    FROM
    USER_TABLES T LEFT OUTER JOIN USER_TAB_MODIFICATIONS M ON T.TABLE_NAME = M.TABLE_NAME
    WHERE
    T.TABLE_NAME = '/BI0/PWBS_ELEMT' AND M.PARTITION_NAME IS NULL
    When you Refresh the stats, all the tables that need stats refreshed, are refreshed again. SInce InfoCube queries access the various master data tables in quereis, it makes sense that SAP would check their status.
    In looking at some of the results in 7.0, I'm not sure that the 30 day check is being doen as it was in 3.5. This is one area SAP retooled quite a bit.
    Yellow only indicates that there could be a problem. You could have stale DB stats on a table, but if they don't cause the DB optimizer to choose a poor execution plan, then it has no impact.
    Good DB stats are vital to query performance and old stats could be responsible for poor performance. I'm just syaing that the Statistics check yellow light status is not a definitive indicator.
    If your DBA has BRCONNECT running daily, you really should not have to worry about stats collection on the BW side except in cases immediately after large loads /deletes, and the nightly BRCONNECT hasn't run.
    BRCONNECT should produce a lof every time it runs showing you all the tables that it determeined should have stats refreshed. That might be worth a review. It should be running daily. If it is not being run, then you need to look at running stats collection from the BW side, either in Process Chains or via InfoCube automatisms.
    Best bet is to use ST04 to get Explain Plans of a poor running InfoCube query and then it can be reviewed to see where the time is being spent and whether stats ate a culprit.

    Hi,
    Thanks, this is what I came up with:
    st05,
    check SQL Trace, Activate Trace
    Now, in Rsa1
    on Cube, Cube1,
    Manage, Performance tab, Check Statistics
    Again, back to st05
    Deactivate Trace
    then click on Displace Trace
    Now, in the trace display, after scanning through  the output,
    “ … how do I see the SELECT statements that the "Check Statistics" command executes …”
    I will appreciate your help.

  • Performance Tuning 'Runtime Error' on Select statement

    Hi Experts,
    Good Day!
    I would like to ask some help regarding a custom program that will encounter 'Runtime Error' on the below codes on how to perform performance tunning especially number 1.
    1.
    SELECT A~VBELN A~ERDAT A~AUART A~VKORG A~VTWEG A~SPART A~VDATU
             A~KUNNR B~POSNR B~MATNR B~ARKTX B~ABGRU B~KWMENG B~VRKME
             B~WERKS B~VSTEL B~ROUTE
          FROM VBAK AS A INNER JOIN VBAP AS B ON A~VBELN EQ B~VBELN
                         INNER JOIN VBEP AS C ON A~VBELN EQ C~VBELN
                           AND B~POSNR EQ C~POSNR
            INTO CORRESPONDING FIELDS OF TABLE I_DATA_TAB
              WHERE A~VBELN  IN S_VBELN
                AND A~VKORG  IN S_VKORG
                AND A~AUART  IN S_AUART
                AND A~VTWEG  IN S_VTWEG
                AND A~SPART  IN S_SPART
                AND A~VDATU  IN S_VDATU
                AND A~KUNNR  IN S_KUNNRD
                AND B~MATNR  IN S_MATNR
                AND B~KWMENG IN S_KWMENG
                AND B~VRKME  IN S_VRKME
                AND B~WERKS  IN S_WERKS
                AND C~EDATU  IN S_VDATU.
    2.
    SELECT VBELN FROM LIKP INTO LIKP-VBELN
                  WHERE LFDAT IN S_VDATU
                    AND VKORG IN S_VKORG
                    AND LFART EQ 'YSTD'
                    AND KUNNR IN S_KUNNRP
                    AND KUNAG IN S_KUNNRD
        SELECT VBELN POSNR LFIMG MATNR WERKS
           FROM LIPS INTO (LIPS-VBELN, LIPS-POSNR, DISPLAY_TAB-DEL_QTY,
                           LIPS-MATNR, LIPS-WERKS)
                 WHERE VBELN EQ LIKP-VBELN
                   AND MATNR IN S_MATNR
                   AND VTWEG IN S_VTWEG
                   AND SPART IN S_SPART
                   AND WERKS IN S_WERKS.   
         ENDSELECT.
      ENDSELECT.
    4.
    SELECT DELIVERY POSNR MATNR PODLFIMG FROM T9YPODI INTO
        (T9YPODI-DELIVERY, T9YPODI-POSNR, T9YPODI-MATNR, T9YPODI-PODLFIMG)
                           WHERE MATNR   IN S_MATNR
                             AND PODDATE IN S_VDATU.
    Answer's will be a great help.
    ~Thank You,
      Lourd
    Edited by: Lourd06 on Oct 23, 2009 10:32 AM
    Moderator message - Welcome to SCN.
    Moderator message - Please see Please Read before Posting in the Performance and Tuning Forum before posting. You're in the driver's seat here. It's up to you to do some analysis before expecting that people can halp you. - post locked
    And please use code tags.
    Edited by: Rob Burbank on Oct 23, 2009 9:13 AM

    Hi All,
    We've checked the transaction ST22 it is TIME OUT. I really need your help on this the program will dump in number 1 Select statement. Can you help me perform a performance tunning.
    In transaction ST22
    Runtime Errors         TIME_OUT
    Date and Time          21.10.2009 08:51:33
    Short text
         Time limit exceeded.
    What happened?
         The program "ZV0PSR10" has exceeded the maximum permitted runtime without
         interruption and has therefore been terminated.
    What can you do?
         Note down which actions and inputs caused the error.
         To process the problem further, contact you SAP system
         administrator.
         Using Transaction ST22 for ABAP Dump Analysis, you can look
         at and manage termination messages, and you can also
         keep them for a long time.
    Error analysis
         After a specific time, the program is terminated to make the work area
         available to other users who may be waiting.
         This is to prevent a work area being blocked unnecessarily long by, for
         example:
         - Endless loops (DO, WHILE, ...),
         - Database accesses with a large result set
         - Database accesses without a suitable index (full table scan)
         The maximum runtime of a program is limited by the system profile
         parameter "rdisp/max_wprun_time". The current setting is 1200 seconds. If this
          time limit is
         exceeded, the system attempts to cancel any running SQL statement or
         signals the ABAP processor to stop the running program. Then the system
         waits another 60 seconds maximum. If the program is then still active,
         the work process is restarted.
    ~Thank you
    Lourd
    Edited by: Lourd06 on Oct 23, 2009 11:22 AM
    Edited by: Lourd06 on Oct 23, 2009 11:33 AM

  • Joins And For all Enteries in Select Statement

    Could you please tell me when there is a high amount of data which is being handled in the table, does the use of INNER JOINS and FOR ALL ENTERIES in SELECT Statement decreases the system performance? ?
    Can you also let me know where can i get some tips regarding do's and dont's for ABAP Programming, I want to increase my system performance.
    Currently the programs which are being used are taking a lot of time for execution...
    Its very URGENT!

    Hai Jyotsna
    Go through the following Tips for improving Performence
    For all entries
    The for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the length of the WHERE clause.
    The plus
    Large amount of data
    Mixing processing and reading of data
    Fast internal reprocessing of data
    Fast
    The Minus
    Difficult to program/understand
    Memory could be critical (use FREE or PACKAGE size)
    Some steps that might make FOR ALL ENTRIES more efficient:
    Removing duplicates from the driver table
    Sorting the driver table
    If possible, convert the data in the driver table to ranges so a BETWEEN statement is used instead of and OR statement:
                   FOR ALL ENTRIES IN i_tab
                      WHERE mykey >= i_tab-low and
                 mykey <= i_tab-high.
    Nested selects
    The plus:
    Small amount of data
    Mixing processing and reading of data
    Easy to code - and understand
    The minus:
    Large amount of data
    when mixed processing isn’t needed
    Performance killer no. 1
    Select using JOINS
    The plus
    Very large amount of data
    Similar to Nested selects - when the accesses are planned by the programmer
    In some cases the fastest
    Not so memory critical
    The minus
    Very difficult to program/understand
    Mixing processing and reading of data not possible
    Use the selection criteria
    SELECT * FROM SBOOK.                   
      CHECK: SBOOK-CARRID = 'LH' AND       
                      SBOOK-CONNID = '0400'.        
    ENDSELECT.                             
    SELECT * FROM SBOOK                     
      WHERE CARRID = 'LH' AND               
            CONNID = '0400'.                
    ENDSELECT.                              
    Use the aggregated functions
    C4A = '000'.              
    SELECT * FROM T100        
      WHERE SPRSL = 'D' AND   
            ARBGB = '00'.     
      CHECK: T100-MSGNR > C4A.
      C4A = T100-MSGNR.       
    ENDSELECT.                
    SELECT MAX( MSGNR ) FROM T100 INTO C4A 
    WHERE SPRSL = 'D' AND                
           ARBGB = '00'.                  
    Select with view
    SELECT * FROM DD01L                    
      WHERE DOMNAME LIKE 'CHAR%'           
            AND AS4LOCAL = 'A'.            
      SELECT SINGLE * FROM DD01T           
        WHERE   DOMNAME    = DD01L-DOMNAME 
            AND AS4LOCAL   = 'A'           
            AND AS4VERS    = DD01L-AS4VERS 
            AND DDLANGUAGE = SY-LANGU.     
    ENDSELECT.                             
    SELECT * FROM DD01V                    
    WHERE DOMNAME LIKE 'CHAR%'           
           AND DDLANGUAGE = SY-LANGU.     
    ENDSELECT.                             
    Select with index support
    SELECT * FROM T100            
    WHERE     ARBGB = '00'      
           AND MSGNR = '999'.    
    ENDSELECT.                    
    SELECT * FROM T002.             
      SELECT * FROM T100            
        WHERE     SPRSL = T002-SPRAS
              AND ARBGB = '00'      
              AND MSGNR = '999'.    
      ENDSELECT.                    
    ENDSELECT.                      
    Select … Into table
    REFRESH X006.                 
    SELECT * FROM T006 INTO X006. 
      APPEND X006.                
    ENDSELECT
    SELECT * FROM T006 INTO TABLE X006.
    Select with selection list
    SELECT * FROM DD01L              
      WHERE DOMNAME LIKE 'CHAR%'     
            AND AS4LOCAL = 'A'.      
    ENDSELECT
    SELECT DOMNAME FROM DD01L    
    INTO DD01L-DOMNAME         
    WHERE DOMNAME LIKE 'CHAR%' 
           AND AS4LOCAL = 'A'.  
    ENDSELECT
    Key access to multiple lines
    LOOP AT TAB.          
    CHECK TAB-K = KVAL. 
    ENDLOOP.              
    LOOP AT TAB WHERE K = KVAL.     
    ENDLOOP.                        
    Copying internal tables
    REFRESH TAB_DEST.              
    LOOP AT TAB_SRC INTO TAB_DEST. 
      APPEND TAB_DEST.             
    ENDLOOP.                       
    TAB_DEST[] = TAB_SRC[].
    Modifying a set of lines
    LOOP AT TAB.             
      IF TAB-FLAG IS INITIAL.
        TAB-FLAG = 'X'.      
      ENDIF.                 
      MODIFY TAB.            
    ENDLOOP.                 
    TAB-FLAG = 'X'.                  
    MODIFY TAB TRANSPORTING FLAG     
               WHERE FLAG IS INITIAL.
    Deleting a sequence of lines
    DO 101 TIMES.               
      DELETE TAB_DEST INDEX 450.
    ENDDO.                      
    DELETE TAB_DEST FROM 450 TO 550.
    Linear search vs. binary
    READ TABLE TAB WITH KEY K = 'X'.
    READ TABLE TAB WITH KEY K = 'X' BINARY SEARCH.
    Comparison of internal tables
    DESCRIBE TABLE: TAB1 LINES L1,      
                    TAB2 LINES L2.      
    IF L1 <> L2.                        
      TAB_DIFFERENT = 'X'.              
    ELSE.                               
      TAB_DIFFERENT = SPACE.            
    LOOP
    AT TAB1.                     
        READ TABLE TAB2 INDEX SY-TABIX. 
        IF TAB1 <> TAB2.                
          TAB_DIFFERENT = 'X'. EXIT.    
        ENDIF.                          
      ENDLOOP.                          
    ENDIF.                              
    IF TAB_DIFFERENT = SPACE.           
    ENDIF.                              
    IF TAB1[] = TAB2[].  
    ENDIF.               
    Modify selected components
    LOOP AT TAB.           
    TAB-DATE = SY-DATUM. 
    MODIFY TAB.          
    ENDLOOP.               
    WA-DATE = SY-DATUM.                    
    LOOP AT TAB.                           
    MODIFY TAB FROM WA TRANSPORTING DATE.
    ENDLOOP.                               
    Appending two internal tables
    LOOP AT TAB_SRC.              
      APPEND TAB_SRC TO TAB_DEST. 
    ENDLOOP
    APPEND LINES OF TAB_SRC TO TAB_DEST.
    Deleting a set of lines
    LOOP AT TAB_DEST WHERE K = KVAL. 
      DELETE TAB_DEST.               
    ENDLOOP
    DELETE TAB_DEST WHERE K = KVAL.
    Tools available in SAP to pin-point a performance problem
    ·                The runtime analysis (SE30)
    ·                SQL Trace (ST05)
    ·                Tips and Tricks tool
    ·                The performance database
    Optimizing the load of the database
    Using table buffering
    Using buffered tables improves the performance considerably. Note that in some cases a statement can not be used with a buffered table, so when using these statements the buffer will be bypassed. These statements are:
    Select DISTINCT
    ORDER BY / GROUP BY / HAVING clause
    Any WHERE clause that contains a sub query or IS NULL expression
    JOIN s
    A SELECT... FOR UPDATE
    If you wan t to explicitly bypass the buffer, use the BYPASS BUFFER addition to the SELECT clause.
    Use the ABAP SORT Clause Instead of ORDER BY
    The ORDER BY clause is executed on the database server while the ABAP SORT statement is executed on the application server. The database server will usually be the bottleneck, so sometimes it is better to move the sort from the database server to the application server.
    If you are not sorting by the primary key ( E.g. using the ORDER BY PRIMARY key statement) but are sorting by another key, it could be better to use the ABAP SORT statement to sort the data in an internal table. Note however that for very large result sets it might not be a feasible solution and you would want to let the database server sort it.
    Avoid the SELECT DISTINCT Statement
    As with the ORDER BY clause it could be better to avoid using SELECT DISTINCT, if some of the fields are not part of an index. Instead use ABAP SORT + DELETE ADJACENT DUPLICATES on an internal table, to delete duplicate rows.
    Thanks & regards
    Sreenivasulu P

Maybe you are looking for

  • I can't get it working on my tv....

    I bought an av cable some time ago... now I foudn out ALL our tvs don't have all the three av ports... so I bought a scard adapter, in which I can plug the av... but it's still not working. I don't know what i'm doing wrong, but isn't it suppose to w

  • Flash picture, need help please

    Hi For a website I want to make a picture of a map to be used so that when someone clicks on a certain area then they hare hyperlinked to a certain web page. i have the picture, how do I cut it up, using Flash (I'm told) so that this will happen? Tha

  • Does old equipment need to be returned?

    My parents have been BT Internet customers for quite a long time, but are thinking of stopping the BT connection quite soon (due to getting FTTP from another provider). I am fairly sure they are not currently within any minimum contract period. They

  • Report/Query/Web Template Listing - Catalog

    Hi all, We are NW2004S SP10 and would like to know if anyone has implemented a report catalog that lists all the custom reports/queries created by functional area? We could search the Metadata repository, but it is not organized well. Also I have loo

  • Org Unit and linked people

    Hello everybody, I have a requirement to show the Org Units available in the system, I found a table (HRP1000 or HRP1001) where I can get it, but I nedd also to show the personnel linked to each Org Unit, does anybody know how can I do it? Is it posi