‎2008 Apr 16 1:06 PM
Hi
I would like to know exclusive Performance Check tips.
SUch that the Traffic is reduced with Database server and get our required Output without much effort.
Regards
Rohini.
‎2008 Apr 16 1:08 PM
Check these out
http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm
http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_PerformanceAnalysisTools.asp
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/abapPerformanceand+Tuning&
http://www.erpgenie.com/abap/performance.htm
http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/abapPerformanceand+Tuning&
http://help.sap.com/saphelp_nw2004s/helpdata/en/c6/617cafe68c11d2b2ab080009b43351/frameset.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/d1/801f7c454211d189710000e8322d00/frameset.htm
‎2008 Apr 17 11:48 AM
Hello Rohini,
If you are looking for ABAP performance tips, then you can go to SE30 and tips and tricks there you can see abap performance examples. Also you can compare the runtime for your own code as well.
If you are looking for technical tuning potential for over all performance of the system, then please refer SAP Note 948066 that describes different transactions used for tuning the SAP system in terms of application and technical tuning of a transaction/program.
Hope this helps
Regards
Dileep
‎2008 Apr 17 11:51 AM
Hi Rohini,
Please explore SE30 as much as you can and follow these tips and tricks into your coding.
Please reward if solved.
‎2008 Apr 17 12:01 PM
Refer SAP Note 948066, did not know that you. It is an interesting list, but with too many options too less details.
I can only recommend you to read my too blogs, they offer short introductions to the two most important performance tools.
SQL trace:
/people/siegfried.boes/blog/2007/09/05/the-sql-trace-st05-150-quick-and-easy
SE30
/people/siegfried.boes/blog/2007/11/13/the-abap-runtime-trace-se30--quick-and-easy
Check the hit list of your example and work top-down. Try to improve to most expensive contributions first.
Siegfried
‎2008 Apr 17 8:48 PM
Here's a tip:
You may think this is absurd, but on th WHERE clause of a SELECT, it's not recommendable to use the OR statement
Example:
SELECT intreno condvalidto condvalidfrom
FROM vicdcond
INTO TABLE itab_vicdcond
FOR ALL ENTRIES IN itab_vicncn_aux
WHERE intreno = itab_vicncn_aux-intreno AND
(condvalidto = space OR
condvalidto >= sy-datum).
When using OR, you'll acess the database TWICE, which it's not good to performance.
It's recommendable to remove the OR statement, and use DELETE WHERE right after the SELECT.
SELECT intreno condvalidto condvalidfrom
FROM vicdcond
INTO TABLE itab_vicdcond
FOR ALL ENTRIES IN itab_vicncn_aux
WHERE intreno = itab_vicncn_aux-intreno.
IF sy-subrc = 0.
DELETE tg_vicdcond WHERE condvalidto NE space AND
condvalidto < sy-datum.
ENDIF.
Hope it helps,
Brian Gonsales
‎2008 Apr 18 8:49 AM
> It's recommendable to remove the OR statement, and use DELETE WHERE right after the SELECT.
this sounds like pure phantasy!
Definitely not recommended!
Siegfried
‎2008 Apr 18 12:01 PM
hi
The key to reduce base hits is to minimize the number of selects from the data base .just select only what is required and give as many where condition as possible.try to avoid select * statements..Please follow below doc for further details.
SAP ABAP Performance Tuning
Tips & Tricks
Introduction
Need for performance tuning
In this world of SAP programming, ABAP is the universal language. In most of the projects, the focus is on getting a team of ABAP programmers as soon as possible, handing over the technical specifications to them and asking them to churn out the ABAP programs within the given deadlines.
Often due to this pressure of schedules and deliveries, the main focus of making a efficient program takes a back seat. An efficient ABAP program is one which delivers the required output to the user in a finite time as per the complexity of the program, rather than hearing the comment I put the program to run, have my lunch and come back to check the results.
Leaving aside the hyperbole, a performance optimized ABAP program saves the time of the end user, thus increasing the productivity of the user, and in turn keeping the user and the management happy.
This tutorial focuses on presenting various performance tuning tips and tricks to make the ABAP programs efficient in doing their work. This tutorial also assumes that the reader is well versed in all the concepts and syntax of ABAP programming.
NOTE: Performance of a program is also often limited due to hardware restrictions, which is out of the scope of this article.
============================================================================
Use of selection criteria
Instead of selecting all the data and doing the processing during the selection, it is advisable to restrict the data to the selection criteria itself, rather than filtering it out using the ABAP code.
Not recommended
Select * from zflight.
Check : zflight-airln = LF and zflight-fligh = BW222.
Endselect.
Recommended
Select * from zflight where airln = LF and fligh = 222.
Endselect.
One more point to be noted here is of the select *. Often this is a lazy coding practice. When a programmer gives select * even if one or two fields are to be selected, this can significantly slow the program and put unnecessary load on the entire system. When the application server sends this request to the database server, and the database server has to pass on the entire structure for each row back to the application server. This consumes both CPU and networking resources, especially for large structures.
Thus it is advisable to select only those fields that are needed, so that the database server passes only a small amount of data back.
Also it is advisable to avoid selecting the data fields into local variables as this also puts unnecessary load on the server. Instead attempt must be made to select the fields into an internal table.
============================================================================
Use of aggregate functions
Use the already provided aggregate functions, instead of finding out the minimum/maximum values using ABAP code.
Not recommended
Maxnu = 0.
Select * from zflight where airln = LF and cntry = IN.
Check zflight-fligh > maxnu.
Maxnu = zflight-fligh.
Endselect.
Recommended
Select max( fligh ) from zflight into maxnu where airln = LF and cntry = IN.
The other aggregate functions that can be used are min (to find the minimum value), avg (to find the average of a Data interval), sum (to add up a data interval) and count (counting the lines in a data selection).
============================================================================
Use of Views instead of base tables
Many times ABAP programmers deal with base tables and nested selects. Instead it is always advisable to see whether there is any view provided by SAP on those base tables, so that the data can be filtered out directly, rather than specially coding for it.
Not recommended
Select * from zcntry where cntry like IN%.
Select single * from zflight where cntry = zcntry-cntry and airln = LF.
Endselect.
Recommended
Select * from zcnfl where cntry like IN% and airln = LF.
Endselect.
============================================================================
Use of the into table clause of select statement
Instead of appending one record at a time into an internal table, it is advisable to select all the records in a single shot.
Not recommended
Refresh: int_fligh.
Select * from zflight into int_fligh.
Append int_fligh. Clear int_fligh.
Endselect.
Recommended
Refresh: int_fligh.
Select * from zflight into table int_fligh.
============================================================================
Modifying a group of lines of an internal table
Use the variations of the modify command to speed up this kind of processing.
Not recommended
Loop at int_fligh.
If int_fligh-flag is initial.
Int_fligh-flag = X.
Endif.
Modify int_fligh.
Endloop.
Recommended
Int_fligh-flag = X.
Modify int_fligh transporting flag where flag is initial.
============================================================================
Use of binary search option
When a programmer uses the read command, the table is sequentially searched. This slows down the processing. Instead of this, use the binary search addition. The binary search algorithm helps faster search of a value in an internal table. It is advisable to sort the internal table before doing a binary search. Binary search repeatedly divides the search interval in half. If the value to be searched is less than the item in the middle of the interval, the search is narrowed to the lower half, otherwise the search is narrowed to the upper half.
Not Recommended
Read table int_fligh with key airln = LF.
Recommended
Read table int_fligh with key airln = LF binary search.
============================================================================
Appending 2 internal tables
Instead of using the normal loop-endloop approach for this kind of programming, use the variation of the append command. Care should be taken that the definition of both the internal tables should be identical.
Not Recommended
Loop at int_fligh1.
Append int_fligh1 to int_fligh2.
Endloop.
Recommended
Append lines of int_fligh1 to int_fligh2.
============================================================================
Using table buffering
Use of buffered tables is recommended to improve the performance considerably. The buffer is bypassed while using the following statements
1. Select distinct
2. Select for update
3. Order by, group by, having clause
4. Joins
Use the Bypass buffer addition to the select clause in order to explicitly bypass the buffer while selecting the data.
============================================================================
Use of FOR ALL Entries
Outer join can be created using this addition to the where clause in a select statement. It speeds up the performance tremendously, but the cons of using this variation are listed below
1. Duplicates are automatically removed from the resulting data set. Hence care should be taken that the unique key of the detail line items should be given in the select statement.
2. If the table on which the For All Entries IN clause is based is empty, all rows are selected into the destination table. Hence it is advisable to check before-hand that the first table is not empty.
3. If the table on which the For All Entries IN clause is based is very large, the performance will go down instead of improving. Hence attempt should be made to keep the table size to a moderate level.
Not Recommended
Loop at int_cntry.
Select single * from zfligh into int_fligh
where cntry = int_cntry-cntry.
Append int_fligh.
Endloop.
Recommended
Select * from zfligh appending table int_fligh
For all entries in int_cntry
Where cntry = int_cntry-cntry.
============================================================================
Structure of Where Clause
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.
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. One more tip is that if a table begins with MANDT, while an index does not, there is a high possibility that the optimizer might not use that index.
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.
============================================================================
Proper use of Move statement
Instead of using the move-corresponding clause it is advisable to use the move statement instead. Attempt should be made to move entire internal table headers in a single shot, rather than moving the fields one by one.
============================================================================
Proper use of Inner Join
When multiple SAP tables are logically joined, it is always advisable to use inner join to read the data from them. This certainly reduces the load on the network.
Let us take an example of 2 tables, zairln and zflight. The table zairln has the field airln, which is the airline code and the field lnnam, which is the name of the airline. The table zflight has the field airln, the airline code and other fields which hold the details of the flights that an airline operates.
Since these 2 tables a re logically joined by the airln field, it is advisable to use the inner join.
Select aairln alnnam bfligh bcntry into table int_airdet
From zairln as a inner join zflight as b on aairln = bairln.
In order to restrict the data as per the selection criteria, a where clause can be added to the above inner join.
============================================================================
Use of ABAP Sort instead of Order By
The order by clause is executed on the database server, while the sort statement is executed on the application server. Thus instead of giving the order by in the select clause statement, it is better to collect the records in an internal table and then use the sort command to sort the resulting data set.
============================================================================
Tools provided for Performance Analysis
Following are the different tools provided by SAP for performance analysis of an ABAP object
1. Run time analysis transaction SE30
This transaction gives all the analysis of an ABAP program with respect to the database and the non-database processing.
2. SQL Trace transaction ST05
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.
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 the SPFLI table in our test program is mapped to a sequence PREPARE-OPEN-FETCH of physical calls in an Oracle environment.
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.
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.
============================================================================
Regards,
Avik
‎2008 Apr 22 10:16 AM
This are the performance tips which you can use to improve the performance of the program.
ABAP provides few tools to analyse the perfomance of the objects, which was developed by us.
Run time analysis transaction SE30
This transaction gives all the analysis of an ABAP program with respect to the database and the non-database processing.
SQL Trace transaction ST05
by using this tool we can analyse the perfomance issues related to DATABASE calls.
Perfomance Techniques for improve the perfomance of the object.
1) ABAP/4 programs can take a very long time to execute, and can make other processes have to wait before executing. Here are some tips to speed up your programs and reduce the load your programs put on the system:
2) Use the GET RUN TIME command to help evaluate performance. It's hard to know whether that optimization technique REALLY helps unless you test it out.
3) Using this tool can help you know what is effective, under what kinds of conditions. The GET RUN TIME has problems under multiple CPUs, so you should use it to test small pieces of your program, rather than the whole program.
4) Generally, try to reduce I/O first, then memory, then CPU activity. I/O operations that read/write to hard disk are always the most expensive operations. Memory, if not controlled, may have to be written to swap space on the hard disk, which therefore increases your I/O read/writes to disk. CPU activity can be reduced by careful program design, and by using commands such as SUM (SQL) and COLLECT (ABAP/4).
5) Avoid 'SELECT *', especially in tables that have a lot of fields. Use SELECT A B C INTO instead, so that fields are only read if they are used. This can make a very big difference.
6) Field-groups can be useful for multi-level sorting and displaying. However, they write their data to the system's paging space, rather than to memory (internal tables use memory). For this reason, field-groups are only appropriate for processing large lists (e.g. over 50,000 records). If you have large lists, you should work with the systems administrator to decide the maximum amount of RAM your program should use, and from that, calculate how much space your lists will use. Then you can decide whether to write the data to memory or swap space.
Use as many table keys as possible in the WHERE part of your select statements.
7)Whenever possible, design the program to access a relatively constant number of records (for instance, if you only access the transactions for one month, then there probably will be a reasonable range, like 1200-1800, for the number of transactions inputted within that month). Then use a SELECT A B C INTO TABLE ITAB statement.
😎 Get a good idea of how many records you will be accessing. Log into your productive system, and use SE80 -> Dictionary Objects (press Edit), enter the table name you want to see, and press Display. Go To Utilities -> Table Contents to query the table contents and see the number of records. This is extremely useful in optimizing a program's memory allocation.
9) Try to make the user interface such that the program gradually unfolds more information to the user, rather than giving a huge list of information all at once to the user.
10) Declare your internal tables using OCCURS NUM_RECS, where NUM_RECS is the number of records you expect to be accessing. If the number of records exceeds NUM_RECS, the data will be kept in swap space (not memory).
11) Use SELECT A B C INTO TABLE ITAB whenever possible. This will read all of the records into the itab in one operation, rather than repeated operations that result from a SELECT A B C INTO ITAB... ENDSELECT statement. Make sure that ITAB is declared with OCCURS NUM_RECS, where NUM_RECS is the number of records you expect to access.
12) If the number of records you are reading is constantly growing, you may be able to break it into chunks of relatively constant size. For instance, if you have to read all records from 1991 to present, you can break it into quarters, and read all records one quarter at a time. This will reduce I/O operations. Test extensively with GET RUN TIME when using this method.
13) Know how to use the 'collect' command. It can be very efficient.
14) Use the SELECT SINGLE command whenever possible.
15) Many tables contain totals fields (such as monthly expense totals). Use these avoid wasting resources by calculating a total that has already been calculated and stored.
Some tips:
1) Use joins where possible as redundant data is not fetched.
2) Use select single where ever possible.
3) Calling methods of a global class is faster than calling function modules.
4) Use constants instead of literals
5) Use WHILE instead of a DO-EXIT-ENDDO.
6) Unnecessary MOVEs should be avoided by using the explicit work area operations
see the follwing links for a brief insifght into performance tuning,
http://www.thespot4sap.com/Articles/SAPABAPPerformanceTuning_Introduction.asp
1. Debuggerhttp://help.sap.com/saphelp_47x200/helpdata/en/c6/617ca9e68c11d2b2ab080009b43351/content.htm
2. Run Time Analyser
http://help.sap.com/saphelp_47x200/helpdata/en/c6/617cafe68c11d2b2ab080009b43351/content.htm
3. SQL trace
http://help.sap.com/saphelp_47x200/helpdata/en/d1/801f7c454211d189710000e8322d00/content.htm
4 Runtime Monitor
http://help.sap.com/saphelp_47x200/helpdata/en/b5/fa121cc15911d5993d00508b6b8b11/content.htm
5. Memory Inspector
http://help.sap.com/saphelp_47x200/helpdata/en/a2/e5fc84cc87964cb2c29f584152d74e/content.htm
Performance tuning for Data Selection Statement
http://www.sap-img.com/abap/performance-tuning-for-data-selection-statement.htm
Reward if helps.
‎2008 Apr 30 9:59 AM
Hi Evry body,
Thanks all for the Tips. ( Some new Some Old) but finally refreshed.
But Brian Gonsales Tip made me think weird.When analysed it was great.
Points rewarded for you Brian Gonsales .
Good Work evrybody
Rohini.
‎2008 May 02 7:41 AM
Hi,
These are some of the tips regarding performance standards. Hope this will be useful...
Run Extended syntax checks with character literals checkbox switched on & Code Inspector to rectify all relevant errors and warning (e.g. Use the results of the above checks to remove all variables/constants etc that are declared but are not used)
Transaction SE30 (ABAP Runtime Analysis) must be checked to measure/compare program performance/runtime if program has multiple inefficient databases selects or complicated internal table operations
Use transaction ST05 (SQL Trace) to see what indices your database accesses are using. Check these indices against your where clause to assure they are significant. Check other indices for this table and where you have to change your where clause to use it. Create new indices if necessary, but do not forget to check the impact by consulting onsite coordinator.
TYPE (data element) command is used while declaring the fields whenever feasible instead of LIKE. Remember not always the data element name matches with the table field name
Internal Table is defined with TYPE STANDARD TABLE OF & Work-Areas is used instead of header lines
Global variables are minimized by declaring local variables or by passing variables through parameters & arguments while creating internal subroutine(s)
In SELECT statement, only the required fields are selected in the same order as they reside on the database table/structure/view
For selecting single row from a database table, SELECT UP to 1 Rows is used. Select Single is used only when full primary key combination is known
No SELECT * is used
Use SELECT INTO TABLE rather than SELECT INTO CORRESPONDING FIELDS OF TABLE
Always specify as many primary keys as possible in WHERE clause to make the Select efficient
Always select into an internal table, except when the table will be very large (i.e., when the internal table will be greater than 500,000 records). Use Up to N Rows when the number of records needed is known
Select statement within a GET event is not used
Wild cards like A% is avoided as much as possible
Nested Select is not used instead Inner Join and/or For all Entries is used. For all Entries is to be used over Loop at ITAB / Select / ENDLOOP (FOR ALL ENTRIES retrieves a unique result set so ensure you retrieve the full key from the database)
When creating joins over database tables there should be an index at least on the inner table for the fields in the join condition else use FOR ALL ENTRIES select statement
Usage of JOIN is limited to a maximum of 2 i.e. not more than 3 database tables are joined at one time
CHECK that the internal table used in FOR ALL ENTRIES is NOT empty as this will retrieve all entries from the table
Delete adjacent duplicate entries from internal table before selection from database table using FOR ALL ENTRIES statement
For copying internal tables use = operator instead of Looping & Appending
SORT inside a LOOP is not used
Sort internal table by fields in the correct order, which are used in a READ TABLE statement using BINARY SEARCH. If the order of sorting is invalid the BINARY SEARCH will never work
For large internal tables where only some rows are to be processed, use SORT and then the READ TABLE command is used to set index to first relevant row before looping from that index. Use CHECK or IF EXIT ENDIF as appropriate to exit from the loop
Sort fields and Sort Order on the SORT statement should be mentioned explicitly (e.g. SORT ITAB BY FLD1 FLD2 ASCENDING)
Hashed table is used for processing large amount of data (provided that you access single records only, and all with a fully specified key)
DELETE or SORT is not used on a hashed table since it increases memory consumption
Sorted table is used for range accesses involving table key or index accesses
Fields specified in the WHERE condition with the critical operators NOT and <> (negative SQL statements) cannot be used for a search using database indexes. Whenever possible formulate SQL statements positively
When coding IF or CASE, testing conditions are nested so that the most frequently true conditions are processed first. Also CASE is used instead of IF when testing multiple fields equal to something
LOOP AT ITAB INTO WORKAREA WHERE K = XXX should be used instead of LOOP AT ITAB INTO WORKAREA / CHECK ITAB-K = XXX.
Also READ TABLE INTO WORKAREA should be used instead of only READ TABLE.
After the APPEND statement inside a loop, the work area that has been appended is cleared
Internal tables, Work areas & Global Variables are freed when no longer needed (e.g. using the FREE / REFRESH command), especially when the tables are large or the program is a batch program
Do not delete the records of internal table inside the Loop End loop.
Do not use: LOOP AT ITAB WHERE EQUNR = 00001011.
DELETE ITAB.
ENDLOOP.
Use: DELETE ITAB WHERE EQUNR = 00001011.
Use the MODIFY ITAB ... TRANSPORTING f1 f2 ... for single line, and MODIFY ITAB ... TRANSPORTING f1 f2 ... WHERE condition for a set of line, to accelerate the updating of internal table
If possible, Update/Insert statement is used instead of Modify
Is the following steps ensured during database updates?
Lock data to be edited
Read current data from the database
Process data and write it to the database
Release the locks set at the beginning
Try to avoid logical databases. If your program uses a logical database, but does not require all fields belonging to a certain GET event, always use the FIELDS addition to reduce the amount of data selected by the logical database
Avoid the aggregate (Count, Max, Min) functions in the database selection
Use Parallel Cursor methods for nested loop into the internal tables if second internal table contains considerable number of records
In Smartform/ Sapscript do not make redundant data retrieval where data is available in interface