<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Performance analyzation in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-analyzation/m-p/3391659#M814382</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Tools for Performance Analysis&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Run time analysis transaction SE30&lt;/STRONG&gt; :This transaction gives all the analysis of an ABAP program with respect to the database and the non-database processing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SQL Trace transaction ST05&lt;/STRONG&gt;: The trace list has many lines that are not related to the SELECT statement in the ABAP program. This is because the execution of any ABAP program requires additional administrative SQL calls. To restrict the list output, use the filter introducing the trace list. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The trace list contains different SQL statements simultaneously related to the one SELECT statement in the ABAP program. This is because the R/3 Database Interface - a sophisticated component of the R/3 Application Server - maps every Open SQL statement to one or a series of physical database calls and brings it to execution. This mapping, crucial to R/3s performance, depends on the particular call and database system. For example, the SELECT-ENDSELECT loop on a particular database table of the ABAP program would be mapped to a sequence PREPARE-OPEN-FETCH of physical calls in an Oracle environment. &lt;/P&gt;&lt;P&gt;The WHERE clause in the trace list's SQL statement is different from the WHERE clause in the ABAP statement. This is because in an R/3 system, a client is a self-contained unit with separate master records and its own set of table data (in commercial, organizational, and technical terms). With ABAP, every Open SQL statement automatically executes within the correct client environment. For this reason, a condition with the actual client code is added to every WHERE clause if a client field is a component of the searched table. &lt;/P&gt;&lt;P&gt;To see a statement's execution plan, just position the cursor on the PREPARE statement and choose Explain SQL. A detailed explanation of the execution plan depends on the database system in use. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Extended Program Check&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This can be called in through transaction SE38 or through transaction SLIN. This indicates possible problems that may cause performance problems. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code Inspector (SCI)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;You can call the Code Inspector from the ABAP Editor (SE38), the Function Builder (SE37), the Class Builder (SE24), or as a separate transaction (SCI). &lt;/P&gt;&lt;P&gt;The Code Inspector indicates possible problems. However, note that, especially with performance issues: There is no rule without exception. If a program passes an inspection, it does not necessarily mean that this program will have no performance problems.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;the percentage of LOAD&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The percentage across each of the areas ABAP/ Database/System shows the percentage of total time used for those areas and load on these areas while running the program . The lesser the database load faster the program runs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ways of Performance Tuning&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ways of Performance Tuning&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.	Selection Criteria &lt;/P&gt;&lt;P&gt;2.	Select Statements&lt;/P&gt;&lt;P&gt;&amp;#149;	Select Queries&lt;/P&gt;&lt;P&gt;&amp;#149;	SQL Interface&lt;/P&gt;&lt;P&gt;&amp;#149;	Aggregate Functions&lt;/P&gt;&lt;P&gt;&amp;#149;	For all Entries&lt;/P&gt;&lt;P&gt;Select Over more than one internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Selection Criteria&lt;/P&gt;&lt;P&gt;1.	Restrict the data to the selection criteria itself, rather than filtering it out using the ABAP code using CHECK statement.  &lt;/P&gt;&lt;P&gt;2.	Select with selection list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM SBOOK INTO SBOOK_WA.&lt;/P&gt;&lt;P&gt;  CHECK: SBOOK_WA-CARRID = 'LH' AND&lt;/P&gt;&lt;P&gt;         SBOOK_WA-CONNID = '0400'.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;The above code can be much more optimized by the code written below which avoids CHECK, selects with selection list &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT  CARRID CONNID FLDATE BOOKID FROM SBOOK INTO TABLE T_SBOOK&lt;/P&gt;&lt;P&gt;  WHERE SBOOK_WA-CARRID = 'LH' AND&lt;/P&gt;&lt;P&gt;              SBOOK_WA-CONNID = '0400'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select Statements   Select Queries&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.	Avoid nested selects&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM EKKO INTO EKKO_WA.&lt;/P&gt;&lt;P&gt;  SELECT * FROM EKAN INTO EKAN_WA&lt;/P&gt;&lt;P&gt;      WHERE EBELN = EKKO_WA-EBELN.&lt;/P&gt;&lt;P&gt;  ENDSELECT.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above code can be much more optimized by the code written below.&lt;/P&gt;&lt;P&gt;SELECT P&lt;SUB&gt;F1 P&lt;/SUB&gt;F2 F&lt;SUB&gt;F3 F&lt;/SUB&gt;F4 INTO TABLE ITAB&lt;/P&gt;&lt;P&gt;    FROM EKKO AS P INNER JOIN EKAN AS F&lt;/P&gt;&lt;P&gt;      ON P&lt;SUB&gt;EBELN = F&lt;/SUB&gt;EBELN.&lt;/P&gt;&lt;P&gt;Note: A simple SELECT loop is a single database access whose result is passed to the ABAP program line by line. Nested SELECT loops mean that the number of accesses in the inner loop is multiplied by the number of accesses in the outer loop. One should therefore use nested SELECT loops only if the selection in the outer loop contains very few lines or the outer loop is a SELECT SINGLE statement.&lt;/P&gt;&lt;P&gt;2.	Select all the records in a single shot using into table clause of select statement rather than to use Append statements. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM SBOOK INTO SBOOK_WA.&lt;/P&gt;&lt;P&gt;  CHECK: SBOOK_WA-CARRID = 'LH' AND&lt;/P&gt;&lt;P&gt;         SBOOK_WA-CONNID = '0400'.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;The above code can be much more optimized by the code written below which avoids CHECK, selects with selection list and puts the data in one shot using into table&lt;/P&gt;&lt;P&gt;SELECT  CARRID CONNID FLDATE BOOKID FROM SBOOK INTO TABLE T_SBOOK&lt;/P&gt;&lt;P&gt;  WHERE SBOOK_WA-CARRID = 'LH' AND&lt;/P&gt;&lt;P&gt;              SBOOK_WA-CONNID = '0400'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3.	When a base table has multiple indices, the where clause should be in the order of the index, either a primary or a secondary index. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To choose an index, the optimizer checks the field names specified in the where clause and then uses an index that has the same order of the fields. In certain scenarios, it is advisable to check whether a new index can speed up the performance of a program. This will come handy in programs that access data from the finance tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4.	For testing existence, use Select.. Up to 1 rows statement instead of a Select-Endselect-loop with an Exit.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM SBOOK INTO SBOOK_WA&lt;/P&gt;&lt;P&gt;  UP TO 1 ROWS&lt;/P&gt;&lt;P&gt;  WHERE CARRID = 'LH'.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;The above code is more optimized as compared to the code mentioned below for testing existence of a record.&lt;/P&gt;&lt;P&gt;SELECT * FROM SBOOK INTO SBOOK_WA&lt;/P&gt;&lt;P&gt;    WHERE CARRID = 'LH'.&lt;/P&gt;&lt;P&gt;  EXIT.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5.	Use Select Single if all primary key fields are supplied in the Where condition .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If all primary key fields are supplied in the Where conditions you can even use Select Single. &lt;/P&gt;&lt;P&gt;Select Single requires one communication with the database system, whereas Select-Endselect needs two. &lt;/P&gt;&lt;P&gt;Select Statements SQL Interface&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.	Use column updates instead of single-row updates &lt;/P&gt;&lt;P&gt;to update your database tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM SFLIGHT INTO SFLIGHT_WA.&lt;/P&gt;&lt;P&gt;  SFLIGHT_WA-SEATSOCC =&lt;/P&gt;&lt;P&gt;    SFLIGHT_WA-SEATSOCC - 1.&lt;/P&gt;&lt;P&gt;  UPDATE SFLIGHT FROM SFLIGHT_WA.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;The above mentioned code can be more optimized by using the following code&lt;/P&gt;&lt;P&gt;UPDATE SFLIGHT&lt;/P&gt;&lt;P&gt;       SET SEATSOCC = SEATSOCC - 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.	For all frequently used Select statements, try to use an index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM SBOOK CLIENT SPECIFIED INTO SBOOK_WA&lt;/P&gt;&lt;P&gt;  WHERE CARRID = 'LH'&lt;/P&gt;&lt;P&gt;    AND CONNID = '0400'.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;The above mentioned code can be more optimized by using the following code&lt;/P&gt;&lt;P&gt;SELECT * FROM SBOOK CLIENT SPECIFIED INTO SBOOK_WA&lt;/P&gt;&lt;P&gt;  WHERE MANDT IN ( SELECT MANDT FROM T000 )&lt;/P&gt;&lt;P&gt;    AND CARRID = 'LH'&lt;/P&gt;&lt;P&gt;    AND CONNID = '0400'.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3.	Using buffered tables improves the performance considerably.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Bypassing the buffer increases the network considerably&lt;/P&gt;&lt;P&gt;SELECT SINGLE * FROM T100 INTO T100_WA&lt;/P&gt;&lt;P&gt;  BYPASSING BUFFER&lt;/P&gt;&lt;P&gt;  WHERE     SPRSL = 'D'&lt;/P&gt;&lt;P&gt;        AND ARBGB = '00'&lt;/P&gt;&lt;P&gt;        AND MSGNR = '999'.&lt;/P&gt;&lt;P&gt;The above mentioned code can be more optimized by using the following code&lt;/P&gt;&lt;P&gt;SELECT SINGLE * FROM T100  INTO T100_WA&lt;/P&gt;&lt;P&gt;  WHERE     SPRSL = 'D'&lt;/P&gt;&lt;P&gt;        AND ARBGB = '00'&lt;/P&gt;&lt;P&gt;        AND MSGNR = '999'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select Statements  Aggregate Functions&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#149;	If you want to find the maximum, minimum, sum and average value or the count of a database column, use a select list with aggregate functions instead of computing the aggregates yourself. &lt;/P&gt;&lt;P&gt;Some of the Aggregate functions allowed in SAP are  MAX, MIN, AVG, SUM, COUNT, COUNT( * )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Consider the following extract.&lt;/P&gt;&lt;P&gt;            Maxno = 0.&lt;/P&gt;&lt;P&gt;            Select * from zflight where airln = &amp;#145;LF&amp;#146; and cntry = &amp;#145;IN&amp;#146;.&lt;/P&gt;&lt;P&gt;             Check zflight-fligh &amp;gt; maxno.&lt;/P&gt;&lt;P&gt;             Maxno = zflight-fligh.&lt;/P&gt;&lt;P&gt;            Endselect.&lt;/P&gt;&lt;P&gt;The  above mentioned code can be much more optimized by using the following code.&lt;/P&gt;&lt;P&gt;Select max( fligh ) from zflight into maxno where airln = &amp;#145;LF&amp;#146; and cntry = &amp;#145;IN&amp;#146;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select Statements  For All Entries&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#149;	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. &lt;/P&gt;&lt;P&gt;	The plus &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#149;	Large amount of data &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#149;	Mixing processing and reading of data &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#149;	Fast internal reprocessing of data &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#149;	Fast &lt;/P&gt;&lt;P&gt;	The Minus &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#149;	Difficult to program/understand &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#149;	Memory could be critical (use FREE or PACKAGE size) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Points to be must considered FOR ALL ENTRIES &lt;/P&gt;&lt;P&gt;&amp;#149;	Check that data is present in the driver table&lt;/P&gt;&lt;P&gt;&amp;#149;	Sorting the driver table &lt;/P&gt;&lt;P&gt;&amp;#149;	Removing duplicates from the driver table&lt;/P&gt;&lt;P&gt;Consider the following piece of extract&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          Loop at int_cntry.&lt;/P&gt;&lt;P&gt;  Select single * from zfligh into int_fligh&lt;/P&gt;&lt;P&gt;  where cntry = int_cntry-cntry.&lt;/P&gt;&lt;P&gt;  Append int_fligh. &lt;/P&gt;&lt;P&gt;                      Endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above mentioned can be more optimized by using the following code.&lt;/P&gt;&lt;P&gt;Sort int_cntry by cntry.&lt;/P&gt;&lt;P&gt;Delete adjacent duplicates from int_cntry.&lt;/P&gt;&lt;P&gt;If NOT int_cntry[] is INITIAL.&lt;/P&gt;&lt;P&gt;            Select * from zfligh appending table int_fligh&lt;/P&gt;&lt;P&gt;            For all entries in int_cntry &lt;/P&gt;&lt;P&gt;            Where cntry = int_cntry-cntry.&lt;/P&gt;&lt;P&gt;Endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select Statements Select Over more than one Internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.	Its better to use a views instead of nested Select statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM DD01L INTO DD01L_WA&lt;/P&gt;&lt;P&gt;  WHERE DOMNAME LIKE 'CHAR%'&lt;/P&gt;&lt;P&gt;        AND AS4LOCAL = 'A'.&lt;/P&gt;&lt;P&gt;  SELECT SINGLE * FROM DD01T INTO DD01T_WA&lt;/P&gt;&lt;P&gt;    WHERE   DOMNAME    = DD01L_WA-DOMNAME&lt;/P&gt;&lt;P&gt;        AND AS4LOCAL   = 'A'&lt;/P&gt;&lt;P&gt;        AND AS4VERS    = DD01L_WA-AS4VERS&lt;/P&gt;&lt;P&gt;        AND DDLANGUAGE = SY-LANGU.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above code can be more optimized by extracting all the data from view DD01V_WA &lt;/P&gt;&lt;P&gt;SELECT * FROM DD01V INTO  DD01V_WA&lt;/P&gt;&lt;P&gt;  WHERE DOMNAME LIKE 'CHAR%'&lt;/P&gt;&lt;P&gt;        AND DDLANGUAGE = SY-LANGU.&lt;/P&gt;&lt;P&gt;ENDSELECT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.	To read data from several logically connected tables use a join instead of nested Select statements. Joins are preferred only if all the primary key are available in WHERE clause for the tables that are joined. If the primary keys are not provided in join the Joining of tables itself takes time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM EKKO INTO EKKO_WA.&lt;/P&gt;&lt;P&gt;  SELECT * FROM EKAN INTO EKAN_WA&lt;/P&gt;&lt;P&gt;      WHERE EBELN = EKKO_WA-EBELN.&lt;/P&gt;&lt;P&gt;  ENDSELECT.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;The above code can be much more optimized by the code written below.&lt;/P&gt;&lt;P&gt;SELECT P&lt;SUB&gt;F1 P&lt;/SUB&gt;F2 F&lt;SUB&gt;F3 F&lt;/SUB&gt;F4 INTO TABLE ITAB&lt;/P&gt;&lt;P&gt;    FROM EKKO AS P INNER JOIN EKAN AS F&lt;/P&gt;&lt;P&gt;      ON P&lt;SUB&gt;EBELN = F&lt;/SUB&gt;EBELN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3.	Instead of using nested Select loops it is often better to use subqueries. &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;SELECT * FROM SPFLI&lt;/P&gt;&lt;P&gt;  INTO TABLE T_SPFLI&lt;/P&gt;&lt;P&gt;  WHERE CITYFROM = 'FRANKFURT'&lt;/P&gt;&lt;P&gt;    AND CITYTO = 'NEW YORK'.&lt;/P&gt;&lt;P&gt;SELECT * FROM SFLIGHT AS F&lt;/P&gt;&lt;P&gt;    INTO SFLIGHT_WA&lt;/P&gt;&lt;P&gt;    FOR ALL ENTRIES IN T_SPFLI&lt;/P&gt;&lt;P&gt;    WHERE SEATSOCC -FLAG = 'X'.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt; The above code works faster as compared to&lt;/P&gt;&lt;P&gt;LOOP AT ITAB INTO WA.&lt;/P&gt;&lt;P&gt;  I = SY-TABIX MOD 2.&lt;/P&gt;&lt;P&gt;  IF I = 0.&lt;/P&gt;&lt;P&gt;    WA-FLAG = 'X'.&lt;/P&gt;&lt;P&gt;    MODIFY ITAB FROM WA.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;8.    If collect semantics is required, it is always better to use to COLLECT rather than READ BINARY and then ADD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB1 INTO WA1.&lt;/P&gt;&lt;P&gt;  READ TABLE ITAB2 INTO WA2 WITH KEY K = WA1-K BINARY SEARCH.&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;    ADD: WA1-VAL1 TO WA2-VAL1,&lt;/P&gt;&lt;P&gt;         WA1-VAL2 TO WA2-VAL2.&lt;/P&gt;&lt;P&gt;    MODIFY ITAB2 FROM WA2 INDEX SY-TABIX TRANSPORTING VAL1 VAL2.&lt;/P&gt;&lt;P&gt;  ELSE.&lt;/P&gt;&lt;P&gt;    INSERT WA1 INTO ITAB2 INDEX SY-TABIX.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;The above code uses BINARY SEARCH for collect semantics. READ BINARY runs in O( log2(n) ) time. The above piece of code can be more optimized by&lt;/P&gt;&lt;P&gt;LOOP AT ITAB1 INTO WA.&lt;/P&gt;&lt;P&gt;  COLLECT WA INTO ITAB2.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;SORT ITAB2 BY K.&lt;/P&gt;&lt;P&gt;COLLECT, however, uses a hash algorithm and is therefore independent &lt;/P&gt;&lt;P&gt;of the number of entries (i.e. O(1)) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;9.    "APPEND LINES OF itab1 TO itab2" accelerates the task of appending a table to another table considerably as compared to &amp;#147; LOOP-APPEND-ENDLOOP.&amp;#148; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND LINES OF ITAB1 TO ITAB2.&lt;/P&gt;&lt;P&gt; This is more optimized as compared to&lt;/P&gt;&lt;P&gt;LOOP AT ITAB1 INTO WA.&lt;/P&gt;&lt;P&gt;  APPEND WA TO ITAB2.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;10.   &amp;#147;DELETE ADJACENT DUPLICATES&amp;#147; accelerates the task of deleting duplicate entries considerably as compared to &amp;#147; READ-LOOP-DELETE-ENDLOOP&amp;#148;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE ADJACENT DUPLICATES FROM ITAB COMPARING K.&lt;/P&gt;&lt;P&gt;This is much more optimized as compared to&lt;/P&gt;&lt;P&gt;READ TABLE ITAB INDEX 1 INTO PREV_LINE.&lt;/P&gt;&lt;P&gt;LOOP AT ITAB FROM 2 INTO WA.&lt;/P&gt;&lt;P&gt;  IF WA = PREV_LINE.&lt;/P&gt;&lt;P&gt;    DELETE ITAB.&lt;/P&gt;&lt;P&gt;  ELSE.&lt;/P&gt;&lt;P&gt;    PREV_LINE = WA.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;11.   "DELETE itab FROM ... TO ..." accelerates the task of deleting a sequence of lines considerably as compared to &amp;#147;  DO -DELETE-ENDDO&amp;#148;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE ITAB FROM 450 TO 550.&lt;/P&gt;&lt;P&gt;This is much more optimized as compared to&lt;/P&gt;&lt;P&gt;DO 101 TIMES.&lt;/P&gt;&lt;P&gt;  DELETE ITAB INDEX 450.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;12.   Copying internal tables by using &amp;#147;ITAB2[ ] = ITAB1[ ]&amp;#148; as compared to &amp;#147;LOOP-APPEND-ENDLOOP&amp;#148;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ITAB2[] = ITAB1[].&lt;/P&gt;&lt;P&gt;This is much more optimized as compared to&lt;/P&gt;&lt;P&gt;REFRESH ITAB2.&lt;/P&gt;&lt;P&gt;LOOP AT ITAB1 INTO WA.&lt;/P&gt;&lt;P&gt;  APPEND WA TO ITAB2.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;13.   Specify the sort key as restrictively as possible to run the program faster. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &amp;#147;SORT ITAB BY K.&amp;#148; makes the program runs faster as compared to &amp;#147;SORT ITAB.&amp;#148;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Internal Tables         contd&amp;#133;&lt;/P&gt;&lt;P&gt; Hashed and Sorted tables&lt;/P&gt;&lt;P&gt;1.	For single read access hashed tables are more optimized as compared to sorted tables.&lt;/P&gt;&lt;P&gt;2.	 For partial sequential access sorted tables are more optimized as compared to hashed tables&lt;/P&gt;&lt;P&gt;Hashed And Sorted Tables&lt;/P&gt;&lt;P&gt;Point # 1&lt;/P&gt;&lt;P&gt;Consider the following example where HTAB is a hashed table and STAB is a sorted table&lt;/P&gt;&lt;P&gt;DO 250 TIMES.&lt;/P&gt;&lt;P&gt;  N = 4 * SY-INDEX.&lt;/P&gt;&lt;P&gt;  READ TABLE HTAB INTO WA WITH TABLE KEY K = N.&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;    " ...&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;This runs faster for single read access as compared to the following same code for sorted table&lt;/P&gt;&lt;P&gt;DO 250 TIMES.&lt;/P&gt;&lt;P&gt;  N = 4 * SY-INDEX.&lt;/P&gt;&lt;P&gt;  READ TABLE STAB INTO WA WITH TABLE KEY K = N.&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;    " ...&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Point # 2&lt;/P&gt;&lt;P&gt;Similarly for Partial Sequential access the STAB runs faster as compared to HTAB&lt;/P&gt;&lt;P&gt;LOOP AT STAB INTO WA WHERE K = SUBKEY.&lt;/P&gt;&lt;P&gt;  " ...&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;This runs faster as compared to&lt;/P&gt;&lt;P&gt;LOOP AT HTAB INTO WA WHERE K = SUBKEY.&lt;/P&gt;&lt;P&gt;  " ...&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 11 Feb 2008 06:59:44 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-02-11T06:59:44Z</dc:date>
    <item>
      <title>Performance analyzation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-analyzation/m-p/3391657#M814380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi every body,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;                 Could any one explain me the following things regarding ABAP RUN TIME ANALYSIS..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. what can we analyze by checking Tcode SE30. &lt;/P&gt;&lt;P&gt;2. what is abap load  and what is database load and what is system load there? &lt;/P&gt;&lt;P&gt;3. For a good performance of a ABAP program, what should be the abap load and data base load?&lt;/P&gt;&lt;P&gt;4. If database load is more what to do to improve performance and if ABAP load is more what to do to improve performance?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          thanks in advance,&lt;/P&gt;&lt;P&gt;           santosh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2008 06:13:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-analyzation/m-p/3391657#M814380</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-11T06:13:57Z</dc:date>
    </item>
    <item>
      <title>Re: Performance analyzation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-analyzation/m-p/3391658#M814381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. ABAP load is the amount of time taken by the code in ABAP processing. DB load is the amount of time taken by the code to fetch data from DB.&lt;/P&gt;&lt;P&gt;2. There is no hard and fast rule for that. Programs total time is 100% which is distributed in ABAP, DB and system loads. We cannot control System load but we can definately reduce time (not percentage -  total would be 100) of ABAP and DB.&lt;/P&gt;&lt;P&gt;3. IF DB is more then try to do performance tuning with ur select queries and if ABAP load is more then try to remove nested loops and optimize on the internal tables by freeing them when not in use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Naveen Gupta&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS: Please reward points if helpfull.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2008 06:48:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-analyzation/m-p/3391658#M814381</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-11T06:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: Performance analyzation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-analyzation/m-p/3391659#M814382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Tools for Performance Analysis&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Run time analysis transaction SE30&lt;/STRONG&gt; :This transaction gives all the analysis of an ABAP program with respect to the database and the non-database processing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SQL Trace transaction ST05&lt;/STRONG&gt;: The trace list has many lines that are not related to the SELECT statement in the ABAP program. This is because the execution of any ABAP program requires additional administrative SQL calls. To restrict the list output, use the filter introducing the trace list. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The trace list contains different SQL statements simultaneously related to the one SELECT statement in the ABAP program. This is because the R/3 Database Interface - a sophisticated component of the R/3 Application Server - maps every Open SQL statement to one or a series of physical database calls and brings it to execution. This mapping, crucial to R/3s performance, depends on the particular call and database system. For example, the SELECT-ENDSELECT loop on a particular database table of the ABAP program would be mapped to a sequence PREPARE-OPEN-FETCH of physical calls in an Oracle environment. &lt;/P&gt;&lt;P&gt;The WHERE clause in the trace list's SQL statement is different from the WHERE clause in the ABAP statement. This is because in an R/3 system, a client is a self-contained unit with separate master records and its own set of table data (in commercial, organizational, and technical terms). With ABAP, every Open SQL statement automatically executes within the correct client environment. For this reason, a condition with the actual client code is added to every WHERE clause if a client field is a component of the searched table. &lt;/P&gt;&lt;P&gt;To see a statement's execution plan, just position the cursor on the PREPARE statement and choose Explain SQL. A detailed explanation of the execution plan depends on the database system in use. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Extended Program Check&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;This can be called in through transaction SE38 or through transaction SLIN. This indicates possible problems that may cause performance problems. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code Inspector (SCI)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;You can call the Code Inspector from the ABAP Editor (SE38), the Function Builder (SE37), the Class Builder (SE24), or as a separate transaction (SCI). &lt;/P&gt;&lt;P&gt;The Code Inspector indicates possible problems. However, note that, especially with performance issues: There is no rule without exception. If a program passes an inspection, it does not necessarily mean that this program will have no performance problems.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;the percentage of LOAD&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The percentage across each of the areas ABAP/ Database/System shows the percentage of total time used for those areas and load on these areas while running the program . The lesser the database load faster the program runs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Ways of Performance Tuning&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ways of Performance Tuning&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.	Selection Criteria &lt;/P&gt;&lt;P&gt;2.	Select Statements&lt;/P&gt;&lt;P&gt;&amp;#149;	Select Queries&lt;/P&gt;&lt;P&gt;&amp;#149;	SQL Interface&lt;/P&gt;&lt;P&gt;&amp;#149;	Aggregate Functions&lt;/P&gt;&lt;P&gt;&amp;#149;	For all Entries&lt;/P&gt;&lt;P&gt;Select Over more than one internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Selection Criteria&lt;/P&gt;&lt;P&gt;1.	Restrict the data to the selection criteria itself, rather than filtering it out using the ABAP code using CHECK statement.  &lt;/P&gt;&lt;P&gt;2.	Select with selection list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM SBOOK INTO SBOOK_WA.&lt;/P&gt;&lt;P&gt;  CHECK: SBOOK_WA-CARRID = 'LH' AND&lt;/P&gt;&lt;P&gt;         SBOOK_WA-CONNID = '0400'.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;The above code can be much more optimized by the code written below which avoids CHECK, selects with selection list &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT  CARRID CONNID FLDATE BOOKID FROM SBOOK INTO TABLE T_SBOOK&lt;/P&gt;&lt;P&gt;  WHERE SBOOK_WA-CARRID = 'LH' AND&lt;/P&gt;&lt;P&gt;              SBOOK_WA-CONNID = '0400'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select Statements   Select Queries&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.	Avoid nested selects&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM EKKO INTO EKKO_WA.&lt;/P&gt;&lt;P&gt;  SELECT * FROM EKAN INTO EKAN_WA&lt;/P&gt;&lt;P&gt;      WHERE EBELN = EKKO_WA-EBELN.&lt;/P&gt;&lt;P&gt;  ENDSELECT.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above code can be much more optimized by the code written below.&lt;/P&gt;&lt;P&gt;SELECT P&lt;SUB&gt;F1 P&lt;/SUB&gt;F2 F&lt;SUB&gt;F3 F&lt;/SUB&gt;F4 INTO TABLE ITAB&lt;/P&gt;&lt;P&gt;    FROM EKKO AS P INNER JOIN EKAN AS F&lt;/P&gt;&lt;P&gt;      ON P&lt;SUB&gt;EBELN = F&lt;/SUB&gt;EBELN.&lt;/P&gt;&lt;P&gt;Note: A simple SELECT loop is a single database access whose result is passed to the ABAP program line by line. Nested SELECT loops mean that the number of accesses in the inner loop is multiplied by the number of accesses in the outer loop. One should therefore use nested SELECT loops only if the selection in the outer loop contains very few lines or the outer loop is a SELECT SINGLE statement.&lt;/P&gt;&lt;P&gt;2.	Select all the records in a single shot using into table clause of select statement rather than to use Append statements. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM SBOOK INTO SBOOK_WA.&lt;/P&gt;&lt;P&gt;  CHECK: SBOOK_WA-CARRID = 'LH' AND&lt;/P&gt;&lt;P&gt;         SBOOK_WA-CONNID = '0400'.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;The above code can be much more optimized by the code written below which avoids CHECK, selects with selection list and puts the data in one shot using into table&lt;/P&gt;&lt;P&gt;SELECT  CARRID CONNID FLDATE BOOKID FROM SBOOK INTO TABLE T_SBOOK&lt;/P&gt;&lt;P&gt;  WHERE SBOOK_WA-CARRID = 'LH' AND&lt;/P&gt;&lt;P&gt;              SBOOK_WA-CONNID = '0400'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3.	When a base table has multiple indices, the where clause should be in the order of the index, either a primary or a secondary index. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To choose an index, the optimizer checks the field names specified in the where clause and then uses an index that has the same order of the fields. In certain scenarios, it is advisable to check whether a new index can speed up the performance of a program. This will come handy in programs that access data from the finance tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4.	For testing existence, use Select.. Up to 1 rows statement instead of a Select-Endselect-loop with an Exit.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM SBOOK INTO SBOOK_WA&lt;/P&gt;&lt;P&gt;  UP TO 1 ROWS&lt;/P&gt;&lt;P&gt;  WHERE CARRID = 'LH'.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;The above code is more optimized as compared to the code mentioned below for testing existence of a record.&lt;/P&gt;&lt;P&gt;SELECT * FROM SBOOK INTO SBOOK_WA&lt;/P&gt;&lt;P&gt;    WHERE CARRID = 'LH'.&lt;/P&gt;&lt;P&gt;  EXIT.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5.	Use Select Single if all primary key fields are supplied in the Where condition .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If all primary key fields are supplied in the Where conditions you can even use Select Single. &lt;/P&gt;&lt;P&gt;Select Single requires one communication with the database system, whereas Select-Endselect needs two. &lt;/P&gt;&lt;P&gt;Select Statements SQL Interface&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.	Use column updates instead of single-row updates &lt;/P&gt;&lt;P&gt;to update your database tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM SFLIGHT INTO SFLIGHT_WA.&lt;/P&gt;&lt;P&gt;  SFLIGHT_WA-SEATSOCC =&lt;/P&gt;&lt;P&gt;    SFLIGHT_WA-SEATSOCC - 1.&lt;/P&gt;&lt;P&gt;  UPDATE SFLIGHT FROM SFLIGHT_WA.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;The above mentioned code can be more optimized by using the following code&lt;/P&gt;&lt;P&gt;UPDATE SFLIGHT&lt;/P&gt;&lt;P&gt;       SET SEATSOCC = SEATSOCC - 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.	For all frequently used Select statements, try to use an index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM SBOOK CLIENT SPECIFIED INTO SBOOK_WA&lt;/P&gt;&lt;P&gt;  WHERE CARRID = 'LH'&lt;/P&gt;&lt;P&gt;    AND CONNID = '0400'.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;The above mentioned code can be more optimized by using the following code&lt;/P&gt;&lt;P&gt;SELECT * FROM SBOOK CLIENT SPECIFIED INTO SBOOK_WA&lt;/P&gt;&lt;P&gt;  WHERE MANDT IN ( SELECT MANDT FROM T000 )&lt;/P&gt;&lt;P&gt;    AND CARRID = 'LH'&lt;/P&gt;&lt;P&gt;    AND CONNID = '0400'.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3.	Using buffered tables improves the performance considerably.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Bypassing the buffer increases the network considerably&lt;/P&gt;&lt;P&gt;SELECT SINGLE * FROM T100 INTO T100_WA&lt;/P&gt;&lt;P&gt;  BYPASSING BUFFER&lt;/P&gt;&lt;P&gt;  WHERE     SPRSL = 'D'&lt;/P&gt;&lt;P&gt;        AND ARBGB = '00'&lt;/P&gt;&lt;P&gt;        AND MSGNR = '999'.&lt;/P&gt;&lt;P&gt;The above mentioned code can be more optimized by using the following code&lt;/P&gt;&lt;P&gt;SELECT SINGLE * FROM T100  INTO T100_WA&lt;/P&gt;&lt;P&gt;  WHERE     SPRSL = 'D'&lt;/P&gt;&lt;P&gt;        AND ARBGB = '00'&lt;/P&gt;&lt;P&gt;        AND MSGNR = '999'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select Statements  Aggregate Functions&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#149;	If you want to find the maximum, minimum, sum and average value or the count of a database column, use a select list with aggregate functions instead of computing the aggregates yourself. &lt;/P&gt;&lt;P&gt;Some of the Aggregate functions allowed in SAP are  MAX, MIN, AVG, SUM, COUNT, COUNT( * )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Consider the following extract.&lt;/P&gt;&lt;P&gt;            Maxno = 0.&lt;/P&gt;&lt;P&gt;            Select * from zflight where airln = &amp;#145;LF&amp;#146; and cntry = &amp;#145;IN&amp;#146;.&lt;/P&gt;&lt;P&gt;             Check zflight-fligh &amp;gt; maxno.&lt;/P&gt;&lt;P&gt;             Maxno = zflight-fligh.&lt;/P&gt;&lt;P&gt;            Endselect.&lt;/P&gt;&lt;P&gt;The  above mentioned code can be much more optimized by using the following code.&lt;/P&gt;&lt;P&gt;Select max( fligh ) from zflight into maxno where airln = &amp;#145;LF&amp;#146; and cntry = &amp;#145;IN&amp;#146;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select Statements  For All Entries&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#149;	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. &lt;/P&gt;&lt;P&gt;	The plus &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#149;	Large amount of data &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#149;	Mixing processing and reading of data &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#149;	Fast internal reprocessing of data &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#149;	Fast &lt;/P&gt;&lt;P&gt;	The Minus &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#149;	Difficult to program/understand &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;#149;	Memory could be critical (use FREE or PACKAGE size) &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Points to be must considered FOR ALL ENTRIES &lt;/P&gt;&lt;P&gt;&amp;#149;	Check that data is present in the driver table&lt;/P&gt;&lt;P&gt;&amp;#149;	Sorting the driver table &lt;/P&gt;&lt;P&gt;&amp;#149;	Removing duplicates from the driver table&lt;/P&gt;&lt;P&gt;Consider the following piece of extract&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          Loop at int_cntry.&lt;/P&gt;&lt;P&gt;  Select single * from zfligh into int_fligh&lt;/P&gt;&lt;P&gt;  where cntry = int_cntry-cntry.&lt;/P&gt;&lt;P&gt;  Append int_fligh. &lt;/P&gt;&lt;P&gt;                      Endloop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above mentioned can be more optimized by using the following code.&lt;/P&gt;&lt;P&gt;Sort int_cntry by cntry.&lt;/P&gt;&lt;P&gt;Delete adjacent duplicates from int_cntry.&lt;/P&gt;&lt;P&gt;If NOT int_cntry[] is INITIAL.&lt;/P&gt;&lt;P&gt;            Select * from zfligh appending table int_fligh&lt;/P&gt;&lt;P&gt;            For all entries in int_cntry &lt;/P&gt;&lt;P&gt;            Where cntry = int_cntry-cntry.&lt;/P&gt;&lt;P&gt;Endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Select Statements Select Over more than one Internal table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.	Its better to use a views instead of nested Select statements.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM DD01L INTO DD01L_WA&lt;/P&gt;&lt;P&gt;  WHERE DOMNAME LIKE 'CHAR%'&lt;/P&gt;&lt;P&gt;        AND AS4LOCAL = 'A'.&lt;/P&gt;&lt;P&gt;  SELECT SINGLE * FROM DD01T INTO DD01T_WA&lt;/P&gt;&lt;P&gt;    WHERE   DOMNAME    = DD01L_WA-DOMNAME&lt;/P&gt;&lt;P&gt;        AND AS4LOCAL   = 'A'&lt;/P&gt;&lt;P&gt;        AND AS4VERS    = DD01L_WA-AS4VERS&lt;/P&gt;&lt;P&gt;        AND DDLANGUAGE = SY-LANGU.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The above code can be more optimized by extracting all the data from view DD01V_WA &lt;/P&gt;&lt;P&gt;SELECT * FROM DD01V INTO  DD01V_WA&lt;/P&gt;&lt;P&gt;  WHERE DOMNAME LIKE 'CHAR%'&lt;/P&gt;&lt;P&gt;        AND DDLANGUAGE = SY-LANGU.&lt;/P&gt;&lt;P&gt;ENDSELECT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.	To read data from several logically connected tables use a join instead of nested Select statements. Joins are preferred only if all the primary key are available in WHERE clause for the tables that are joined. If the primary keys are not provided in join the Joining of tables itself takes time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT * FROM EKKO INTO EKKO_WA.&lt;/P&gt;&lt;P&gt;  SELECT * FROM EKAN INTO EKAN_WA&lt;/P&gt;&lt;P&gt;      WHERE EBELN = EKKO_WA-EBELN.&lt;/P&gt;&lt;P&gt;  ENDSELECT.&lt;/P&gt;&lt;P&gt;ENDSELECT.&lt;/P&gt;&lt;P&gt;The above code can be much more optimized by the code written below.&lt;/P&gt;&lt;P&gt;SELECT P&lt;SUB&gt;F1 P&lt;/SUB&gt;F2 F&lt;SUB&gt;F3 F&lt;/SUB&gt;F4 INTO TABLE ITAB&lt;/P&gt;&lt;P&gt;    FROM EKKO AS P INNER JOIN EKAN AS F&lt;/P&gt;&lt;P&gt;      ON P&lt;SUB&gt;EBELN = F&lt;/SUB&gt;EBELN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3.	Instead of using nested Select loops it is often better to use subqueries. &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;SELECT * FROM SPFLI&lt;/P&gt;&lt;P&gt;  INTO TABLE T_SPFLI&lt;/P&gt;&lt;P&gt;  WHERE CITYFROM = 'FRANKFURT'&lt;/P&gt;&lt;P&gt;    AND CITYTO = 'NEW YORK'.&lt;/P&gt;&lt;P&gt;SELECT * FROM SFLIGHT AS F&lt;/P&gt;&lt;P&gt;    INTO SFLIGHT_WA&lt;/P&gt;&lt;P&gt;    FOR ALL ENTRIES IN T_SPFLI&lt;/P&gt;&lt;P&gt;    WHERE SEATSOCC -FLAG = 'X'.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt; The above code works faster as compared to&lt;/P&gt;&lt;P&gt;LOOP AT ITAB INTO WA.&lt;/P&gt;&lt;P&gt;  I = SY-TABIX MOD 2.&lt;/P&gt;&lt;P&gt;  IF I = 0.&lt;/P&gt;&lt;P&gt;    WA-FLAG = 'X'.&lt;/P&gt;&lt;P&gt;    MODIFY ITAB FROM WA.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;8.    If collect semantics is required, it is always better to use to COLLECT rather than READ BINARY and then ADD.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT ITAB1 INTO WA1.&lt;/P&gt;&lt;P&gt;  READ TABLE ITAB2 INTO WA2 WITH KEY K = WA1-K BINARY SEARCH.&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;    ADD: WA1-VAL1 TO WA2-VAL1,&lt;/P&gt;&lt;P&gt;         WA1-VAL2 TO WA2-VAL2.&lt;/P&gt;&lt;P&gt;    MODIFY ITAB2 FROM WA2 INDEX SY-TABIX TRANSPORTING VAL1 VAL2.&lt;/P&gt;&lt;P&gt;  ELSE.&lt;/P&gt;&lt;P&gt;    INSERT WA1 INTO ITAB2 INDEX SY-TABIX.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;The above code uses BINARY SEARCH for collect semantics. READ BINARY runs in O( log2(n) ) time. The above piece of code can be more optimized by&lt;/P&gt;&lt;P&gt;LOOP AT ITAB1 INTO WA.&lt;/P&gt;&lt;P&gt;  COLLECT WA INTO ITAB2.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;SORT ITAB2 BY K.&lt;/P&gt;&lt;P&gt;COLLECT, however, uses a hash algorithm and is therefore independent &lt;/P&gt;&lt;P&gt;of the number of entries (i.e. O(1)) .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;9.    "APPEND LINES OF itab1 TO itab2" accelerates the task of appending a table to another table considerably as compared to &amp;#147; LOOP-APPEND-ENDLOOP.&amp;#148; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;APPEND LINES OF ITAB1 TO ITAB2.&lt;/P&gt;&lt;P&gt; This is more optimized as compared to&lt;/P&gt;&lt;P&gt;LOOP AT ITAB1 INTO WA.&lt;/P&gt;&lt;P&gt;  APPEND WA TO ITAB2.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;10.   &amp;#147;DELETE ADJACENT DUPLICATES&amp;#147; accelerates the task of deleting duplicate entries considerably as compared to &amp;#147; READ-LOOP-DELETE-ENDLOOP&amp;#148;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE ADJACENT DUPLICATES FROM ITAB COMPARING K.&lt;/P&gt;&lt;P&gt;This is much more optimized as compared to&lt;/P&gt;&lt;P&gt;READ TABLE ITAB INDEX 1 INTO PREV_LINE.&lt;/P&gt;&lt;P&gt;LOOP AT ITAB FROM 2 INTO WA.&lt;/P&gt;&lt;P&gt;  IF WA = PREV_LINE.&lt;/P&gt;&lt;P&gt;    DELETE ITAB.&lt;/P&gt;&lt;P&gt;  ELSE.&lt;/P&gt;&lt;P&gt;    PREV_LINE = WA.&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;11.   "DELETE itab FROM ... TO ..." accelerates the task of deleting a sequence of lines considerably as compared to &amp;#147;  DO -DELETE-ENDDO&amp;#148;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE ITAB FROM 450 TO 550.&lt;/P&gt;&lt;P&gt;This is much more optimized as compared to&lt;/P&gt;&lt;P&gt;DO 101 TIMES.&lt;/P&gt;&lt;P&gt;  DELETE ITAB INDEX 450.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;12.   Copying internal tables by using &amp;#147;ITAB2[ ] = ITAB1[ ]&amp;#148; as compared to &amp;#147;LOOP-APPEND-ENDLOOP&amp;#148;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ITAB2[] = ITAB1[].&lt;/P&gt;&lt;P&gt;This is much more optimized as compared to&lt;/P&gt;&lt;P&gt;REFRESH ITAB2.&lt;/P&gt;&lt;P&gt;LOOP AT ITAB1 INTO WA.&lt;/P&gt;&lt;P&gt;  APPEND WA TO ITAB2.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;13.   Specify the sort key as restrictively as possible to run the program faster. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &amp;#147;SORT ITAB BY K.&amp;#148; makes the program runs faster as compared to &amp;#147;SORT ITAB.&amp;#148;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Internal Tables         contd&amp;#133;&lt;/P&gt;&lt;P&gt; Hashed and Sorted tables&lt;/P&gt;&lt;P&gt;1.	For single read access hashed tables are more optimized as compared to sorted tables.&lt;/P&gt;&lt;P&gt;2.	 For partial sequential access sorted tables are more optimized as compared to hashed tables&lt;/P&gt;&lt;P&gt;Hashed And Sorted Tables&lt;/P&gt;&lt;P&gt;Point # 1&lt;/P&gt;&lt;P&gt;Consider the following example where HTAB is a hashed table and STAB is a sorted table&lt;/P&gt;&lt;P&gt;DO 250 TIMES.&lt;/P&gt;&lt;P&gt;  N = 4 * SY-INDEX.&lt;/P&gt;&lt;P&gt;  READ TABLE HTAB INTO WA WITH TABLE KEY K = N.&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;    " ...&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;This runs faster for single read access as compared to the following same code for sorted table&lt;/P&gt;&lt;P&gt;DO 250 TIMES.&lt;/P&gt;&lt;P&gt;  N = 4 * SY-INDEX.&lt;/P&gt;&lt;P&gt;  READ TABLE STAB INTO WA WITH TABLE KEY K = N.&lt;/P&gt;&lt;P&gt;  IF SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;    " ...&lt;/P&gt;&lt;P&gt;  ENDIF.&lt;/P&gt;&lt;P&gt;ENDDO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Point # 2&lt;/P&gt;&lt;P&gt;Similarly for Partial Sequential access the STAB runs faster as compared to HTAB&lt;/P&gt;&lt;P&gt;LOOP AT STAB INTO WA WHERE K = SUBKEY.&lt;/P&gt;&lt;P&gt;  " ...&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;This runs faster as compared to&lt;/P&gt;&lt;P&gt;LOOP AT HTAB INTO WA WHERE K = SUBKEY.&lt;/P&gt;&lt;P&gt;  " ...&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2008 06:59:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-analyzation/m-p/3391659#M814382</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-11T06:59:44Z</dc:date>
    </item>
    <item>
      <title>Re: Performance analyzation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-analyzation/m-p/3391660#M814383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi naresh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;          thanks for your answer. could you also tell me the following things?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. what is ABAP load in SE30 analysis&lt;/P&gt;&lt;P&gt;2. for a better performance, what should be abap laod and what should be DB load.&lt;/P&gt;&lt;P&gt;3. if ABAP load is more what we have to do for bettr formance and if DB load is more what we need to do?&lt;/P&gt;&lt;P&gt;4. Also, in ST05, how can we check our SQL performance. i mean do we need to check the time its taking to execute each SQL Query?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;           thnks,&lt;/P&gt;&lt;P&gt;           santosh.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2008 10:53:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-analyzation/m-p/3391660#M814383</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-11T10:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: Performance analyzation</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/performance-analyzation/m-p/3391661#M814384</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. what is ABAP load in SE30 analysis&lt;/P&gt;&lt;P&gt;The time taken to execute the ABAP statements .. I mean&lt;/P&gt;&lt;P&gt;which doesn't hit Database ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. for a better performance, what should be abap laod and what should be DB load.&lt;/P&gt;&lt;P&gt;It all depends on the program UR executing.&lt;/P&gt;&lt;P&gt;(DB should be less)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. if ABAP load is more what we have to do for bettr formance and if DB load is more what we need to do?&lt;/P&gt;&lt;P&gt;For better performance .. load on Database should be less ..&lt;/P&gt;&lt;P&gt;If it's more try to optimize the usage of DB ..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4. Also, in ST05, how can we check our SQL performance. i mean do we need to check the time its taking to execute each SQL Query?&lt;/P&gt;&lt;P&gt;U can trace for SQL performance using SE30 itself .. &lt;/P&gt;&lt;P&gt;by clicking the Hitlist ...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Feb 2008 14:11:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/performance-analyzation/m-p/3391661#M814384</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-11T14:11:49Z</dc:date>
    </item>
  </channel>
</rss>

