Vous êtes sur la page 1sur 136

IBM z Systems for SAP

Performance & Tuning Workshop


SAP on IBM z Systems

Ashraf Kamel
akamel@us.ibm.com

Mike Mardis
mardis@us.ibm.com
© 2016 IBM Corporation

1
IBM z Systems for SAP

Prerequisite

Performance Section of the following Class:

ADM530
“SAP NetWeaver on DB2 for z/OS”
- Chapter 9: Performance Monitoring and Tuning

© 2016 IBM Corporation


2
IBM z Systems for SAP

Agenda
 Prerequisite material
 Background Summary
o Origin of SAP Performance Data

 z/OS Performance Management


o RMF (Resource Management Facility) – Detecting Key Bottlenecks

 DB2 for z/OS – DBMS and SQL Basics


o Basics and How Does SAP Utilize it

 DB2 Accounting and Statistics


o Identifying Bottlenecks and Analysis

 SAP Application Server


o Best Utilization and Optimization for Best Performance

 ABAP Programing Performance Perspective


 SAP BW Performance Perspective
o Performance Analysis & Star Joins Tuning

 Performance Roadmap
 Case Studies
© 2016 IBM Corporation
3
IBM z Systems for SAP

Agenda
 Prerequisite material
 Background Summary
o Origin of SAP Performance Data

 z/OS Performance Management


o RMF (Resource Management Facility) – Detecting Key Bottlenecks

 DB2 for z/OS – DBMS and SQL Basics


o Basics and How Does SAP Utilize it

 DB2 Accounting and Statistics


o Identifying Bottlenecks and Analysis

 SAP Application Server


o Best Utilization and Optimization for Best Performance

 ABAP Programing Performance Perspective


 SAP BW Performance Perspective
o Performance Analysis & Star Joins Tuning

 Performance Roadmap
 Case Studies
© 2016 IBM Corporation
4
IBM z Systems for SAP

Performance Problem Roadmap


ABAP Trace on
Inspect Overall Workload
TOP TIME Transactions
Statistics for Problem Areas SQL Trace on
(MAIN_MENU Response Time?) Specific problem TOP TIME Transactions
General
Consider Tuning DB in
Problem Analyze Error Files Order of Highest Gains:
(ST22, AL11, SM21…) App. SQL Tuning 70%
SAP Buffer Quality? Buffer Objects or Memory 15%
ST02 Increase Buffers Disk I/O 10%
Memory Contention 5%
If DB2 Buffer Pools/
Avg DB Time Thresholds? ST04
> 40% Response Time
or Check Missing Indexes
> 400 ms (ST03) DBACockpit → Diagnostics → Missing Tables and Indexes

Transaction Workload Stats, Use SQL Trace on Tune Statements


Identify Intensive Transactions. Transaction ST05 (Indices/Coding)

Network Problem (OS06) Redefine/Reconfigure/


Additional Interfaces
SAP Server Resources (OS06) Resources Required by the
SAP Dispatcher (CPU, Memory, ...)
Paging Problem/ More Real Memory/
Overallocation of Virtual Memory? Reconfigure Virtual Memory
OS06

© 2016 SAP ADM530 Chapter 9


5
IBM z Systems for SAP

High Database Time (1)

Potential for Performance Optimization

Applications and Customizing


60%

Database and SAP Basis


30%
OS and other
10%

© 2016 SAP ADM530 Chapter 9


6
IBM z Systems for SAP

High Database Time (2)


Which Servers?

 InST03 choose Load Distribution → Instance Comparison


 All servers or just a few?
 Choose worst dialog server to start the analysis
 Recent configuration or workload changes?
 Performance acceptable?
 Average response time for dialog according to SLA (Service Level
Agreement)
 Reasonable sample for the server?

What is High?
 HIGH: 400 ms for dialog
 HIGH: 40% of overall average response time for dialog

© 2016 SAP ADM530 Chapter 9


7
IBM z Systems for SAP

High Database Time (3)


Question to Ask?

Is the size sample reasonable?


Typically greater than 20 000 dialog steps
Is there unusual activity?
Client copy, loads
Is the analysis period a realistic workload?
Is one transaction distorting all of the averages?

© 2016 SAP ADM530 Chapter 9


8
IBM z Systems for SAP

High Database Time: Possible Causes (1)


Real DB2 Performance:

 I/O suspensions
 Locking issues
 DB2 latching or IRLM latching
 Low buffer pool hit ratios
 Critical thresholds reached
 Improper configuration settings
 Data sharing: Global contention or false contention
 WLM settings
 Resource allocation to DB2
 Outdated RUNSTATS and REORGs

© 2016 SAP ADM530 Chapter 9


9
IBM z Systems for SAP

High Database Time: Possible Causes (2)


Causes Outside of DB2:

 Coding / bugs in SAP and in customer code


 Missing performance transports
 Code customization
 Poor SAP buffering strategy for high use tables
 Low SAP buffer hit ratios
 Bad or missing indexes
 Too many indexes
 High database calls to database request ratio
 Wrong DB Time measurement due to:
 High application server CPU utilization
 Memory / paging problems on the application server
 Incorrect vmtune settings (AIX)

© 2016 SAP ADM530 Chapter 9


10
IBM z Systems for SAP

High Database Time: Possible Causes (3)


Causes outside of SAP NetWeaver and DB2:
Networking problem
SAP transaction OS06 - Starting point
DB2 Connect network statistics in SAP DBA Cockpit
z/OS prioritization
Real storage paging
CPU delays
Processor resource capping

© 2016 SAP ADM530 Chapter 9


11
IBM z Systems for SAP

Monitoring Roadmap
ST03 Which processes are
currently running?
Workload Analysis
Are the buffers (Today on all servers)
optimally adjusted? Database Operations
Average Times
Serious problems on
the database server? SM66
SM51 SAP Servers
Work Process Overview
Server Work Process

On an Application Server,
ST02 SM50 Process Overview For Example SAP01

Tune Summary What are the time


ST05 SQL Trace
Table Buffers consuming TR’s All SQL Activity of
Program Buffers a Certain User
doing?

ST04
Database Activity
DB2 System
Threads NAME ST A REQ ID AUTHID
Stmt Cache SERVER RA * 1552 D8HDIA000 R3USER
Times V437-WORKSTATION=ihls04, USERID=r3user
Inst. Parameters
z/OS SysLog
© 2016 SAP ADM530 Chapter 9
12
IBM z Systems for SAP

Workload Analysis: Time Statistics

GUI Time Wait Roll In Load Process Time DB Time

CPU Time

Response Time

Presentation
Server Application Server Database Server

© 2016 SAP ADM530 Chapter 9


13
IBM z Systems for SAP

Workload Analysis: Detail View - DB Statistics


ST03
Buffer hit ratio

# Logical Database Calls - # Physical Database Read Acc.


---------------------------------------------------------------------------------- * 100
# Logical Database Calls

GUI Time Wait Roll In Load Process Time DB Time

CPU Time

Response Time

Application Server Database Server

© 2016 SAP ADM530 Chapter 9


14
IBM z Systems for SAP

Monitoring Roadmap
ST03 Which processes are
currently running?
Workload Analysis
Are the buffers (Today on all servers)
optimally adjusted? Database Operations
Average Times
Serious problems on
the database server? SM66
SM51 SAP Servers
Work Process Overview
Server Work Process

On an Application Server,
ST02 SM50 Process Overview For Example SAP01

Tune Summary What are the time


ST05 SQL Trace
Table Buffers consuming TR’s All SQL Activity of
Program Buffers a Certain User
doing?

ST04
Database Activity
DB2 System
Threads NAME ST A REQ ID AUTHID
Stmt Cache SERVER RA * 1552 D8HDIA000 R3USER
V437-WORKSTATION=ihls04, USERID=r3user
Times
Inst. Parameters
z/OS SysLog
© 2016 SAP ADM530 Chapter 9
15
IBM z Systems for SAP

Tuning Summary (ST02)


ST02
SAP Buffers
 Nametab
 Program  Efficiency (Hit ratio)
 CUA  Size
 Screen  Directory entries
 Calendar  Swaps
 Table  Resets
 Message
Memory Management
 Roll area
 Paging area
 Usage
 Extended memory
 Heap memory

SAP Cursor Cache


 Ids  Hitratio
 Statements  Free entries
© 2016 SAP ADM530 Chapter 9
16
IBM z Systems for SAP

Tuning Summary: Table Buffers

SAP AS
Work Process
Database

SAP Tables

Table X Table X

Table Buffers
First Access

© 2016 SAP ADM530 Chapter 9


17
IBM z Systems for SAP

Tuning Summary: Table Buffering Types


ABAP Dictionary DB2 Catalog

Full Whole Table TAB K1 K2 F1 F2 F3


Buffering
Generic
Key TAB K1 K2 K3 F2 F3
Buffering
Generic Generic Area a b c ... ...
Buffering a b d ... ...
a c d ... ...

Single Partial One Record TAB K1 K2 K3 F2 F3


Key Buffering a b c ... ...
Buffering
a b d ... ...
a c d ... ...

Key
TAB: Table name
K1: Key field name
F1: Field name

© 2016 SAP ADM530 Chapter 9


18
IBM z Systems for SAP

