ABAP Performance (2)

66
¥ / 1 Optimize Database Access From ABAP QL

Transcript of ABAP Performance (2)

Page 1: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 1/66

Page 2: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 2/66

¥ / 2

Copyright

Please note:

No part of this Training Session may be reproduced or 

transmitted in any form or by any means, electronic or 

mechanical, including photocopying, recording, or 

information storage and retrieval systems, for any purpose

without the express written permission of SAP America.

© SAP America, 2000. All rights reserved.

SAP Virtual Classroom is a registered trademark of SAP

 America.

Page 3: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 3/66

¥ / 3

Course Objectives

At the conclusion of this course, you will know:

Five Rules for Writing an ABAP Program with Efficient Database

 Access.

Performance Check List.

Page 4: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 4/66

¥ / 4

SQL

Performance of Business Transactions

R/3 and DBMS Architecture

Efficient Database Programming in ABAP

ABAP Open SQL Overview

Page 5: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 5/66

¥ / 5

General rule:

The performance of a business transaction is primarily

determined by its DB accesses.

DB

Application

GUI

Performance of Business Transactions

Page 6: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 6/66

¥ / 6

SQL

Performance of Business Transactions

R/3 and DBMS Architecture

Efficient Database Programming in ABAP

ABAP Open SQL Overview

Page 7: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 7/66

¥ / 7

R/3 Architecture

Central DB

(stores all data andapplication programs)

Application server 

Communication

from / to user 

Data transfer between database

and application server 

Presentation server (workstation)

Database server 

DBMS

processesDB

cache

...Local

data

WP

Page 8: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 8/66

¥ / 8

Rule-based

Cost-based

Execution plan

The Optimizer 

Page 9: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 9/66

¥ / 9

SQL

Performance of Business Transactions

R/3 and DBMS Architecture

Efficient Database Programming in ABAP

ABAP Open SQL Overview

Page 10: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 10/66

¥ / 10

ABAP SQL

Open SQL Native SQL

DB interface

Embedded SQL

SQL

Database

Page 11: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 11/66

¥ / 11

SELECT field1 field2 field3 field4

FROM ( table1 INNER JOIN table2 ON

table1~field1 = table2~field1 )

WHERE ... AND field1 IN ('A','B','C') AND field3 LIKE 'T%'

SELECT

clause

WHERE clause

FROM clause

Search area

Data to be transferred

Relevant data

- the hit list

One or more tables

Data to be searched -

only limited by index access

Solution Set of a SQL Command

Page 12: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 12/66

¥ / 12

SQL

Performance of Business Transactions

R/3 and DBMS Architecture

Efficient Database Programming in ABAP

ABAP Open SQL Overview

Page 13: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 13/66

¥ / 13

5 Rules

Should be as independent of 

the DBMS as possible

Rules for Open SQL Programming

Page 14: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 14/66

¥ / 14

Rule 1:

Keep the hit list small

Keep the Hit List Small

Page 15: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 15/66

¥ / 15

Use a WHERE clause wherever possible

SELECT * FROM sflight INTO wa.CHECK wa-fldate(4) = ´1998´. WRITE: / wa-carrid,

 wa-connid, ...

ENDSELECT.

SELECT * FROM sflight INTO wa WHERE fldate LIKE ´1998%´.

 WRITE: / wa-carrid,

 wa-connid, ...ENDSELECT.

Use instead

Performance SELECT * ... CHECK. ENDSELECT. 300,000 msec (for 400 recs.)

advantage: SELECT ... WHERE. 3,700 msec

Keep the Hit List Small

Page 16: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 16/66

¥ / 16

R/3 work processR/3 work process

DB work process DB work process

Database cacheDatabase

Service

processes

Operating system

Database files

R/3 work process

DB work process

Network

communication

DB CPUconsumption

DB memory

consumption

Physical I /O

Effects of Rule 1

Page 17: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 17/66

¥ / 17

Rule 2:Keep the set of data to be

transferred between the database

and the application small

Keep the Transferred Dataset Small

Page 18: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 18/66

¥ / 18

Keep the Transferred Dataset Small

SELECT * FROM sbookINTO wa WHERE carrid NE 'BA'.

 WRITE: / wa-customid, wa-class.ENDSELECT.

SELECT customid class FROM sbookINTO (wa-customid, wa-class) WHERE carrid NE 'BA'.

 WRITE: / wa-customid, wa-class.ENDSELECT.

