You are on page 1of 41

IBM Software Group

DB2 for z/OS Stored Procedures Performance & Hot Topics

Nogi Simanjuntak, IBM SHARE session 1334 February 27, 2008


2008 IBM Corporation

IBM Software Group

Important Disclaimer
THE INFORMATION CONTAINED IN THIS PRESENTATION IS PROVIDED FOR INFORMATIONAL PURPOSES ONLY. WHILE EFFORTS WERE MADE TO VERIFY THE COMPLETENESS AND ACCURACY OF THE INFORMATION CONTAINED IN THIS PRESENTATION, IT IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. IN ADDITION, THIS INFORMATION IS BASED ON IBMS CURRENT PRODUCT PLANS AND STRATEGY, WHICH ARE SUBJECT TO CHANGE BY IBM WITHOUT NOTICE. IBM SHALL NOT BE RESPONSIBLE FOR ANY DAMAGES ARISING OUT OF THE USE OF, OR OTHERWISE RELATED TO, THIS PRESENTATION OR ANY OTHER DOCUMENTATION. NOTHING CONTAINED IN THIS PRESENTATION IS INTENDED TO, OR SHALL HAVE THE EFFECT OF:
CREATING ANY WARRANTY OR REPRESENTATION FROM IBM (OR ITS AFFILIATES OR ITS OR THEIR SUPPLIERS AND/OR LICENSORS); OR ALTERING THE TERMS AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT GOVERNING THE USE OF IBM SOFTWARE.

SHARE session 1334

2008 IBM Corporation

IBM Software Group

Agenda

Performance considerations Managing the environments Hot topics Java routines

SHARE session 1334

2008 IBM Corporation

IBM Software Group

Performance considerations

Consider path length of each invocation Tune the SQL statements

SHARE session 1334

2008 IBM Corporation

IBM Software Group

DB2 z/OS Stored Procedures and UserDefined Functions execution


DRDA or Java or Batch Client

DB2
EXEC SQL CALL PROGX Catalog Entry

WLM-SPAS

PROCLIB SPAS JCL

LE Enclave
Sched PROGX Execute SQL locally Execute SQL locally Return parms C1 rows (only stored procedures) PROGX: EXEC SQL OPEN C1 WITH RETURN EXEC SQL proc end. STEPLIB PDS/PDSE Load Library (PROGX)

z/OS

SHARE session 1334

2008 IBM Corporation

IBM Software Group

Should we use stored procedure locally?

When code reuse benefit outweigh overhead (additional 30K+ instructions) High overhead environment such as Java on z/OS Dynamic SQL but prefers static SQL

SHARE session 1334

2008 IBM Corporation

IBM Software Group

Nested and concurrent routines Multiple invocations of stored procedures/ UDFs requires multiple the resource
One task per routine Scheduling time for each routine

Cancel scenarios become more complex


Follow recommended order of events Current cancel maintenance: PK22811

SHARE session 1334

2008 IBM Corporation

IBM Software Group

Performance considerations Do not call the metadata routines SYSIBM.SQLPROCEDURECOLS Metadata stored procedure supplied by server Invoked implicitly by V8 CLI client
DB2 LUW client FP4: only invoked if first attempt fails

DescribeParam=0 in db2cli.ini Need proper data type assignments


SHARE session 1334 2008 IBM Corporation 8

IBM Software Group

Performance considerations Do not display/printf() in Production Display/printf() add debugging statements Put routine name, timestamps on messages Multiple routines output to SYSOUT: 02A abend
Runopts: 'MSGFILE(SYSOUT,,,, ENQ)'

Expensive

SHARE session 1334

2008 IBM Corporation

IBM Software Group

Interactive debugging IBM Debug Tool


www.software.ibm.com/awdtools/debugtool COBOL, C/C++, PL/I How-to: DB2 Application Programming and SQL Guide

SQL Procedures debugging in V8 Unified debugger support in V9


IBM Data Studio

SHARE session 1334

2008 IBM Corporation

10

IBM Software Group

Performance considerations

STAY RESIDENT YES PROGRAM TYPE SUB Different runopts on separate WLM Environment

SHARE session 1334

2008 IBM Corporation

11

IBM Software Group

STAY RESIDENT YES

Reentrant Stays in storage Subroutines not affected


May see many loads of subroutines

SHARE session 1334

2008 IBM Corporation

12

IBM Software Group

PROGRAM TYPE SUB


LE does less processing May help subroutines stay in storage Local variables need to be initialized on each invocation
SQL-INIT-FLAG in COBOL LINKAGE SECTION vs. WORKING STORAGE