Monitoring Roadmap
ST03 Which processes are
currently running?
Workload Analysis
Are the buffers (Today on all servers)
optimally adjusted? Database Operations
Average Times
Serious problems on
the database server? SM66
SM51 SAP Servers
Work Process Overview
Server Work Process

On an Application Server,
ST02 SM50 Process Overview For Example SAP01

Tune Summary What are the time


ST05 SQL Trace
Table Buffers consuming TR’s All SQL Activity of
Program Buffers a Certain User
doing?

ST04
Database Activity
DB2 System
Threads NAME ST A REQ ID AUTHID
Stmt Cache SERVER RA * 1552 D8HDIA000 R3USER
Times V437-WORKSTATION=ihls04, USERID=r3user
Inst. Parameters
z/OS SysLog
© 2016 SAP ADM530 Chapter 9
19
IBM z Systems for SAP

Database Activity (ST04)


Statistics ST04 DB2 subsystem activity
01 Statistics data Thread activity
02 Installation-def. statistics records
03 Deadlock information Stmt cache statistics
04 DB2 exceptional conditions Times
05 Data sharing statistics records Installation parameters
DB2 Commands
Accounting
01 Most accounting data, but no time z/OS system log
distribution RSDB2_RUN_HOURLY_REMOTE START TRACE
02 Elapsed and CPU time spent in DB2
03 Detail distribution of suspension Alert Router
times and events

Instrumentation Facility Interface


Instrumentation Facility Component ID
DB2
TNO TYPE CLASS DEST
000 001 002 003 004 005 006 007 008 01 STATS 01,03, SMF
. . . 02 ACCTG 01,02,03 SMF
226 227 228 229 230 231 232 233 ...

© 2016 SAP ADM530 Chapter 9


20
IBM z Systems for SAP

Database Activity: Available Information (1)


 DB2 Subsystem Activity
 DBM1 virtual and real storage
 Lock waits
 Locking activity
 Logging activity
 EDM Pool
 Dynamic statement cache
 Open/close activity
 Subsystem services
 SQL activity
 Buffer pools

© 2016 SAP ADM530 Chapter 9


21
IBM z Systems for SAP

Database Activity: Available Information (2)


 Thread Activity
 Lock waits
 Buffer pool activity (per pool)
 Locking activity
 Locked resources
 Times
 SQL activity
 SQL statement
 DS locking
 GP pool
 Statement cache
 Global times

© 2016 SAP ADM530 Chapter 9


22
IBM z Systems for SAP

Database Activity: Available Information (3)


 Installation parameters
 Log parameters
 Protection and data definition
 Application programming defaults
 Others
– Connection to DB2
– IRLM Installation
– Storage sizes
– Lock escalation parameters
– Operator functions
– Tracing and pseudo-close
– Data installation
– DDF parameters
– Data sharing parameters
 DB2 commands
 Sysplex Monitor
© 2016 SAP ADM530 Chapter 9
23
IBM z Systems for SAP

DB2 Subsystem Activity: Lock Waits

© 2016 SAP ADM530 Chapter 9


24
IBM z Systems for SAP

Locking: Basics
 Row Level Locking
 Reads mostly with UR, but some important CS
 Late escalation
NUMLKTS = 2097152
LOCKMAX = SYSTEM (or 1000000)
 High limits
NUMLKUS = 2097152
 SAP prefers large timeout values
IRLMRWT = 600
UTIMOUT = 3
 Deadlocks
DEADLOK = 5.1

© 2016 SAP ADM530 Chapter 9


25
IBM z Systems for SAP

Locking: Avoiding Deadlocks with SAP Enqueues


Without Enqueue 1 X-lock
R1 waits
1 T1: Update 3 T1: Update for 4
Time
Row R1 Row R2
T2: Update 4 T2: Update T1 T2
2
Row R2 Row R1
waits
3 for R2

2 X-Lock

With
Enqueue 4
1 X-Enqueue
R1, R2 waits
1 T1: Enqueue Time for 2
3 T1: Update 4 T1: Commit
Row R1,R2 Row R1,R2
T2: Enqueue T1 T2
2 5 T2: Update 6 T2: Commit
Row R1,R2 Row R2

Key
T1, T2 Transaction 1, Transaction 2
R1, R2 Row 1, Row 2

© 2016 SAP ADM530 Chapter 9


26
IBM z Systems for SAP

Base for Buffer Pool Performance Evaluation


Critical Threshold Values

Read Operations
Prefetch disabled - no buffers
Prefetch disabled - no read engine

Write Operations
Write engine not available
Deferred write threshold reached
Vertical deferred write threshold reached
Data manager critical threshold reached

Sort/Merge Work file Operations


Prefetch not scheduled - zero quantity
Degraded - low buffers
Work file requests rejected - low buffers

© 2016 SAP ADM530 Chapter 9


27
IBM z Systems for SAP

Buffer Pool Tuning: Buffer Pool Parameters


VPSIZE Random C

C
B A
B C
B A A B
B C
B 128
A B B A
VDWQT A B C
B B A A A
A B C
A B B B
A B C
A B C
Sequential
VPSEQT C C C C C C
DWQT
... ...
C C

C C C C ... C ... C

A B C

VBAK VBAP VBBE

Key
Header Item Requirements
Pages read

Pages updated / in use Sales and Distribution

© 2016 SAP ADM530 Chapter 9


28
IBM z Systems for SAP

Buffer Pools: Read Efficiency


Read Operations

Getpage requests - total total MINUS


Getpage requests - sequential access only sequential
Synchronous reads - total total
MINUS
Synchronous reads - sequential access sequential
Sequential prefetch - pages read
List prefetch - pages read
Dynamic prefetch - pages read

SUM SUM
total pages read Random requested getpages
Random synchronous reads

(total requests - pages read)


Hit ratio = * 100
total requests

(total random requests - random pages read)


Random hit ratio = * 100
total random requests

Pages read per prefetch = total pages read / all type prefetch reads

Read rate = total pages read / interval of measurement

© 2016 SAP ADM530 Chapter 9


29
IBM z Systems for SAP

DB2 Data Sharing Tuning (2)


SYN.READS(XI)-DATA RETURNED

GBP Hit Ratio = =


(SYN.READS(XI)-NO DATA RETURNED + SYN.READS(XI)-DATA RETURNED)

= QBGLXD / (QBGLXD + QBGLXR)

Recommendation: >= 70%


 Cross-invalidations due to directory reclaims
Needs to be small, otherwise GBP or GBP ratio for directory entries needs to be increased; to
query current status:
-DIS GBPOOL(*) GDETAIL(INTERVAL) TYP(GCONN)
 Castout efficiency
UNLOCK CASTOUT should be significantly less than PAGES CASTOUT, at most half of
PAGE CASTOUT
 CF processor utilization recommendation
Under 50 % (ISPF RMF Monitor III, S SYSPLEX → 5)
 CF link performance
If total sub-channel busy < 10% of all requests, then add another CF link
© 2016 SAP ADM530 Chapter 9
30
IBM z Systems for SAP

DB2 Data Sharing Tuning (2)


Servicetime:
Synchronized service time:
GBPs - ICP 30 mics, - CFP 65 mics
LOCK1, SCA - ICP 65 mics, - CFP 40 mics
Asynchronized service time:
GBPs - ICP 120 mics, - CFP 150 mics
LOCK1,SCA - ICP 100 mics, - CFP 120 mics
(ISPF RMF Monitor III, S SYSPLEX → 6)

© 2016 SAP ADM530 Chapter 9


31
IBM z Systems for SAP

Buffer Pools: Write Efficiency

Write operations

Buffer updates
Pages written
Synchronous writes
Asynchronous writes
SUM Write I/Os

Buffer updates per page written = Buffer updates / Pages written

Pages written
Pages written per write I/O = Write I/Os

Write I/Os
Write rate =
Interval of measurement

© 2016 SAP ADM530 Chapter 9


32
IBM z Systems for SAP

DB2 Thread Activity

© 2016 SAP ADM530 Chapter 9


33
IBM z Systems for SAP

Accounting Class 1, 2, and 3 Time Values

Name in ST04 class 1 class 3 class 2 calculated

Activity time elapsed


Time out of DB2 activity time - time spent in DB2
Total CPU time CPU
Time spent in DB2 elapsed
CPU time in DB2 CPU
Suspended in DB2 suspension
Not attrib. in DB2 wait time - suspended in DB2
Wait time time spent in DB2 - CPU time in DB2

Activity Time

Total CPU Time

TimeSpent in DB2 Time Out of DB2

CPU Time in DB2 Wait Time

Suspended Not Attributed


in DB2 in DB2

© 2016 SAP ADM530 Chapter 9


34
IBM z Systems for SAP

Distribution of Time Spent in DB2

In DB2 Time

CPU Time in DB2


Suspended in DB2

Not Attributed in DB2

© 2016 SAP ADM530 Chapter 9


35
IBM z Systems for SAP

Tracking a Time-Consuming SAP Transaction

ABAP Program
...
SELECT * FROM sflight INTO wa_sflight
D DB2
FOR ALL ENTRIES IN ftab
WHERE connid = ftab-connid
B Native
and carrid = ftab-carrid. S SQL
...
L
© 2016 SAP ADM530 Chapter 9
36
IBM z Systems for SAP

EXPLAIN SQL Statements

Explain SQL statement