Performance SELECT column... . ENDSELECT. 2.2 sec (for 21500 records)

advantage: SELECT * ... ENDSELECT. 6.7 sec

Field list vs. SELECT *

Use instead

Page 19: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 19/66

Page 20: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 20/66

¥ / 20

SELEC

T * FROM SBOOKREPORT XYZ

Data transfer from DBserver to appl. server 

10000 SBOOK records each

with 97 bytes required

30 transfers of 

32K packages from the DB server 

to the appl. server 

Report result

Appl.

server 

Data-

base

server 

Appl.

server 

Keep the Transferred Dataset Small

Data transfer 

Page 21: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 21/66

¥ / 21

SELECT column1 .. FROM SBOOK

REPORT XYZ

10.000 SBOOK records

each with 9 bytes required

3 transfers of 

32K packages from the DB

server to the appl. server 

Data transfer of DB

server to appl. server 

Report result

Data-

base

server 

Appl.

server 

Appl.

server 

Keep the Transferred Dataset Small

Data transfer 

Page 22: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 22/66

¥ / 22

Referencing of table fields

Instead of this, use:

SELECT * FROM sflightINTO wa WHERE carrid ='LH'.

 wa-seatsocc = wa-seatsocc + 1.UPDATE sflight FROM wa.

ENDSELECT.

UPDATE sflight SET seatsocc = seatsocc + 1 WHERE carrid = 'LH'.

Performance advantage: SELECT * ... ENDSELECT. 500.000 ms (for 100 records)

UPDATE ... SET ... 56.700 ms

Keep the Transferred Dataset Small

Page 23: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 23/66

Page 24: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 24/66

¥ / 24

Databases can calculate roundings in a different manner to the

ABAP runtime system.

Databases can recognize the NULL value, ABAP cannot.

AVG (1, 3, 0, 0) = 1

AVG (1, 3, NULL, NULL) = 2

Select the right data type for the target field.

For AVG

use data type 'F' (Floating Point). For SUM use a data type which is large enough to incorporate the

total so as to avoid an overflow of figures.

Aggregate functions ± proceed with care

Keep the Transferred Dataset Small

Page 25: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 25/66

¥ / 25

The "Having" clause

SELECT carrid connid fldate MAX( luggweight )

INTO (carrid, connid, fldate, max)FROM sbookGROUP BY carrid connid fldateHAVING MAX( luggweight ) > 20.

 WRITE: / carrid, connid, fldate, max.ENDSELECT.

SELECT carrid connid fldate MAX( luggweight )INTO (carrid, connid, fldate, max)FROM sbook

GROUP BY carrid connid fldate.CHECK max > 20. WRITE: / carrid, connid, fldate, max.

ENDSELECT.

Keep the Transferred Dataset Small

Page 26: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 26/66

¥ / 26

R/3 work processR/3 work process

DB work process DB work process

Database cacheDatabase

Service

processes

Operating system

Database files

R/3 work process

DB work process

Network

communication

DB CPUconsumption

DB memory

consumption

Physical I /O

Effects of Rule 2

Page 27: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 27/66

¥ / 27

Rule 3:

Keep the number of roundtripsbetween the database

and application small

Keep the Number of Roundtrips Small

Page 28: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 28/66

¥ / 28

LOOP AT itab.INSERT INTO dbtab VALUES itab.

ENDLOOP.

INSERT dbtab FROM TABLE itab.

Instead of this, use:

* If double lines can appear:

INSERT dbtab FROM TABLE itab

 ACCEPTING DUPLICATE KEYS.IF sy-subrc = 4.

... Error handling ...ENDIF.

Array operations ± for example, with INSERT

Keep the Number of Roundtrips Small

Page 29: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 29/66

¥ / 29

JOINs implemented as views

in the ABAP Dictionary

JOINs in ABAP Open SQL

SELECT ... FOR ALL ENTRIES

SELECT * FROM t1 WHERE ...

SELECT * FROM t2 WHERE ...

SELECT * FROM t3 WHERE ...

SELECT * FROM t4 WHERE ...

SELECT * FROM t5 WHERE ...

...

ENDSELECT.

ENDSELECT.

ENDSELECT.

SELECT * FROM t6 WHERE ...

SELECT * FROM t7 WHERE ...

SELECT * FROM t8 WHERE ...

...