Need to keep LE enclave


No STOP RUN in COBOL

Different runopts cause LE to build new enclave


Different runopts on separate W LM Environment
SHARE session 1334 2008 IBM Corporation 13

IBM Software Group

Performance considerations Use SP authorization cache ZPARM ROUTINE AUTH CACHE option on INSTALL DB2 PROTECTION PANEL If set to 0 no caching is done: catalog access on each invocation Default 100K Max 5M Max of 5 IDs cached for each routine
SHARE session 1334 2008 IBM Corporation 14

IBM Software Group

Performance considerations

Use Security DB2 If not accessing non-SQL resources No need to build special external security environment

SHARE session 1334

2008 IBM Corporation

15

IBM Software Group

Performance considerations

No more than 512 different load modules in one WLM environment 512 entries in table storing load module names No fancy replacement algorithm

SHARE session 1334

2008 IBM Corporation

16

IBM Software Group

Managing the environment

WLM-SPAS considerations WLM management of tasks Control runaways

SHARE session 1334

2008 IBM Corporation

17

IBM Software Group

WLM-SPAS considerations How many to define Sensitive applications TYPE SUB with special runopts Test/development Java Separate if need special JCL

SHARE session 1334

2008 IBM Corporation

18

IBM Software Group

WLM-SPAS considerations Need to refresh if code modified V WLM,APPLENV=<APPLENV>,REFRESH DB2 supplies WLM_RESFRESH SP
Use RACF Authority check Can be invoked remotely

STOP/START SP does not affect load modules in WLM-SPAS

SHARE session 1334

2008 IBM Corporation

19

IBM Software Group

WLM management of tasks

Pre-V8: Enough storage in WLMSPAS?


Too many tasks on NUMTCB Many successful with 40-60 If CPU-starved, may need to use less

V8: Tasks are managed by WLM


NUMTCB is max
SHARE session 1334 2008 IBM Corporation 20

IBM Software Group

WLM management of tasks 1 per system vs. no limit


no limit = managed by wlm

1 TCB per concurrent SP/UDF request?


No, managed by WLM Request queued, more responsive on workload spikes NUMTCB is max value

SHARE session 1334

2008 IBM Corporation

21

IBM Software Group

WLM Management of Tasks

How to control
-STOP PROC/FUNC -CANCEL THD WLM QUISCE

Manual Control
http://www-1.ibm.com/support/docview.wss? uid=swg21239743

SHARE session 1334

2008 IBM Corporation

22

IBM Software Group

Control runaways Use ASUTIME to control looping Specified on CREATE Monitored every 20 seconds If no ASUTIME specified and looping
-Cancel Thread wait couple mins Refresh WLM environment Cancel WLM address space as a last resort In the order above!
SHARE session 1334 2008 IBM Corporation 23

IBM Software Group

Hot Topics

zIIP and stored procedures Native SQL Procedure language Package Path

SHARE session 1334

2008 IBM Corporation

24

IBM Software Group

zIIP and Stored Procedures


TCB execution not eligible for redirect Processing on DDF SRB is eligible
Commit, result sets processings

SP benefits still applies


Less network trips Better concurrency Static sql package invoked from dynamic

DB2 9 Native SQL PL procedure zIIP eligible when invoked over DDF
SHARE session 1334 2008 IBM Corporation

25

IBM Software Group

Native SQL PL procedure language DB2 9 Eliminates Generated C code and compilation Fully integrated into DB2 engine Extensive support for versioning
VERSION keyword on CREATE PROCEDURE CURRENT ROUTINE VERSION special register ALTERs

SHARE session 1334

2008 IBM Corporation

26

IBM Software Group

Package Path on Create SP DB9 V8 provides special register to identify list of package collection
SET CURRENT PACKAGE PATH

DB9 added capability to specify during CREATE or ALTER


Does not need to be set by invoker Does not need program change

Simplified administration and management


SHARE session 1334 2008 IBM Corporation 27

IBM Software Group

Java Routines Performance Considerations zAAP Java shared classes Common JAR Tips

SHARE session 1334

2008 IBM Corporation

28

IBM Software Group

Java Routine Performance Considerations Similar considerations applies Consider path length for each invocation Tune the SQL statements Do not call metadata routines Use SP authorization cache Do not println() in production

SHARE session 1334

2008 IBM Corporation

29

IBM Software Group

Java Routine Performance Considerations

Use nonresettable JVM


Gone from JVM 5 Not used in DB2 9