plan_table
Optimizer
DB2
© 2016 SAP ADM530 Chapter 9
37
IBM z Systems for SAP

DSC Statistics – Statement Cache

DSC Statistics

© 2016 SAP ADM530 Chapter 9


38
IBM z Systems for SAP

Statement Cache Statistics


-START TRACE(PERFORMANCE) CLASS(30) IFCID(318) DEST(SMF)
Identification and status Avg. time distr. per exec Total time distr. across all execs
Prep. stmn. cache ID Avg. elap/exec Acc. time elapsed
Program name Avg. CPU time CPU time
Stmt line number Avg. wait time Wait time
Transaction name Avg. sync I/O time Sync I/O wait time
ABAP program name Avg. read wait Read wait time
User ID Avg. write wait Write wait time
User Group Avg. lock/latch wait Lock/latch wait time
Initial prepare time Avg. global lock wait Glob lock wait time
Copies in use Avg. EU switch wait EU switch wait time
Copies of statement Avg. other wait time Other wait time
BW STATUID
Unqual tab names Avg. statistics per exec Total statistics across all execs
ISOLATION BIND Execs / sec Executions
CURDATA BIND Avg getpages Getpages
DYNAMICRULES BIND Rows exam/execs Rows examined
CURRENT DEGREE Rows proc/execs Rows processed
CURRENT RULES Getpages / processed Synchronous reads
CURRENT PRECISION Examined / processed Synchronous writes
CURSOR HOLD Sync reads / execs Sorts
Status Synch writes / execs Index scans
Avg sync I/Os Tablespace scans
Avg I/O duration RID list fails (no storage)
Avg sorts RID list fails (limit exceeded)
Avg idx scans Parallel groups
Avg tbl scans
Avg RID fails stor
Avg RID fails limit
Avg parallel groups
© 2016 SAP ADM530 Chapter 9
39
IBM z Systems for SAP

Statement Cache Statistics

© 2016 SAP ADM530 Chapter 9


40
IBM z Systems for SAP

Monitoring Roadmap
ST03 Which processes are
currently running?
Workload Analysis
Are the buffers (Today on all servers)
optimally adjusted? Database Operations
Average Times
Serious problems on
the database server? SM66
SM51 SAP Servers
Work Process Overview
Server Work Process

On an Application Server,
ST02 SM50 Process Overview For Example SAP01

Tune Summary What are the time


ST05 SQL Trace
Table Buffers consuming TR’s All SQL Activity of
Program Buffers a Certain User
doing?

ST04
Database Activity
DB2 System
Threads NAME ST A REQ ID AUTHID
Stmt Cache SERVER RA * 1552 D8HDIA000 R3USER
Times V437-WORKSTATION=ihls04, USERID=r3user
Inst. Parameters
z/OS SysLog
© 2016 SAP ADM530 Chapter 9
41
IBM z Systems for SAP

SQL Trace (ST05)


ABAP Dictionary (SE11)
 Table / view fields
 Indexes with fields
 Technical settings
ABAP Program
SELECT "MANDT" , "MATNR" , Analyze plan table ...
. . . select * from mara
FROM "MARA" Performance is optimal. … into table i_mara
WHERE "MANDT" = ?
where matnr in matnr.
AND "MATNR" IN ( ? , ? , ? ) Method: access new table.
FOR FETCH ONLY WITH UR ...
...

Details DDIC info Explain SQL ABAP Display

HH:MM:SS.MS Duration Program Obj. name Op. Curs Array Recs. RC Conn Statement

11:38:59.066 119 ZZXGD_M MARA DECLARE 95 0 R/3 SELECT WHERE "MANDT" = ? AND "MATNR" IN ( ? , ? , ? , ?
11:38:59.066 42.991 ZZXGD_M MARA PREPARE 95 0 R/3 SELECT WHERE "MANDT" = ? AND "MATNR" IN ( ? , ? , ? , ?
11:38:59.109 12 ZZXGD_M MARA OPEN 95 0 R/3 SELECT WHERE "MANDT" = '000' AND "MATNR" IN (
‘0000000000
11:38:59.109 112.139 ZZXGD_M MARA FETCH 95 23 5 100 R/3

© 2016 SAP ADM530 Chapter 9


42
IBM z Systems for SAP

Tuning Problem Statements


Creating Appropriate Indexes
Disadvantages Advantages
 Expensive inserts, deletes and index-column  Reduction of CPU and I/O costs
changing updates  Sort avoidance
 Increased DASD
 Increasing number of data sets
 Increased RECOVER time
 Larger online REORG switch phase

Using Open SQL Hints


 Onlyfor Open SQL
 Add %_HINTS DB2 ‘hint text’

Advanced Techniques

 Changing join sequence and method


 Discouraging use of an index

© 2016 SAP ADM530 Chapter 9


43
IBM z Systems for SAP

DB2 Explain: DB2 Optimizer Basics

© 2016 SAP ADM530 Chapter 9


44
IBM z Systems for SAP

New with 7.02 and 7.30: WebDynpro Explain


 Currently only explain from
statement text
 Graphical tree view
 Uses SAP Web Dynpro
technology.
 Displays additional access path
information such as:
 Predicate filter factors
 Cost estimates
 Rewritten query
 Sort and parallelism
information
…

© 2016 SAP ADM530 Chapter 9


45
IBM z Systems for SAP

DB2 Optimizer Basics: Conclusion

 Up-to-date statistics for the DB2 optimizer RUNSTATS


RUNSTATS with  Sometimes collecting additional statistics is necessary
Option FREQVAL  Indexable or at least stage 1 predicates Change SQL
 Optimize the SQL statements in the application statements

© 2016 SAP ADM530 Chapter 9


46
IBM z Systems for SAP

Optimizing SQL Statements


Data to be
transferred

Relevant data
- the hit set -
SELECT
Clause
Data to be searched
WHERE Clause - limited only by
the use of indexes -
Search Area

FROM Clause One or more tables

SELECT field1 field2 field3 field4


FROM table1 inner join table2 on
table1.field1 = table2.field1
WHERE field1 IN ('A','B','C') AND field3 like 'T%'

© 2016 SAP ADM530 Chapter 9


47
IBM z Systems for SAP

Optimizing SQL Statements: Basic Rules


1 Keep hit set small
2 Keep size of data transfers small
3 Keep number of transfers small

4 Keep search area small

5 Take load off database

© 2016 SAP ADM530 Chapter 9


48
IBM z Systems for SAP

rsdb/stattime parameter

• Used to enable DBIF layer to record cumulative times for


tables per SQL call type

• Set by rsdb/stattime=1 in instance profiles

• Collected and integrated in ST10 data, also can view


realtime in ST02

• Some minimal overhead involved

• Extremely valuable for determining justification of


additional indexes

© 2016 IBM Corporation


49
IBM z Systems for SAP

rsdb/stattime parameter

When parameter enabled,


viewing statistics for tables
in ST10 will show values in
this column.

© 2016 IBM Corporation


50
IBM z Systems for SAP

stat/tabrec parameter

• Used to enable individual table records to be


recorded in ‘stat’ records

• Instance parameter of stat/tabrec=n, where n is


the # of highest time tables of a dialog step

• Collected and Integrated into ST03N data

• Some overhead involved, mainly elongated


runtime of the collector

© 2016 IBM Corporation


51
IBM z Systems for SAP

stat/tabrec parameter

When parameter enabled,


viewing individual table stat
records, this button will
appear.

© 2016 IBM Corporation


52
IBM z Systems for SAP

stat/tabrec parameter

In this example, this


customer written
transaction stands out
with significantly less
data (rows) accessed
for it’s impact on
response time. Drilling
into the transaction
shows…

© 2016 IBM Corporation


53
IBM z Systems for SAP

stat/tabrec parameter

This shows almost


the entire
contribution to
response time is
table VBAP. The
next step would be
identifying SQL in
DBMS cache, or
tracing with ST05.

© 2016 IBM Corporation


54
IBM z Systems for SAP

stat/tabrec parameter

When parameter enabled,


viewing individual stat
records, this button will
appear.

© 2016 IBM Corporation


55
IBM z Systems for SAP

stat/tabrec parameter

In this case, we see that the


view ASSOB_HR was
accessed to retrieve 395
rows, however the impact to
response time was 11.705
seconds from a total of
11.829 seconds.

© 2016 IBM Corporation


56
IBM z Systems for SAP

Agenda
 Prerequisite materials
 Background Summary
o Origin of SAP Performance Data

 z/OS Performance Management


o RMF (Resource Management Facility) – Detecting Key Bottlenecks

 DB2 for z/OS – DBMS and SQL Basics


o Basics and How Does SAP Utilize it

 DB2 Accounting and Statistics


o Identifying Bottlenecks and Analysis

 SAP Application Server


o Best Utilization and Optimization for Best Performance

 ABAP Programing Performance Perspective


 SAP BW Performance Perspective
o Performance Analysis & Star Joins Tuning

 Performance Roadmap
 Case Studies
© 2016 IBM Corporation
57
IBM z Systems for SAP

SAP Application Server

• Learn the technical principles underlying the SAP table


buffering mechanism and how it is critical to system
performance

• Develop expertise in the use of tracing, runtime analysis


and debugging techniques to understand complex issues

• Understand the role of memory in providing a vital


resource to the relevant software layers. Understand the
SAP memory model

© 2016 IBM Corporation


58
IBM z Systems for SAP

SAP Table Buffers

SAP GUI SAP GUI SAP GUI SAP GUI

Table Buffers
Application Server A Application Server B Number Range Buffer
PXA Programm Buffer
original original Presentation Buffer
Work Work
Processes R/3 Buffers Processes R/3 Buffers
CUA Buffer
Nametab Buffer

Communication System

Database
DBMS Database
Management Processes Cache
System

Database

© 2016 IBM Corporation


59
IBM z Systems for SAP

Buffering Process: No Logon Group Scenario


FI SD FI SD USR-1 reads A: 4 buffer accesses 1,200 time units
USR-1 USR-2 USR-3 USR-4 USR-2 reads A: 2 BAs 100 TUs
USR-2 reads E: 4 BAs 1,200 TUs
X 100 X 100
USR-3 reads A: 3 BAs 200 TUs
USR-4 reads E: 3 BAs 200 TUs
A
AE AEF
AEFGH
AEFG
A
AE
EFGHA USR-4 reads F: 4 BAs 1,200 TUs
AS-1 AS-2 USR-4 reads G: 4 BAs 1,200 TUs
X 100
X 100 USR-4 reads H: 4 BAs 1,200 TUs (displaces A)
USR-3 reads A: 3 BAs 200 TUs (displaces E)

A
AEFGH
AEF
AEFG
AE

DB-1
X 1000

AEFGH
A
AE
AEF
AEFG

DASD

© 2016 IBM Corporation


187
IBM z Systems for SAP

Buffering Process: Logon Group Scenario


FI FI SD SD USR-1 requests A: 4 buffer accesses 1,200 time units
USR-1 USR-2 USR-3 USR-4 USR-2 requests A: 2 BAs 100 TUs
USR-2 requests B: 4 BAs 1,200 TUs
X 100 X 100
USR-3 requests E: 4 BAs 1,200 TUs
USR-4 requests E: 2 BAs 100 TUs
A
AB EFGH
E USR-4 requests F: 4 BAs 1,200 TUs
AS-1 AS-2 USR-4 requests G: 4 BAs 1,200 TUs
X 100 USR-4 requests H: 4 BAs 1,200 TUs

FI users are unaffected by the large SD query


SD app servers can be tuned for larger SD queries
ABEFGH
ABE
A
AB

DB-1
X 1000

ABE
AB
ABEFGH
A

DASD

© 2016 IBM Corporation


188
IBM z Systems for SAP

Buffering Process: Table Write Scenario


FI FI FI USR-1 reads A : 4 buffer accesses 1,200 time units
USR-1 USR-2 USR-3 USR-2 reads A : 2 BAs 100 TUs
USR-3 reads A : 3 BAs 200 TUs
X 100 X 100
USR-3 writes A’ : 5 BAs 1,200 TUs (replaces A)
(DDLOG entry for A)
A (pend
A’ 5)
A 1)
2)
3)
4) AA’
A USR-3 reads A’ : 2 BAs 100 TUs
AS-1 AS-2 USR-1 reads A : 2 BAs 100 TUs (gets old value for A)
X 100 …
Sync occurs at 60-120 second period
MSG SVR reads DDLOG and invalidates AS-1 buffered A
DDLOG
DDLOG USR-1 reads A’ : 3 BAs 200 TUs (pend 1)
A A USR-1 reads A’ : 3 BAs 200 TUs (pend 2)
AA’
USR-1 reads A’ : 3 BAs 200 TUs (pend 3)
USR-1 reads A’ : 3 BAs 200 TUs (pend 4)
DB-1 USR-1 reads A’ : 3 BAs 200 TUs (pend 5)
X 1000 USR-1 reads A’ : 3 BAs 200 TUs (cancel pend)
USR-1 reads A’ : 2 BAs 100 TUs