ENDSELECT.

ENDSELECT.

ENDSELECT.

ENDSELECT.

ENDSELECT.

Avoid multi-way SELECTs

Keep the Number of Roundtrips Small

Page 30: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 30/66

¥ / 30

View in the ABAP DictionarySELECT * FROM sflight.

SELECT * FROM sbook WHERE carrid = sflight-carrid 

 AND connid = sflight-connid  AND fldate = sflight-fldate.

IF SY_SUBRC NE 0.

 WRITE: sbook-carrid, sbook-bookid,...ENDIF.

ENDSELECT.ENDSELECT.

SELECT * FROM sflightsbookview.* View im ABAP-Dictionary WRITE: / sflightsbookview-price,

sflightsbookview-paymentsum, ...ENDSELECT.

Instead of this, use:

Keep the Number of Roundtrips Small

Page 31: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 31/66

¥ / 31

SELECT f~carrid f~connid b~bookid INTO (carrid, connid, bookid)FROM sflight AS f INNER JOIN sbook AS b

ON f~carrid = b~carrid AND f~connid = b~connid  AND f~fldate = b~fldate.

 WRITE: / carrid, connid, bookid.ENDSELECT.

INNER JOIN in the FROM clause

SELECT * FROM sflight INTO wa_sflight.SELECT * FROM sbook INTO wa_sbook

 WHERE carrid = wa_sflight-carrid  AND connid = wa_sflight-connid  AND fldate = wa_sflight-fldate.

 WRITE: / wa_sflight-carrid, wa_sflight-connid,

 wa_sbook-bookid.ENDSELECT.

ENDSELECT.

Instead of this, use:

Keep the Number of Roundtrips Small

Page 32: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 32/66

¥ / 32

Inner Join

AA

LH

LHQF

...

SFLIGHT:

CARRID CONNID ... DISTANCE

SBOOK:

CARRID CONNID ... BOOKID

Join operator 

AA 0017 2.572 AA 0017 1

AA 0017 2.572 AA 0017 2

Join result table on the database

CARRID CONNID ... DISTANCE CARRID CONNID ... BOOKID

QF 0598 1.689 QF 0598 10

0017

0400

04020598

...

2.572

6.658

3.1621.689

...

AA

AA

AAQF

...

0017

0017

00180598

...

1

2

1710

...

Please note:The resulting quantity

does not contain any

entries for the airline

company LH.

Keep the Number of Roundtrips Small

Page 33: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 33/66

¥ / 33

SELECT f~carrid f~connid f~fldate b~bookid INTO (carrid, connid, fldate, bookid)FROM sflight AS f LEFT OUTER sbook AS b

ON f~carrid = b~carrid AND f~connid = b~connid  AND f~fldate = b~fldate.

 WRITE: / carrid, connid, fldate, bookid.ENDSELECT.

SELECT * FROM sflight INTO wa_sflight.SELECT * FROM sbook INTO wa_sbook

 WHERE carrid = wa_sflight-carrid  AND connid = wa_sflight-connid  AND fldate = wa_sflight-fldate.

 WRITE: / wa_sflight-carrid, wa_sflight-connid, wa_sbook-bookid.

ENDSELECT.IF sy-dbcnt = 0.CLEAR wa_sbook-bookid. WRITE: / wa_sflight-carrid, ... wa_sbook-bookid.ENDIF.

ENDSELECT.

Instead of this, use:

Keep the Number of Roundtrips Small

LEFT OUTER JOIN in the FROM clause

Page 34: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 34/66

¥ / 34

AA

LH

LHQF

...

SFLIGHT:

CARRID CONNID ... DISTANCE

SBOOK:

CARRID CONNID ... BOOKID

Join operator 

AA 0017 ... 2.572 AA 0017 ... 1

AA 0017 ... 2.572 AA 0017 ... 2

LH 0400 ... 6.658 NULL NULL ... NULL

LH 0402 ... 3.162 NULL NULL ... NULL

QF 0598 ... 1.689 QF 0598 ... 10

Join result table on the database

CARRID CONNID ... DISTANCE CARRID CONNID ... BOOKID

0017

0400

04020598

...

2.572

6.658

3.1621.689

...

AA

AA

AAQF

...

0017

0017

00180598

...

1

2

1710

...

Left Outer Join

Keep the Number of Roundtrips Small

Please note:

The resulting set

always contains the