Keep JVM alive between invocation


Test using JSPDEBUG

Do not use JSPDEBUG in production

SHARE session 1334

2008 IBM Corporation

30

IBM Software Group

Runtime Errors Uncaught SQL Exceptions


-443 SQLCODE Stored procedure not put in STOPABN

Other uncaught Java Exceptions


-4302 SQLCODE JVM is destroyed Stored procedure put in STOPABN

Developer should use try/catch/logic Print stack trace, fix problem


SHARE session 1334 2008 IBM Corporation 31

IBM Software Group

JSPDEBUG

Information that can be used to debug Java stored procedure


CLASSPATH JVM started, brought down

Enabled by JSPDEBUG DD statement Do not use on production

SHARE session 1334

2008 IBM Corporation

32

IBM Software Group

zAAP System z Application Assist Processor Runs Java workload (Java application code) Java stored procedures eligible Native system services (i.e.. I/O) not eligible

SHARE session 1334

2008 IBM Corporation

33

IBM Software Group

Java Shared Classes Java 5 Uses z/OS shared memory segments Parameter on JVM property file:
-Xscmx4M -Xshareclasses:name=myCache

Statistic
Java Xshareclasses:name=myCache,printStats

Destroy
Java Xshareclasses:name=myCache,destroy
SHARE session 1334 2008 IBM Corporation 34

IBM Software Group

Common JAR V8: Common routines have to be:


Included in each JAR that reference them, or Stored in HFS and included in CLASSPATH

DB2 9 can install common JAR once


Common routines packaged in common JAR Specifies other JARs can add it in search path SQLJ.ALTER_JAVA_PATH

SHARE session 1334

2008 IBM Corporation

35

IBM Software Group

Tips
JVM property startup options in ENVAR
Heap size example

"JVMPROPS=/u/<filename>" create a text file in HFS add this line to the file: -Xmx100M Support for envars > 254 chars in a separate HFS file: ENVAR("_CEE_ENVFILE=/u/<filename>"

SHARE session 1334

2008 IBM Corporation

36

IBM Software Group

Tips Support to direct output to dataset or HFS file


For println( ) debugging statements Java logging
//JAVAOUT DD PATH='/u/javasp/out/javaout.txt', // PATHOPTS=(ORDWR,OCREAT,OAPPEND), // PATHMODE=(SIRUSR,SIWUSR,SIRGRP,SIWGRP,SIROTH, SIWOTH) //JAVAERR DD PATH='/u/javasp/out/javaerr.txt', // PATHOPTS=(ORDWR,OCREAT,OAPPEND), // PATHMODE=(SIRUSR,SIWUSR,SIRGRP,SIWGRP,SIROTH, SIWOTH)

SHARE session 1334

2008 IBM Corporation

37

IBM Software Group

Handy Java UDF


CREATE FUNCTION SYSADM.JAVDRVV ( ) RETURNS VARCHAR(100) FENCED NO SQL LANGUAGE JAVA SPECIFIC JAVDRVV EXTERNAL NAME 'com.ibm.db2.jcc.DB2Version.getVersion' WLM ENVIRONMENT WLMJAVA NO EXTERNAL ACTION NO FINAL CALL PROGRAM TYPE SUB PARAMETER STYLE JAVA;
SHARE session 1334 2008 IBM Corporation 38

IBM Software Group

References Redbooks
www.redbooks.ibm.com SG24-7083 Through the call and beyond

DB2 for z/OS: www.ibm.com/software/ db2zos


Follow support link for FAQs

DB2 Developer Domain: www.ibm.com/ software/data/developer


SHARE session 1334 2008 IBM Corporation 39

IBM Software Group

DB2 UDB for z/OS information resources

Take advantage of the following information resources available for DB2 UDB for z/OS:

Information center http://publib.boulder.ibm.com/infocenter/dzichelp/index.jsp Information roadmap www.ibm.com/software/data/db2/zos/roadmap.html DB2 UDB for z/OS library page www.ibm.com/software/data/db2/zos/library.html Examples trading post www.ibm.com/software/data/db2/zos/exHome.html DB2 for z/OS support www.ibm.com/software/data/db2/zos/support.html Official Introduction to DB2 for z/OS www.ibm.com/software/data/education/bookstore

SHARE session 1334

2008 IBM Corporation

40

IBM Software Group

Summary

Performance considerations Managing the environments Hot topics Java routines


Nogi Simanjuntak, manogari@us.ibm.com
SHARE session 1334 2008 IBM Corporation 41

You might also like