AA’
A

DASD

© 2016 IBM Corporation


189
IBM z Systems for SAP

Buffering Process: Datasharing Scenario


• FI users are
FI FI FI SD SD SD
buffered on AS-1
USR-1 USR-2 USR-3 USR-4 USR-5 USR-6
and AS-2, as well
X 100 X 100 X 100 X 100 as on DB-1.
• SD users are
ABCD ABCD EFGH EFGHA
EFGH buffered on AS-3
and AS-4, as well
AS-1 AS-2 AS-3 AS-4
X 100 X 100 as on DB-2.
• Improves buffer
efficiency on the
DB, just like logon
ABCD A EFGHA
EFGH groups improved
buffer efficiency
on the app servers.
DB-1 CF DB-2 • When “A” is read
X 1000 by USR-6 a lock
and the “A” is
stored in the
Coupling Facility to
ABCDEFGH
ensure DB
DASD integrity. This is
called cross system
interests.

© 2016 IBM Corporation


190
IBM z Systems for SAP

SAP Buffering Checklist


• In a productive system rarely changed tables with:
– rather small size
– read-mostly access
– e.g. control tables and customizing tables

• Check whether buffering allowed


– NO if data must be always up-to-date (impossible to wait for
synchronization period)
– NO if overhead due to displacement and synchronization too high

• For effective use of the buffer:


– choose right buffering type
– avoid all kinds of bypassing statements
– avoid displacement / synchronization (of buffers)

© 2016 IBM Corporation


64
IBM z Systems for SAP

Table Buffering Types

Resident Buffering Generic buffering Generic buffering Partial buffering


(100%) 1 key field 2 key fields (single record)
key1 key2 key3 data
001 A 2
key1 key2 key3 data 001 A 4
001 A 001 B 1
key1 key2 key3 data 001 A 001 B 3
001 001 B 001 B 5
001 001 B 002 A 1
001 002 A 002 A 3
key1 key2 key3 data 001 002 A 002 A 6
002 002 B 002 A 8
002 002 B 002 B 1
002 002 B 002 B 2
002 002 C 002 B 3
002 002 C 002 C 0
002 002 D 002 C 3
003 003 A 002 D 5
003 003 A 003 A 2
003 003 A 003 A 3
003 003 B 003 A 6
003 003 B 003 B 2
003 003 C 003 B 4
003 003 C 003 C 2
003 003 C 003 C 3
003 D 003 C 5
003 D 003 C 8
003 D 003 D 1
003 D 2
003 D 3
003 D 4

© 2016 IBM Corporation


65
IBM z Systems for SAP

Statements bypassing buffer


– SELECT ... BYPASSING BUFFER
– SELECT ... FOR UPDATE
– Any aggregate function (COUNT, MIN, MAX, SUM, AVG), GROUP BY
SELECT MIN(F1) FROM T1 WHERE ...
– SELECT DISTINCT ...
– WHERE clause contains ... IS [NOT] NULL
– ORDER BY (other than PRIMARY KEY)
– Joins in Open SQL (SELECT ... JOIN ON ...)
– Any Native SQL statement
– In partial (single record) case: no SELECT SINGLE
– In generic case: no generic key

© 2016 IBM Corporation


66
IBM z Systems for SAP

Buffer Synchronization
• Changes on “bufferable” tables
– Each change on a “bufferable” table is noted in the DDLOG table for
multiple application server systems (rdisp/bufrefmode =
sendon,exeauto)
– Each application server reads the DDLOG contents in a certain period
determined by rdisp/bufreftime (default 120 for 4.7+)
– Tool available in ST02 -> Detailed analysis menu -> Buffer synchron.

• Buffer Synchronization (refresh)


– Application server marks as invalid data in its buffers that has been
changed on another application server
– Changed data is not read from the database immediately but only on
demand
– Synchronization occurs every 60 or 120 seconds (release dependent),
individual servers randomly staggered based on startup

© 2016 IBM Corporation


67
IBM z Systems for SAP

Example of table buffering

Monitoring the system


shows frequent access
to table CIF_IMMBOM…
(as well as MKAL)
Need to further
investigate….

© 2016 IBM Corporation


69
IBM z Systems for SAP

Example of table buffering

Turning on ST05 trace for these


two tables during the monitoring
period shows high frequency of
reads, ALL returning ZERO
ROWS

© 2016 IBM Corporation


70
IBM z Systems for SAP

Example of table buffering

Drilling from the trace to


the code shows it is SAP
code executing against
SAP delivered table…

© 2016 IBM Corporation


71
IBM z Systems for SAP

Example of table buffering

Looking at the technical


settings for the table, SAP
deliver the table ‘ready to
buffer’. These zero row SQL
requests will go from an
average of 1 millisecond to
1 microsecond

© 2016 IBM Corporation


72
IBM z Systems for SAP

rsdb/stattime parameter

© 2016 IBM Corporation


73
IBM z Systems for SAP

Memory Management - Dialog

© 2016 IBM Corporation


74
IBM z Systems for SAP

Memory Management – Non-dialog

© 2016 IBM Corporation


75
IBM z Systems for SAP

Memory Management - Dumps

© 2016 IBM Corporation


76
IBM z Systems for SAP

Memory Management – Page/Roll

© 2016 IBM Corporation


77
IBM z Systems for SAP

Memory Management – Page/Roll

© 2016 IBM Corporation


78
IBM z Systems for SAP

Memory Management - EM