complete

µouter' table.

Page 35: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 35/66

¥ / 35

R/3 work processR/3 work process

DB work process DB work process

Database cacheDatabase

Service

processes

Operating system

Database files

R/3 work process

DB work process

Network

communication

DB CPUconsumption

DB memory

consumption

Physical I /O

Effects of Rule 3

Page 36: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 36/66

¥ / 36

Rule 4:Keep the costs of 

the search down

Keep the Search Costs Down

Page 37: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 37/66

¥ / 37

TableIndex A

Block 2

Block 3

Block 1

Tables and indices

3

5

7

4

5

1

2

3

6

7

Record 4

Record 2

Record 5

Record 1

Record 6

Record 7

Record 3

Index B

B

E

G

C

D

E

A

B

F

G

Keep the Search Costs Down

Page 38: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 38/66

¥ / 38

SELECT * FROM sbook  WHERE carrid = 'AA'

 AND connid = '0017' AND fldate = '19981205'.

... Processing...ENDSELECT.

Keep the Search Costs Down

Use as many EQs as possible

Page 39: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 39/66

¥ / 39

SELECT carrid connid fldate bookid custtype orderdate FROM sbookINTO ...

 WHERE carrid = 'LH' AND fldate = '19981119'

 AND orderdate = '19981118'.... Verarbeitung ...ENDSELECT.

SELECT f~carrid f~connid f~fldate b~bookid  b~custtype b~orderdate

INTO (carrid, connid, fldate, bookid, custtype)FROM sflight AS f INNER JOIN sbook as b

ON f~carrid = b~carrid AND f~connid = b~connid  AND f~fldate = b~fldate

 WHERE f~carrid = 'LHµ AND fldate = '19981119' AND orderdate = '19981118'.

... Verarbeitung ...ENDSELECT.

SBOOK Key:

mandt

carrid

connid

fldatebookid

Use as many EQs as possible

Keep the Search Costs Down

Page 40: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 40/66

¥ / 40

Keep the Search Costs Down

1 2 3 4

Key to the

SBOOK

table

Primary

index

Mand Carrid Connid Fldate

Mand Carrid Connid Fldate

Secondary

indexCarrid Fldate Orderdate

Page 41: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 41/66

¥ / 41

f0 = x1 AND (f1 = y1 OR 

f1 = y2 OR f1 = y3).

Replace the inner OR with anIN operator 

f0 = x1 AND f1 IN (y1, y2, y3).

Keep the Search Costs Down

Page 42: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 42/66

¥ / 42

Place fields that are effective in the selection process at thebeginning

The following fields are not effective in the selection process:MANDT, BUKRS,GJAHR.

The following are effective: BUCHUNGSNUMMER, BELNR, MATNR,KUNNR,

Create small indices

Avoid overlaps (disjunct indices)

Up to 3 indices in each table do not have to be critical

Avoid using complex WHERE clauses with IN and ORoperators for index fields

 You cannot process NOT operators in SELECT using an index

Verify the use of indices (for example, SQL trace)

Index design

Keep the Search Costs Down

Page 43: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 43/66

¥ / 43

R/3 work processR/3 work process

DB work process DB work process

Database cacheDatabase

Service

processes

Operating system

Database files

R/3 work process

DB work process

Network

communication

DB CPUconsumption

DB memory

consumption

Physical I /O

Effects of Rule 4

Page 44: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 44/66

¥ / 44

Rule 5:

Remove the load

from the database

Remove the Load from the Database

Page 45: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 45/66

¥ / 45

Buffer tables

Avoid repeated reading of data

Is a SELECT needed before a change is made?

ORDER BY vs. SORT

Use the ³right´ logical database

==> More scalable

Remove the Load from the Database

Page 46: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 46/66

¥ / 46

What is table buffering?

When should you buffer tables?

What should you bear in mind when programming SQLaccesses to buffered tables?

ABAP Open SQL and table buffering

Remove the Load from the Database

Page 47: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 47/66

¥ / 47

SELECT col1 .......... FROM T001

PROGRAM XYZ

RESULTTransfer data from the

database server to the

application server and

the table buffer 

21

3

4

5

Read data from

database if it is

not in the table

buffer 

Table buffering ± the concept

Remove the Load from the Database

Data-

base

server 

Table buffer 

Appl.

server 

Page 48: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 48/66

¥ / 48

Why buffer tables?

