You are on page 1of 6

11/9/2016

GeneralPerformanceAdviceforSAPABAPOpenSQL

SAPPractical.com

Home (/home/)

SAP Exam (/sap/index)

Hello Guest! (/home/login)

SAP Technical (/sap/saptech)


http://www.sappractical.com/home/blogd/generalperformanceadviceforsapabapopensql/

1/6

11/9/2016

GeneralPerformanceAdviceforSAPABAPOpenSQL

SAP Functional (/sap/sapfun)

Blogs (/home/blogs)

Production Issues (/home...

Index (/home/indexs)

Login (/home/login)

Registration (/home/regis...

General Performance Advice for


SAP ABAP Open SQL
(/home/blogd/generalperformance-advice-for-sap-abapopen-sql-/)
- in ABAP (/home/blog/ABAP)

2/1/2016 5:20:59 PM

General Performance Advice for Open SQL - This blog will gives about
performance tuning in ABAP programming. How to optimize your
ABAP SQL? Tips and tricks for select queries. Deducting expensive
SQL for a transaction which can be either custom or standard
transaction. ABAP SQL performance tuning is one of the challenging
area. I am sure below the contents will be a basic for ABAP beginners.
Keep the database hit list small
Wherever possible, you should include all selection conditions in the
WHERE clause, using AND and checking for equality. Do not select a
large dataset and then check it with CHECK. If you want to read the
whole table, you do not have to specify a WHERE condition at all.
Transfer small amounts of data
If you only want to transfer a few elds, use SELECT with a structure,
not SELECT *. Alternatively, you can use one of the views in the ABAP
Dictionary to select data.

SAPPractical.com

Home (/home/)

SAP Exam (/sap/index)

Use
the aggregate
functions rather than selecting data and grouping
it
Hello
Guest! (/home/login)
yourself. SAP buffering is switched off when you use aggregate
functions.

When you UPDATE a database record, you should only update those
columns that have been changed.
http://www.sappractical.com/home/blogd/generalperformanceadviceforsapabapopensql/
SAP Technical (/sap/saptech)

2/6

11/9/2016

GeneralPerformanceAdviceforSAPABAPOpenSQL

columns that have been changed.


SAP Functional (/sap/sapfun)

Use a small number of database accesses

Blogs (/home/blogs)

Production Issues (/home...

When you INSERT, UPDATE or DELETE, you should use sets of data
instead of individual table entries. This ensures that the index only has
to be maintained once, which relieves the load on the database.

Index (/home/indexs)

You should only use nested SELECT loops when the hit list in the
outermost level is very small.

Login (/home/login)

There are various ways of avoiding nested SELECT loops:

Registration (/home/regis...

Building a JOIN in the FROM clause


Joins as views de ned in the ABAP Dictionary.
SELECT ... FOR ALL ENTRIES
In the outermost loop, the database table (PACKAGE SIZE) is read
section-by-section into an internal table, sorted by its primary key
(SORT on the internal table, or read in using ORDER BY PRIMARY
KEY). For each data record in the internal table, all associated,
dependent records are read into a further internal table (using
SELECT ... FOR ALL ENTRIES). This is also sorted. You can then carry
on processing using a nested LOOP.
The advantage of SELECT ... FOR ALL ENTRIES is that it provides good
performance regardless of the selectivity of the condition on the
outermost table, since, in contrast to the nested SELECT, it works in a
data-oriented way in the database, but still only picks out the relevant
database entries (different to parallel cursor processing).
You should use the addition FOR ALL ENTRIES if a JOIN is not possible
for syntactical reasons or if the JOIN would result in high redundancy
due to the constantly repeated elds from the left table.
Explicit cursor handling (OPEN CURSOR [WITH HOLD]...)
In this processing type, a separate cursor is opened for each table
involved. These are processed in parallel. In order for the system to
recognize control breaks, the tables must be sorted (ORDER BY
PRIMARY KEY) before being read. You should only use parallel cursor
processing when you want to process the outermost table completely
or to a large extent, since WHERE conditions for the outermost table
cannot be passed on to other tables (in other words, you might read
more data than is necessary).
Hello Guest! (/home/login)

Caution: RANGES tables

SAPPractical.com

Home (/home/)

SAP Exam (/sap/index)

SAP Technical (/sap/saptech)

You should use explicit cursor handling for large quantities of data and
logical databases.
Search through small amounts of dataIn WHERE conditions, you

http://www.sappractical.com/home/blogd/generalperformanceadviceforsapabapopensql/

3/6

11/9/2016

GeneralPerformanceAdviceforSAPABAPOpenSQL

Search through small amounts of dataIn WHERE conditions, you


should use EQ comparisons linked with AND as often as possible. This
means that the system can use indexes in the search.

SAP Functional (/sap/sapfun)

Blogs (/home/blogs)

Production Issues (/home...

Index (/home/indexs)

Login (/home/login)

Registration (/home/regis...

NOT, OR and IN are not supported by indexes unless all of the elds in
the SELECT clause and WHERE condition are also contained in the
index.
Reduce the database load wherever possible
Saving database in local buffers (see SAP buffering) can save
considerable time in client-server environments, as the access time via
the network is considerably higher than access time via a locally
buffered table.

The SAP buffering is switched off:


When you use SELECT FOR UPDATE or SELECT DISTINCT in the
SELECT clause,
When you use BYPASSING BUFFER in the FROM clause,
When you use JOINs and subqueries (subqueries),
When you use ORDER BY f1 f2 ... in the ORDER-BY clause.
When you use aggregate functions in the SELECT clause.
When you use IS [NOT] NULL in the WHERE condition.
You cannot process a query in the SAP buffer if the generic key section
is not speci ed in the WHERE condition
Avoid re-reading the same data.
Before you change a table using DELETE, INSERT or UPDATE, you
should check whether you need to read entries using SELECT.
If you want to sort data, it is more ef cient to read it into the internal
table and sort it using SORT than to use the ORDER-BY clause, where
the sort is not supported by an index.
Check whether you can delete duplicates using the variant DELETE
ADJACENT DUPLICATES FROM itab instead of using SELECT
DISTINCT.
You should use logical databases if possible.

SAPPractical.com

Strings in database tables

Home (/home/)

SAP Exam (/sap/index)

SAP Technical (/sap/saptech)

Data
in long
strings
is stored outside the dataset, which means that it
Hello
Guest!
(/home/login)
takes longer to access long strings than to access other data types.
This applies in particular to set operations, and does not apply for
short strings. Next blog will give about how to get trace and analyse
further.

http://www.sappractical.com/home/blogd/generalperformanceadviceforsapabapopensql/

4/6

11/9/2016

GeneralPerformanceAdviceforSAPABAPOpenSQL
further.

If you like this blog, please share (Facebook/LinkedIn/Google+) to click


below links so it will reach to others.

SAP Functional (/sap/sapfun)

Blogs (/home/blogs)

Production Issues (/home...

Index (/home/indexs)

Login (/home/login)

Registration (/home/regis...

COMMENTS

sarika sonu -2/19/2016 12:33:59 PM


Good post.....!

LEAVE A COMMENT

Your name
Your email address

Calibri

15

Submit comment

SAPPractical.com

Home (/home/)

SAP Exam (/sap/index)

RECENT POSTS

Hello
Guest! or
(/home/login)

How
to create
generate a test inbound queue in sap
(/home/blogd/how-to-create-or-generate-a-test-inbound-queuein-sap/)

8/13/2016 12:17:40 AM

SAP Technical (/sap/saptech)

SQL Performance Monitoring-SAP SQLM Part3 (/home/blogd/sql- 5/6


http://www.sappractical.com/home/blogd/generalperformanceadviceforsapabapopensql/

11/9/2016

GeneralPerformanceAdviceforSAPABAPOpenSQL

SQL Performance Monitoring-SAP SQLM Part3 (/home/blogd/sqlperformance-monitoring-sap-sqlm-part3/)

SAP Functional (/sap/sapfun)

5/26/2016 11:22:26 AM

Blogs (/home/blogs)

Production Issues (/home...

Index (/home/indexs)

Login (/home/login)

Registration (/home/regis...

SQL Performance Monitoring-SAP SQLM Part2 (/home/blogd/sqlperformance-monitoring-sap-sqlm-part2/)


5/25/2016 3:18:27 PM

SQL Performance Monitoring-SAP SQLM PART1


(/home/blogd/sql-performance-monitoring-sap-sqlm-part1/)
4/25/2016 2:29:32 PM

How to implement SAP ABAP eld exit (/home/blogd/how-toimplement-sap-abap- eld-exit/)


4/23/2016 10:03:20 PM

Share & Follow

(https://www.facebook.com/sappractical/)

(http://www.SAPPracticalCom.blogspot.com)

(https://plus.google.com/b/115103102431089818132)

(https://twitter.com/sap_practical)
About Us (/home/aboutus)

Contact Us (/home/contactus)

Terms & Privacy (/home/termofuse)


Testimonial (/home/testimonial)
www.sappractical.com. All rights reserved.
All trademarks, service marks, trade names, trade dress, product names and logos
appearing on the site are the property of their respective owners.
The site www.sappractical.com is in no way af liated with SAP SE. Copyright
2016

http://www.sappractical.com/home/blogd/generalperformanceadviceforsapabapopensql/

6/6

You might also like