Extended Memory
• Dominant residence for ABAP program requirements. Mapped to
shared memory
• Shared memory allows transparent access from all work processes
• While problems most often manifest themselves with extended memory
being referenced in the dump and problem analysis, em is almost
always the ‘messenger’ for poor programming overusing memory
• Analysis available in ST02 -> double click “ext memory” -> Mode List
• Dialog user analysis in SM04 -> Goto -> Memory -> Sort on Mem(Total)
• STAT records historical in Task/Memory button
• Memory Inspector – Transaction: S_MEMORY_INSPECTOR
– Create/View & Compare Memory Snapshots

© 2016 IBM Corporation


79
IBM z Systems for SAP

Memory Management - EM

Key Issues for EM


• Use tools to trace back dominant users of memory, and analyse the
effectiveness of memory management in the code

• Once the bad performers are removed it is important to size EM area


large enough to prevent PRIV overflows, but not too large to become
system wide paging/swapping problems occurrence

• DISCLAIM allows EM to return unused memory to the OS

© 2016 IBM Corporation


80
IBM z Systems for SAP

Memory Management – EM high water

© 2016 IBM Corporation


81
IBM z Systems for SAP

Memory Management – EM blocks

© 2016 IBM Corporation


82
IBM z Systems for SAP

Memory Management – SM04 snapshot

© 2016 IBM Corporation


83
IBM z Systems for SAP

Agenda
 Prerequisite materials
 Background Summary
o Origin of SAP Performance Data

 z/OS Performance Management


o RMF (Resource Management Facility) – Detecting Key Bottlenecks

 DB2 for z/OS – DBMS and SQL Basics


o Basics and How Does SAP Utilize it

 DB2 Accounting and Statistics


o Identifying Bottlenecks and Analysis

 SAP Application Server


o Best Utilization and Optimization for Best Performance

 ABAP Programing Performance Perspective


 SAP BW Performance Perspective
o Performance Analysis & Star Joins Tuning

 Performance Roadmap
 Case Studies
© 2016 IBM Corporation
84
IBM z Systems for SAP

Programing Programing!

• Common pitfalls and errors in programming and


alternatives to these mistakes
• Writing code that is scalable and efficient and how to
avoid introducing flaws that potentially can grind a
system to a halt as it grows
• Ensuring customer code is written correctly to reflect
the underlying SAP data models in place
• How to implement appropriate code review techniques
to ensure these errors never make it into production
systems

© 2016 IBM Corporation


85
IBM z Systems for SAP

ABAP Programming
Before software can be
reusable it first has to be
usable. ~Ralph Johnson

Style distinguishes excellence


from accomplishment
~James Coplien

Simplicity carried to the


extreme becomes elegance
~Jon Franklin

http://www.eskimo.com/~hottub/software/programming_quotes.html

© 2016 IBM Corporation


86
IBM z Systems for SAP

ABAP Open SQL Basic Rules

Rule 1: hit set small

Rule 2: transferred data small

Rule 3: number of transfers small

Rule 4: search area small

Rule 5: take off database load


(when possible)

© 2016 IBM Corporation


87
IBM z Systems for SAP

ABAP SQL Rules of Thumb

Use WHERE whenever possible

SELECT * FROM MSEG.


CHECK MBLNR = lv_docno.
CHECK MJAHR >= lv_year.
... do something...
ENDSELECT.

SELECT * FROM table


WHERE MBLNR = lv_docno
AND MJAHR >= lv_year .
... do something ...
ENDSELECT.

© 2016 IBM Corporation


88
IBM z Systems for SAP

ABAP SQL Rules of Thumb

Use aggregate functions

sum = 0.
SELECT amount INTO amt
FROM tab WHERE year = '1996'.
sum = sum + amt.
ENDSELECT.

SELECT SUM( amount )


INTO sum FROM tab
WHERE year = '1996'.

© 2016 IBM Corporation


89
IBM z Systems for SAP

ABAP SQL Rules of Thumb

Do not use NOT clauses on ‘binary’ fields

SELECT *
FROM QALS
WHERE stat35 <> ‘X’
AND werks = lv_plant
AND herkunkt = ’01’.

SELECT *
FROM QALS
WHERE stat35 = space
AND werks = lv_plant
AND herkunkt = ’01’.

© 2016 IBM Corporation


90
IBM z Systems for SAP

ABAP SQL Rules of Thumb

Avoid nested SELECTs

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 view1 WHERE ...

OR

SELECT * FROM t1 INNER JOIN t2


ON t1~field1 = t2_field1
WHERE …

© 2016 IBM Corporation


91
IBM z Systems for SAP

Using ORDER BY vs. SORT

• ORDER BY
– ... does not force the DB to use a certain index!

– ... is sometimes a large overhead for the DB!

• Question: do you really need the data ordered?


• To get your data ordered:
– Usually: (small or mid-size data)
-> use the ABAP/4 statement SORT

– If you expect large amounts of data (> 1 GB):


-> let the DB do it - ORDER BY

© 2016 IBM Corporation


92
IBM z Systems for SAP

ABAP – Sample complex SQL

select afko~aufnr afpo~posnr afpo~matnr afko~aufpl afpo~kdauf


afpo~kdpos afko~aprio afpo~mill_oc_aufnr_u afko~atrkz
afpo~dwerk afko~gamng afko~gstrs JEST can not be in INNER JOIN
aufk~auart aufk~objnr aufk~bukrs because of the NOT EXIST
into table it_porders operation
from afko inner join afpo
on afko~aufnr = afpo~aufnr
inner join aufk
on afko~aufnr = aufk~aufnr
where afko~aufnr = '100' "Production Order number
and afko~gstrs = '200' "Schedule date range
and afpo~dwerk = '300' NOT EXIST operation eliminated
and aufk~bukrs = 'x' 95% of data
and not exists (select * from jest
where objnr = aufk~objnr
and stat IN ('I0009','I0045',’I0076’) ).

© 2016 IBM Corporation


93
IBM z Systems for SAP

ABAP Code - Common Pitfalls


* Get Basic Material and material description
select mara~matnr
mara~wrkst
makt~maktx
into corresponding fields of table l_it_mara
from mara join makt
on mara~matnr = makt~matnr At runtime, internal table is empty
for all entries in it_materials
where mara~matnr = it_materials-matnr
and makt~spras = it_materials-spras.

When the clause FOR ALL ENTRIES IN is used in an SQL


statement, and at runtime the internal table in question is
empty, the resulting SQL issued to the database will not
have the specified columns in the where clause. In this case
this will result in ALL entries being returned from MARA !!

© 2016 IBM Corporation


94
IBM z Systems for SAP

ABAP Code - Common Pitfalls

* Exit form if table IT_MATERIALS is empty.


if it_materials[] is initial.
exit.
endif.
* Get Basic Material and material description
select mara~matnr
mara~wrkst
makt~maktx
into corresponding fields of table l_it_mara
from mara join makt
on mara~matnr = makt~matnr
for all entries in it_materials
where mara~matnr = it_materials-matnr
and makt~spras = it_materials-spras.

Solution is to “simple detect” empty internal tables prior to


execution, and take appropriate action.

© 2016 IBM Corporation


95
IBM z Systems for SAP

Polling in custom code

submit rsbdcsub
with mappe = p_group
and return
exporting list to memory.
do.
select single * from apqi where qid = v_qid and
groupid = p_group and
datatyp = 'BDC' and
credate = sy-datum.
if sy-subrc = 0 and ( apqi-qstate = 'F' or apqi-qstate = 'E' ).
exit.
endif.
enddo.

This code is part of a custom routine that submits a BDC (Batch Data Communications) and waits
for it’s completion before continuing. At the initial go-live the data in the system resulted in an
almost instantaneous response. However as time has progressed, on a lot of occasions the BDC
takes from 5sec and up to 1 minute to return. The query on APQI is efficient (0.25 milliseconds)
but this means it executes ~4,000 per second while this is do loop running, and consumes a CPU
on the application server or DB server at any point in time.

© 2016 IBM Corporation


96
IBM z Systems for SAP

Polling in custom code


submit rsbdcsub
with mappe = p_group
and return
exporting list to memory.
do.
select single * from apqi where qid = v_qid and
groupid = p_group and
datatyp = 'BDC' and
credate = sy-datum.
if sy-subrc = 0 and ( apqi-qstate = 'F' or apqi-qstate = 'E' ).
exit.
else. " Insert wait period
wait up to 2 seconds. " Insert wait period
endif.
enddo.

This solution is extremely simple and elegant, simply putting the ABAP ‘to sleep’ for 2 seconds
each time an unsuccessful call is made to table APQI. Statistically this will add one second to the
batch job’s average runtime as on average the BDC will finish half way through the last 2 second
wait period.

© 2016 IBM Corporation


97
2,000,000
4,000,000
6,000,000
8,000,000
10,000,000
12,000,000

0
19/02/2007
20/02/2007
21/02/2007
22/02/2007
23/02/2007
24/02/2007
IBM z Systems for SAP

25/02/2007
26/02/2007
27/02/2007
28/02/2007
1/03/2007
2/03/2007
3/03/2007
4/03/2007
5/03/2007
6/03/2007
7/03/2007

© 2016 IBM Corporation


8/03/2007
APQI Database Reads

9/03/2007
10/03/2007
Polling Removal - Improvement

11/03/2007
12/03/2007
13/03/2007
14/03/2007
15/03/2007
16/03/2007
17/03/2007
18/03/2007
19/03/2007
20/03/2007
Series1