Appl.

server 

Data-

base

server 

SELECT SINGLE col1 .. FROM T001

PROGRAMM XYZ

Table buffer 

8 - 600 ms

0.2 - 1 ms

Remove the Load from the Database

Page 49: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 49/66

Page 50: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 50/66

¥ / 50

Buffer synchronizationI

Application server A

Table buffer 

Communication system

Database management system

The database

is up to date

Local buffer is

up to date

...

DDLOG

UPDATE T001...

Database

R/3 DB interface

Remove the Load from the Database

Page 51: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 51/66

¥ / 51

Buffer synchronizationII

Application server A

Table buffer 

Communication system

Database management system

Application server BBuffer is

NOT upto date...

DDLOG

UPDATE T001...

Database

Table buffer 

R/3 DB interface

DDLOG

INSERT DDLOG

The database

is up to date

Local buffer is

up to date

Remove the Load from the Database

Page 52: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 52/66

Page 53: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 53/66

Page 54: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 54/66

¥ / 54

When should you buffer a table?

 You should buffer a table if:

It is read frequently

It is relatively small It is read much more frequently than it is changed

Possible candidates for buffering

Control tables and customizing tables

³Small´ master data tables(100 data records for material master data -> few changes)

Remove the Load from the Database

Page 55: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 55/66

Page 56: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 56/66

R th L d f th D t b

Page 57: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 57/66

¥ / 57

This should be avoided because:

It places an unnecessary burden on the database

Different results could be read

Repeated reading of data

Remove the Load from the Database

R th L d f th D t b

Page 58: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 58/66

¥ / 58

ORDER BY

... does not necessarily mean that certain indexes will be used in

the database

... often results in large overhead for the database.

Is the data really needed in a certain order?

ORDER BY vs. SORT

Remove the Load from the Database

Remove the Load from the Database

Page 59: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 59/66

¥ / 59

Pre-defined effective table access

Simplified list creation

Optimization is performed centrally

But use the ³right´ LDB!

Logical databases

Remove the Load from the Database

Effects of Rule 5

Page 60: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 60/66

¥ / 60

R/3 work processR/3 work process

DB work process DB work process

Database cacheDatabase

Service

processes

Operating system

Database files

R/3 work process

DB work process

Networkcommunication

DBC

PU

consumption

DB memory

consumption

PhysicalI /O

Effects of Rule 5

Performance Check List

Page 61: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 61/66

¥ / 61

Performance Check List

Is the program using SELECT * statements?

Convert them to SELECT column 1 column 2 or use projection

views.

Are the fields within the SELECT..WHERE normalized to same

domain?

Convert data fields in where clause to same field level 

domain.

Ex. ( SELECT FROM MARA«WHERE matnr = fld2« DATA:

fld2 like mara-matnr)

Performance Check List

Page 62: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 62/66

¥ / 62

Performance Check List

Are Check Statements for table fields embedded in a SELECT

« ENDSELECT loop?

I ncorporate the CHECK statements into the WHERE clause of the

SELECT statement.

Do SELECTS on non-key fields use an appropriate DB index

or is the table buffered?

Create index for the table in the data dictionary or buffer 

tables if they are read only or read mostly.

SELECT into ITABs on key fields, LOOP ITAB or DELETE to

filter on remaining criteria.

Page 63: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 63/66

Performance Check List

Page 64: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 64/66

¥ / 64

Performance Check List

Is the program using Select « Append ITAB«. ENDSELECT

technique to fill Internal Table ?.

Change the processing to read the data immediately into an

internal table.

(SELECT VBELN AUART« INTO TABLE IVBAK«)

Is the program using SELECT..ORDER BY statement?.

Data should be read into an internal table first and then sorted,

unless there is an appropriate index for the order by field.

Performance Check List

Page 65: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 65/66

¥ / 65

Performance Check List

Is the programming doing calculations/summations that can

be done on the database via SUM, AVG, MIN, MAX functions

for the SELECT statement?.

Use the calculation capabilities of the database via SELECT 

SUM«

Is the program inserting/updating or deleting data in dialog

mode (not via an update function module)?.

Make sure that the program issues COMMIT W ORK statements

when one or more logical units of work (LU W s) have been

 processed.

Page 66: ABAP Performance (2)

8/3/2019 ABAP Performance (2)

http://slidepdf.com/reader/full/abap-performance-2 66/66