98
IBM z Systems for SAP

Nested LOOP problems

© 2016 IBM Corporation


99
IBM z Systems for SAP

Nested LOOP problems

* WA_KEY_NUM = 0. "case7525
LOOP AT ITAB_TCODE.
LOOP AT TLOG_USER.
ALERT_FOR_USER = SPACE.
CLEAR ALERTS_TAB.
* check mitigating control
*-Start of Modify----Ravi.S----09/09/2005-----------------------------*
IF PA_MIT = 'X'.
CLEAR: MIT_FLAG.
LOOP AT MIT_TAB.
IF ITAB_TCODE-ZVIRSODID CP MIT_TAB-ZVIRSODID AND
TLOG_USER-UNAME CP MIT_TAB-BNAME.
MIT_FLAG = 'X'.
EXIT.
ENDIF.
* READ TABLE MIT_TAB WITH KEY ZVIRSODID = ITAB_TCODE-ZVIRSODID
* BNAME = TLOG_USER-UNAME.
ENDLOOP.
* IF SY-SUBRC = 0.
IF MIT_FLAG = 'X'.
*-End of Modify----Ravi.S----09/09/2005-----------------------------*
CONTINUE.
ENDIF.
ENDIF.

© 2016 IBM Corporation


100
IBM z Systems for SAP

Agenda
 Prerequisite materials
 Background Summary
o Origin of SAP Performance Data

 z/OS Performance Management


o RMF (Resource Management Facility) – Detecting Key Bottlenecks

 DB2 for z/OS – DBMS and SQL Basics


o Basics and How Does SAP Utilize it

 DB2 Accounting and Statistics


o Identifying Bottlenecks and Analysis

 SAP Application Server


o Best Utilization and Optimization for Best Performance

 ABAP Programing Performance Perspective


 SAP BW Performance Perspective
o Performance Analysis & Star Joins Tuning

 Performance Roadmap
 Case Studies
© 2016 IBM Corporation
101
IBM z Systems for SAP

SAP BW Performance Perspective

• SAP BW System – Data Overview


– SAP_BWTOOLPGM_DB2

• Query Runtime Statistics


– RSDDSTAT_OLAP

• Query Processing
– Start Joins and Dynamic Indexing

© 2016 IBM Corporation


102
IBM z Systems for SAP

SAP BW System Overview (SAP_BWTOOLPGM_DB2)

The report provides answers to:

• How big are the ODS/PSA objects or cubes and


aggregates?

• Which of the BW objects (PSA/ODS/fact tables) are


partitioned and how many partitions do they have?

• Which are the widest fact tables? In which PSA table is


space wasted?

• What do the dimension cardinality of the cubes look like?

© 2016 IBM Corporation


103
IBM z Systems for SAP

Basic Cubes

© 2016 IBM Corporation


104
IBM z Systems for SAP

Basic Cubes – Buffer Pools

© 2016 IBM Corporation


105
IBM z Systems for SAP

PSA Tables

© 2016 IBM Corporation


106
IBM z Systems for SAP

Query Runtime Statistics (RSDDSTAT_OLAP)


An Option for Analyzing Statistics Data .. Easiest?!

© 2016 IBM Corporation


107
IBM z Systems for SAP

Query Runtime Statistics (RSDDSTAT_OLAP)

© 2016 IBM Corporation


108
IBM z Systems for SAP

Query Runtime Statistics (RSDDSTAT_OLAP)

© 2016 IBM Corporation


109
IBM z Systems for SAP

Query Runtime Statistics (RSDDSTAT_OLAP)

9000 Data Manager Event This event measures the time in the data manager if
the data manager is called from the OLAP. You can
find more detailed data in the data manager statistics
(table RSDDSTAT_DM). The times measured there do
not normally cumulate to the data manager time.

9010 Total Number of This event measures the number of transported


Transported Records records, aggregated from all read accesses (counter
(DBTRANS) event).

9011 Total Number of Read This event measures the number of read records,
Records (DBSEL) aggregated from all the read accesses (counter
event).

http://help.sap.com/saphelp_nw70/helpdata/en/45/f0488a1aa03115
e10000000a1553f7/content.htm

© 2016 IBM Corporation


110
IBM z Systems for SAP

Query Runtime Statistics (RSDDSTAT_OLAP)

© 2016 IBM Corporation


111
IBM z Systems for SAP

Complex Query Example


SELECT "S____637" , "S____566" , "S____581" , "S____561" , "S____565", "S____574" , "1ROWCOUNT" , "Z_BQ" , "Z_CNFCST" ,
"Z_COMMQ" , "Z_FCBP" , "Z_FCMK" , "Z_FCSLN" , "Z_NSQ" , "Z_RBQ" FROM ( SELECT "D5"."SID_Z_DOCTYP" AS "S___637"
,"X1"."S__Z_PROTIND" AS "S____566" ,"D6"."SID_Z_FACTWK" AS "S____581" ,"X2"."S__Z_BTGRPNO" AS
"S____561","X1"."S__Z_MODEL" AS "S____565" ,"X1"."S__Z_MAJCAT" AS "S____574" , COUNT( * ) AS "1ROWCOUNT" , SUM (
"F"."/BIC/Z_BQ" ) AS "Z_BQ" , SUM ("F"."/BIC/Z_CNFCST" ) AS "Z_CNFCST" , SUM ( "F"."/BIC/Z_COMMQ" ) AS "Z_COMMQ" , SUM (
"F"."/BIC/Z_FCBP" ) AS "Z_FCBP" , SUM ("F"."/BIC/Z_FCMK" ) AS "Z_FCMK" , SUM ( "F"."/BIC/Z_FCSLN" ) AS "Z_FCSLN" , SUM (
"F"."/BIC/Z_NSQ" ) AS "Z_NSQ" , SUM ("F"."/BIC/Z_RBQ" ) AS "Z_RBQ"
FROM "/BIC/FZIC_SFC" "F" ,"/BIC/DZIC_SFC5" "D5" ,"/BIC/DZIC_SFC3" "D3" ,"/BIC/XZ_PRODCD" "X1" ,"/BIC/DZIC_SFC6" "D6"
,"/BIC/DZIC_SFC1" "D1" ,"/BIC/XZ_SHIPTO" "X2" ,"/BIC/DZIC_SFCP" "DP" ,"/BI0/0600000005" "Z1"
WHERE "F"."KEY_ZIC_SFC5" = "D5"."DIMID"
AND "F"."KEY_ZIC_SFC3" ="D3"."DIMID"
AND "D3"."SID_Z_PRODCD" = "X1"."SID"
AND "F"."KEY_ZIC_SFC6" = "D6"."DIMID"
This is a typical SAP/BW
AND "F"."KEY_ZIC_SFC1" = "D1"."DIMID"
AND "D1"."SID_Z_SHIPTO" = "X2"."SID" query. How do you tune
AND "F"."KEY_ZIC_SFCP" = "DP"."DIMID" this?
AND "X2"."S__Z_BTGRPNO" = "Z1"."SID"
AND (((( "DP"."SID_0RECORDTP" = 0 )) AND (( "DP"."SID_0REQUID" <=76419 ))
AND (( "D5"."SID_Z_DOCTYP" <> 2000008999 ) AND NOT ("D5"."SID_Z_DOCTYP" = 6 ))
AND (( "D6"."SID_Z_FACTWK" BETWEEN 200327AND 200352 ))
AND (("X1"."S__Z_MAJCAT" IN (103, 119, 150, 98 )))
AND (("X1"."S__Z_PROTIND" <> 2000008999 ) AND NOT ( "X1"."S__Z_PROTIND" = 1))))
AND "X1"."OBJVERS" = 'A' AND "X2"."OBJVERS" = 'A' AND "Z1"."SID" <> 2000008999
GROUP BY "D5"."SID_Z_DOCTYP" ,"X1"."S__Z_PROTIND", "D6"."SID_Z_FACTWK" ,"X2"."S__Z_BTGRPNO", "X1"."S__Z_MODEL",
"X1"."S__Z_MAJCAT" ) "/BI0/0300422840" FOR FETCH ONLY WITH UR

© 2016 IBM Corporation


112
IBM z Systems for SAP

Complex Query Example


 How to simplify query analysis
 Given the size and complexity of the example query, some method
must be employed to simplify such a query.
 The following steps can be followed:
o Step 1
– Join Analysis - Building the join graph
o Step 2
– Associate local predicates
o Step 3
– Determine the filtering
o Step 4
– Compare with actual access path
o Step 5
– Consider alternatives to improve performance

© 2016 IBM Corporation


113
IBM z Systems for SAP

Complex Query Example - Step 1


 Join Analysis - Building the Join Graph
 Ignore the SELECT list
o We will assume all columns selected are required
– If generated SQL, then not much choice.
– If user-written, then double-check SELECT list.
 Ignore the FROM clause
o We will assume all tables listed are required
– As per SELECT list.
 Ignore the GROUP BY
o Syntax requires GROUP BY is equal to or superset of SELECT list
– Any column in the SELECT that is not contained within a column
function must be in GROUP BY
– Not all GROUP BY columns must be in SELECT list.
 Focus on the WHERE clause.

© 2016 IBM Corporation


114
IBM z Systems for SAP

Step 1 - Join Analysis


SELECT "S____637" , "S____566" , "S____581" , "S____561" , "S____565", "S____574" , "1ROWCOUNT" , "Z_BQ" , "Z_CNFCST" ,
"Z_COMMQ" , "Z_FCBP" , "Z_FCMK"Ignore SELECT
, "Z_FCSLN" , "Z_NSQ" List
, "Z_RBQ" FROM ( SELECT "D5"."SID_Z_DOCTYP" AS "S___637"
,"X1"."S__Z_PROTIND" AS "S____566" ,"D6"."SID_Z_FACTWK" AS "S____581" ,"X2"."S__Z_BTGRPNO" AS
"S____561","X1"."S__Z_MODEL" AS "S____565" ,"X1"."S__Z_MAJCAT" AS "S____574" , COUNT( * ) AS "1ROWCOUNT" , SUM (
"F"."/BIC/Z_BQ" ) AS "Z_BQ" , SUM ("F"."/BIC/Z_CNFCST" ) AS "Z_CNFCST" , SUM ( "F"."/BIC/Z_COMMQ" ) AS "Z_COMMQ" , SUM (
"F"."/BIC/Z_FCBP" ) AS "Z_FCBP" , SUM ("F"."/BIC/Z_FCMK" ) AS "Z_FCMK" , SUM ( "F"."/BIC/Z_FCSLN" ) AS "Z_FCSLN" , SUM (
"F"."/BIC/Z_NSQ" ) AS "Z_NSQ" , SUM ("F"."/BIC/Z_RBQ" ) AS "Z_RBQ"
Ignore FROM
FROM "/BIC/FZIC_SFC" "F" ,"/BIC/DZIC_SFC5" "D5" ,"/BIC/DZIC_SFC3" Clause
"D3" ,"/BIC/XZ_PRODCD" "X1" ,"/BIC/DZIC_SFC6" "D6"
,"/BIC/DZIC_SFC1" "D1" ,"/BIC/XZ_SHIPTO" "X2" ,"/BIC/DZIC_SFCP" "DP" ,"/BI0/0600000005" "Z1"
WHERE "F"."KEY_ZIC_SFC5" = "D5"."DIMID"
AND "F"."KEY_ZIC_SFC3" ="D3"."DIMID"
AND "D3"."SID_Z_PRODCD" = "X1"."SID"
AND "F"."KEY_ZIC_SFC6" = "D6"."DIMID"
AND "F"."KEY_ZIC_SFC1" = "D1"."DIMID"
AND "D1"."SID_Z_SHIPTO" = "X2"."SID"
Focus on WHERE Clause
AND "F"."KEY_ZIC_SFCP" = "DP"."DIMID"
AND "X2"."S__Z_BTGRPNO" = "Z1"."SID"
AND (((( "DP"."SID_0RECORDTP" = 0 )) AND (( "DP"."SID_0REQUID" <=76419 ))
AND (( "D5"."SID_Z_DOCTYP" <> 2000008999 ) AND NOT ("D5"."SID_Z_DOCTYP" = 6 ))
AND (( "D6"."SID_Z_FACTWK" BETWEEN 200327AND 200352 ))
AND (("X1"."S__Z_MAJCAT" IN (103, 119, 150, 98 )))
AND (("X1"."S__Z_PROTIND" <> 2000008999 ) AND NOT ( "X1"."S__Z_PROTIND" = 1))))
AND "X1"."OBJVERS" = 'A' AND "X2"."OBJVERS" = 'A' AND "Z1"."SID" <> 2000008999
Ignore GROUP "D6"."SID_Z_FACTWK"
GROUP BY "D5"."SID_Z_DOCTYP" ,"X1"."S__Z_PROTIND", BY ,"X2"."S__Z_BTGRPNO", "X1"."S__Z_MODEL",
"X1"."S__Z_MAJCAT" ) "/BI0/0300422840" FOR FETCH ONLY WITH UR

© 2016 IBM Corporation


115
IBM z Systems for SAP

Complex Query Example - Step 1

 Join Analysis - Building the Join Graph

 Focus on the WHERE clause

o Join predicates first


–Take each join predicate and map the table join relationship
–Continue adding each join relationship to the map (or join graph)

o Defer local predicates until next step

o Check that all FROM clause tables are accounted for in join graph
–Thus each table has at least one join predicate

© 2016 IBM Corporation


116
IBM z Systems for SAP

Step 1 - Join Analysis


WHERE "F"."KEY_ZIC_SFC5" = "D5"."DIMID"
AND "F"."KEY_ZIC_SFC3" ="D3"."DIMID"
AND "D3"."SID_Z_PRODCD" = "X1"."SID"
Focus on Join Predicates
AND "F"."KEY_ZIC_SFC6" = "D6"."DIMID"
AND "F"."KEY_ZIC_SFC1" = "D1"."DIMID"
AND "D1"."SID_Z_SHIPTO" = "X2"."SID"
AND "F"."KEY_ZIC_SFCP" = "DP"."DIMID"
AND "X2"."S__Z_BTGRPNO" = "Z1"."SID"
AND (((( "DP"."SID_0RECORDTP" = 0 ))
AND (( "DP"."SID_0REQUID" <=76419 )) Defer Local Predicates
AND (( "D5"."SID_Z_DOCTYP" <> 2000008999 ) to later
AND NOT ("D5"."SID_Z_DOCTYP" = 6 ))
AND (( "D6"."SID_Z_FACTWK" BETWEEN 200327AND 200352 ))
AND (("X1"."S__Z_MAJCAT" IN (103, 119, 150, 98 )))
AND (("X1"."S__Z_PROTIND" <> 2000008999 )
AND NOT ( "X1"."S__Z_PROTIND" = 1))))
AND "X1"."OBJVERS" = 'A'
AND "X2"."OBJVERS" = 'A'
AND "Z1"."SID" <> 2000008999
© 2016 IBM Corporation
117
IBM z Systems for SAP

Step 1 - Building the Join Graph


D5
F
WHERE "F"."KEY_ZIC_SFC5" = "D5"."DIMID"

D5
F

AND "F"."KEY_ZIC_SFC3" ="D3"."DIMID" D3

D5
F
AND "D3"."SID_Z_PRODCD" = "X1"."SID"
D3 X1

© 2016 IBM Corporation


118
IBM z Systems for SAP

Step 1 - Building the Join Graph D5


F
AND "F"."KEY_ZIC_SFC6" = "D6"."DIMID" D3 X1
D6

AND "F"."KEY_ZIC_SFC1" = "D1"."DIMID" D5


F
D1
D3 X1
D6
AND "D1"."SID_Z_SHIPTO" = "X2"."SID" D5
F
X2 D1
D3 X1
D6
© 2016 IBM Corporation
119
IBM z Systems for SAP

Step 1 - Building the Join Graph DP


D5
F
X2 D1
D3 X1
AND "F"."KEY_ZIC_SFCP" = "DP"."DIMID" D6

AND "X2"."S__Z_BTGRPNO" = "Z1"."SID" DP


D5
F
Z1 X2 D1
D3 X1
D6

© 2016 IBM Corporation


120
IBM z Systems for SAP

Step 1 - Final Join Graph

DP
D5
Z1 X2 D1 F

D3 X1
D6

© 2016 IBM Corporation


121
IBM z Systems for SAP

Step 2 - Associate the Local Predicates


WHERE "F"."KEY_ZIC_SFC5" = "D5"."DIMID"
AND "F"."KEY_ZIC_SFC3" ="D3"."DIMID"
AND "D3"."SID_Z_PRODCD" = "X1"."SID"
AND "F"."KEY_ZIC_SFC6" = "D6"."DIMID" Map each local predicate to
AND "F"."KEY_ZIC_SFC1" = "D1"."DIMID" the appropriate table on the
AND "D1"."SID_Z_SHIPTO" = "X2"."SID"
AND "F"."KEY_ZIC_SFCP" = "DP"."DIMID"
join graph
AND "X2"."S__Z_BTGRPNO" = "Z1"."SID"
AND (((( "DP"."SID_0RECORDTP" = 0 ))
AND (( "DP"."SID_0REQUID" <=76419 ))
AND (( "D5"."SID_Z_DOCTYP" <> 2000008999 )
AND NOT ("D5"."SID_Z_DOCTYP" = 6 ))
AND (( "D6"."SID_Z_FACTWK" BETWEEN 200327AND 200352 ))
AND (("X1"."S__Z_MAJCAT" IN (103, 119, 150, 98 )))
AND (("X1"."S__Z_PROTIND" <> 2000008999 ) Associate the Local
AND NOT ( "X1"."S__Z_PROTIND" = 1)))) Predicates
AND "X1"."OBJVERS" = 'A'
AND "X2"."OBJVERS" = 'A'
AND "Z1"."SID" <> 2000008999
© 2016 IBM Corporation
122
IBM z Systems for SAP

Step 2 - Associate Local Predicates


AND "D5"."SID_Z_DOCTYP" <> 2000008999
AND NOT "D5"."SID_Z_DOCTYP" = 6
AND "DP"."SID_0RECORDTP" = 0
AND "DP"."SID_0REQUID" <=76419 DP
D5
AND "Z1"."SID" <> 2000008999

F
Z1 X2 D1
AND "X2"."OBJVERS" = 'A'
D3 X1

AND "D6"."SID_Z_FACTWK" D6 AND "X1"."S__Z_MAJCAT" IN (103, 119, 150, 98 )


BETWEEN 200327AND 200352 AND "X1"."S__Z_PROTIND" <> 2000008999
AND NOT "X1"."S__Z_PROTIND" = 1
AND "X1"."OBJVERS" = 'A'

© 2016 IBM Corporation


123
IBM z Systems for SAP

Complex Query Example - Step 3

DP
D5
Z1 X2 D1 F
So where
should my
access path
D3 X
start? D6 1

© 2016 IBM Corporation


124
IBM z Systems for SAP

Complex Query Example - Step 3

 Determine the filtering

 Beginning with the outermost table

o Break apart the original query and count the number of rows
retrieved

o Move to the next innermost table and join to the previous


SELECT and produce the composite count

o Continue until the filtering predicates and tables are determined

© 2016 IBM Corporation


125
IBM z Systems for SAP

Step 3 - Determine the Filtering


Shows the
filtering of this
SELECT COUNT(*)
D6 predicate
FROM "/BIC/DZIC_SFC6" "D6"
WHERE "D6"."SID_Z_FACTWK" BETWEEN 200327 AND 200352

Shows the effect of


filtering against the fact F
table
SELECT COUNT(*)
FROM "/BIC/FZIC_SFC" "F" ,"/BIC/DZIC_SFC6" "D6"
WHERE "F"."KEY_ZIC_SFC6" = "D6"."DIMID" D6
AND "D6"."SID_Z_FACTWK" BETWEEN 200327AND 200352

© 2016 IBM Corporation


126
IBM z Systems for SAP

Step 3 - Determine the Filtering


SELECT COUNT(*) SELECT COUNT(*)
FROM "/BI0/0600000005" "Z1" FROM "/BIC/XZ_SHIPTO" "X2" ,"/BI0/0600000005" "Z1"
WHERE "Z1"."SID" <> 2000008999 WHERE "X2"."S__Z_BTGRPNO" = "Z1"."SID"
AND "X2"."OBJVERS" = 'A'
Z1 AND "Z1"."SID" <> 2000008999

Z1 X2
SELECT COUNT(*)
FROM "/BIC/DZIC_SFC1" "D1" ,"/BIC/XZ_SHIPTO" "X2" ,"/BI0/0600000005" "Z1"
WHERE "D1"."SID_Z_SHIPTO" = "X2"."SID"
AND "X2"."S__Z_BTGRPNO" = "Z1"."SID"
AND "X2"."OBJVERS" = 'A' Z1 X2 D1
AND "Z1"."SID" <> 2000008999
SELECT COUNT(*)
FROM "/BIC/FZIC_SFC" "F" ,"/BIC/DZIC_SFC1" "D1" ,"/BIC/XZ_SHIPTO" "X2" ,"/BI0/0600000005" "Z1"
WHERE "F"."KEY_ZIC_SFC1" = "D1"."DIMID"
AND "D1"."SID_Z_SHIPTO" = "X2"."SID" F
AND "X2"."S__Z_BTGRPNO" = "Z1"."SID" Z1 X2 D1
AND "X2"."OBJVERS" = 'A'
AND "Z1"."SID" <> 2000008999

© 2016 IBM Corporation


127
IBM z Systems for SAP

Step 3 - Determine the Filtering

SELECT COUNT(*)
FROM "/BIC/DZIC_SFC5" "D5"
WHERE "D5"."SID_Z_DOCTYP" <> 2000008999
AND NOT "D5"."SID_Z_DOCTYP" = 6
D5

SELECT COUNT(*)
FROM "/BIC/FZIC_SFC" "F" ,"/BIC/DZIC_SFC5" "D5" D5
WHERE "F"."KEY_ZIC_SFC5" = "D5"."DIMID"
AND "D5"."SID_Z_DOCTYP" <> 2000008999
F
AND NOT "D5"."SID_Z_DOCTYP" = 6

© 2016 IBM Corporation


128
IBM z Systems for SAP

Step 3 - Determine the Filtering

SELECT COUNT(*)
FROM "/BIC/DZIC_SFCP" "DP"
WHERE "DP"."SID_0RECORDTP" = 0 DP
AND "DP"."SID_0REQUID" <=76419

DP
SELECT COUNT(*)
FROM "/BIC/FZIC_SFC" "F" ,"/BIC/DZIC_SFCP" "DP" F
WHERE "F"."KEY_ZIC_SFCP" = "DP"."DIMID"
AND "DP"."SID_0RECORDTP" = 0
AND "DP"."SID_0REQUID" <=76419

© 2016 IBM Corporation


129
IBM z Systems for SAP

Step 3 - Determine the Filtering

SELECT COUNT(*)
FROM "/BIC/XZ_PRODCD" "X1"
WHERE "X1"."S__Z_MAJCAT" IN (103, 119, 150, 98 ) X1
AND "X1"."S__Z_PROTIND" <> 2000008999
AND NOT "X1"."S__Z_PROTIND" = 1
AND "X1"."OBJVERS" = 'A'
SELECT COUNT(*)
FROM "/BIC/DZIC_SFC3" "D3" ,"/BIC/XZ_PRODCD" "X1"
WHERE "D3"."SID_Z_PRODCD" = "X1"."SID"
AND "X1"."S__Z_MAJCAT" IN (103, 119, 150, 98 )
AND "X1"."S__Z_PROTIND" <> 2000008999
AND NOT "X1"."S__Z_PROTIND" = 1 D3 X1
AND "X1"."OBJVERS" = 'A'
SELECT COUNT(*)
FROM "/BIC/FZIC_SFC" "F" ,"/BIC/DZIC_SFC3" "D3" ,"/BIC/XZ_PRODCD" "X1"
WHERE "F"."KEY_ZIC_SFC3" ="D3"."DIMID"
AND "D3"."SID_Z_PRODCD" = "X1"."SID"
AND "X1"."S__Z_MAJCAT" IN (103, 119, 150, 98 )
F
AND "X1"."S__Z_PROTIND" <> 2000008999
AND NOT "X1"."S__Z_PROTIND" = 1
AND "X1"."OBJVERS" = 'A'
D3 X1
© 2016 IBM Corporation
130
IBM z Systems for SAP

Step 4 - Compare with Actual Access Path

Join Sequence Count with Table CARDF % Rows


Filtering Returned
Z1 13 13 100%
Z1-X2
Z1-X2-D1
Z1-X2-D1-F
X1
26,514
171,787
1,702,101
258
353,413
1,565,004
10,743,216
43,511
7.50%
10.98%
15.84%
0.59%
} #3

X1-D3
X1-D3-F
DP
281
511,179
432
30,932
10,743,216
432
0.26%
4.76%
100%
} #1

DP-F 10,743,216 10,743,216 100% } No Filtering


D5 598 598 100%
D5-F 10,743,216 10,743,216 100% } No Filtering
D6 37 423 8.75%
D6-F 1,317,164 10,743,216 12.26% } #2

© 2016 IBM Corporation


131
IBM z Systems for SAP

Step 4 - Compare with Actual Access Path

100% 100%
DP
15.84%
D5
Z1 X2 D1 F 4.76%

D3 X
D6 1
So where should my
12.26% access path start?

© 2016 IBM Corporation


132
IBM z Systems for SAP

Complex Query Example - Step 5


 Consider alternatives to improve performance
 Indexing
o Given knowledge of star join index directed access paths
– Do indexes on fact table support the preferred join sequence?
o Evaluate standard index design for joins
– Do indexes support the join columns?
 Statistics
o Are statistics correct and current?
o Are columns correlated?
– KEYCARD/COLGROUP options of RUNSTATS

© 2016 IBM Corporation


133
IBM z Systems for SAP

Performance - Performance Layers


 Performance Layers

Offline Analysis

Performance
Pre-Calculation

OLAP Cache

Aggregates / IDAA Reuse

InfoCubes
© SAP 2013 / Page 134

© 2016 IBM Corporation


IBM z Systems for SAP

IBM DB2 Analytic Accelerator

 DB2 Accelerator
o DB2 component based on Netezza technology
o Appliance solution, including servers, discs, software and hardware
o Data is replicated to the DB2 Accelerator to accelerate SQL queries by factors
o Application tables

 DB2 Accelerator support is integral part of SAP BW


o Control Center as frontend (next slide)
o Integrated in OLAP Processor and Data Manager

For more information, see SAP Note 894045

© SAP 2013 / Page 135

© 2016 IBM Corporation


IBM z Systems for SAP

IBM DB2 Analytic Accelerator: Control Center


 Transaction DB2ACCEL
 Add and maintain objects in DB2
Accelerator
o InfoCube
o Data Store Object
o Master Data (InfoObject)
o Application tables
 Data status calculation based on real
time statistics and SAP BW control
tables
o "red": Table does not exist in DB2
Accelerator or status is initial
o "yellow": Table exists in DB2
Accelerator, but data is not current
o "green": Table data in DB2 Accelerator is
most current
 Schedule load to DB2 Accelerator on
o Table level
o Object level
o Folder level

© SAP 2013 / Page 136

© 2016 IBM Corporation


IBM z Systems for SAP

Questions?

© 2016 IBM Corporation


137

Vous aimerez peut-être aussi