Upload
tess98
View
1.424
Download
1
Tags:
Embed Size (px)
Citation preview
IBM Software Group
© IBM Corporation
DB2 for z/OS Stored Procedure Performance –Language / API Comparison
Session Number TDZ – 2296AGopal Krishnan, Todd Munk
DB2 for z/OS Performance
IBM Silicon Valley Lab, San Jose, CA
December 2008
IBM Software Group
© IBM Corporation
Stored Procedure Overview
Stored Procedure Performance Checklist
Customer reasons for the study
Languages/API’s to be discussed
Workload & Environment description
Pros and cons of each language/API
Performance and Cost comparison
IBM Software Group
© IBM Corporation
It is a user-written program that can be called by an application with an SQL CALL statement.
It is a compiled program that is stored at a DB2 server, and can execute SQL statements.
Stored procedures can be called:
– locally (on the same system where the application runs) and
– remotely (from a different system).
• Reducing the traffic of information across the communication network
• Splitting the application logic and encouraging an even distribution of the computational workload
• Providing an easy way to call a remote program
IBM Software Group
© IBM Corporation
Processing without & with Stored Procedures
The same SQL previously executed by the client has been stored on the server andis called by the client whenever necessary. The invocation is treated as a regular external call:
•The application waits for te stored procedure to terminate• Parameters can be passed back and forth
IBM Software Group
© IBM Corporation
Modularity in application development
Data will be processed always in a consistent way according to the rules defined in the stored procedure
Reduced network traffic for distributed applications
– Typical application requires two trips across the network for each SQL statement
– Grouping SQL statements into a stored procedure results in two trips across the network for each group of statement, resulting in better performance for applications
Improved application security
– Sensitive business logic runs on the DB2 server
– End users do not need table privilege
IBM Software Group
© IBM Corporation
Access to features that exist only on the server:– Stored procedures can have access to commands that run
only on the server.
– They might have the advantages of increased memory and disk space on server machines.
– They can access any additional software installed on the server.
Enforcement of business rules:– You can use stored procedures to define business rules that
are common to several applications.
– This is another way to define business rules, in addition to using constraints and triggers.
IBM Software Group
© IBM Corporation
Application integration solutions:– You can use stored procedures to easily access non-DB2 resources.
– With the use of WebSphere® MQ, you can coordinate accesses to multiple data and platforms.
Cost of ownership reduction– DRDA® activity is a candidate for zIIP redirect.
– Stored procedures written in Java can take advantage of zAAP engines
– Native SQL procedures have richer SQL functions and remote native SQL procedures, running as enclaves in DBM1 address space, are candidate for zIIP redirect with DB2 9 for z/OS.
IBM Software Group
© IBM Corporation
What is common to all Stored Procedures called via DRDA ?
Portion of distributed workload that comes in via DRDA is eligible for zIIP redirect. This includes:
– Call statement processing
– Result set processing
– Commit processing
For WLM managed stored procedures:
– SQL processing runs under a TCB hence not eligible for zIIPredirect.
For Native SQL procedures:
– Execution is under an enclave SRB, thus zIIP eligible
IBM Software Group
© IBM Corporation
Stored Procedure Performance ChecklistConsider overhead of each invocation
– Recommend more SQL Calls per Stored Procedure
Avoid metadata SPs
Use the SP authorization cache (zparm CACHERAC)
Don’t println() / DISPLAY in production
Use PROGRAM TYPE SUB
Separate WLM Enviornments for different LE runtime options
Use STAY RESIDENT YES
Use SECURITY DB2
No more than 512 SPs in one WLMENV
Don’t use JSPDEBUG in production
Make sure the JVM is not destroyed between invocations
Use a non-resettable JVM
Java Considerations:
IBM Software Group
© IBM Corporation
External high level language procedures– COBOL, PL/I, C, C++, Assembler, REXX, and Java
External SQL language procedures
Native SQL language stored procedures– Introduced by DB2 9 for z/OS
IBM Software Group
© IBM Corporation
Some customer reasons for looking at alternative languages
To leverage potential cost savings of zIIP and zAAP assist processors.
Productivity and manageability improvements available with new enterprise level tooling.
Redesigning some applications and want to investigate viability of moving to a different language during redesign.
Specific language programming skills dwindling and hard to acquire/replace.
All of the above.
IBM Software Group
© IBM Corporation
What Languages/API’s will be discussed ?
COBOL
C/C++
JDBC
SQLJ
External SQL
Native SQL
IBM Software Group
© IBM Corporation
Performance Evaluation Environmentz/OS 1.9
DB2 9 for z/OS
IBM Driver for SQLJ and JDBC Type 4 clients
3 CP’s, 2 zIIPs, 2 zAAPs
8 GB’s of memory
COBOL
– Enterprise COBOL for z/OS compiler V4R1
External SQL/C/C++
– z/OS XL C/C++ compiler
JDBC/SQLJ
– JDK 1.4.2, non-resetable JVM, NUMTCB=20
IBM Software Group
© IBM Corporation
The IBM Relational Warehouse workload (IRWW)
IRWW is an OLTP workload consisting of 7 transactions in support of a product warehouse, customer order, and order delivery system.
Each transaction consists of roughly 25 DML on average with 7 of those being Insert/Update/Delete.
All Stored Procedures are written using static SQL with the exception of JDBC.
IBM Software Group
© IBM Corporation
IRWW workload used for Comparison7 OLTP transactions
DML distribution for the workload :SQL DML AVERAGE-------- --------SELECT 3.65INSERT 2.80UPDATE 3.63MERGE 0.00DELETE 0.20
DESCRIBE 0.00DESC.TBL 0.00PREPARE 0.00 OPEN 4.41FETCH 8.50CLOSE 2.53
DML-ALL 25.72
IBM Software Group
© IBM Corporation
IBM Software Group
© IBM Corporation
COBOL
Pros
– Excellent throughput performance.
– Robust development language.
– Low billable cost.
Cons
– Runs as WLM managed.
– Not eligible for zAAP redirect.
– Future availability of COBOL development resources.
IBM Software Group
© IBM Corporation
C/C++
Pros
– Best performance.
– Robust development language.
– Low billable cost
• Lower than COBOL
– Future availability of C/C++ development resources
– Portable
Cons
– Runs as WLM managed
– Not eligible for zAAP redirect.
IBM Software Group
© IBM Corporation
SQLJPros
– zAAP specialty engine eligible.
– Robust development language.
– Future availability of Java development resources.
– Portable.
– Wide variety of development tools.
– Easy to code.
– Benefits of Static SQL
Cons
– Runs as WLM managed.
– Higher billable cost.• Above COBOL
IBM Software Group
© IBM Corporation
JDBC
Pros
– zAAP specialty engine eligible.
– Robust development language.
– Future availability of Java development resources.
– Portable.
– Wide variety of development tools.
– Easy to code
• More complex than SQLJ
Cons
– Runs as WLM managed.
– Highest billable cost.
• Above External SQL.
– Dynamic SQL.
IBM Software Group
© IBM Corporation
External SQL
Pros
– Portable.
– Easy to code.
– Can be migrated to native SQL in DB2 9 for z/OS
Cons
– Runs as WLM managed.
– Not a robust development language.
– Not eligible for zAAP redirect.
– Higher billable cost.
• Above SQLJ
IBM Software Group
© IBM Corporation
Native SQLPros
– Higher zIIP redirect.
– Portable.
– Easy to code.
– Excellent performance.
– Lowest billable cost.
– Enhanced SQL support :• FOR Loops, nested compound statements• More data types (BIGINT,BINARY,VARBINARY,DECFLOAT)• Versioning support.
Cons
– Not a robust development language.
– Requires DB2 9 for z/OS
– Not eligible for zAAP redirect.
IBM Software Group
© IBM Corporation
What is the difference between External and Native SQL procedures?
External SQL
– Parsed and translated into C.
– Runs as a C stored procedure.
– WLM managed.
Native SQL
– Broken down into runtime structures like any other SQL statement.
– Does not run in a WLM environment.
– Runs under DBM1 enclave SRB, thus zIIP eligible.
IBM Software Group
© IBM Corporation
When is it good to use SQL language? When is it bad?
Good when …
– SQL intensive
– Contains minimal application logic
– Lower billable cost and productivity are the most important priorities.
Bad when …
– Contains significant amount of apllication logic
– Executes math, string manipulation functions
– Many IF/WHILE/CASE/REPEAT statements
IBM Software Group
© IBM Corporation
Language Pros/Cons Comparison Summary
Below COBOL
Below SQLJ
Below External SQL
Below native SQL
Above COBOL
High
Th
rou
gh
pu
t P
erform
anc
eSignificant
zIIP
No zAAP
Some zIIP
zAAP
Some zIIP
zAAP
Some zIIP
No zAAP
Some zIIP
No zAAP
Some zIIP
Sp
ecialty E
ng
ine
Lowest
Above SQLJ
Above External SQL
Above COBOL
Below COBOL
Low
Billab
le Co
st
Yes
No
No
No
No
No
Ru
ns in
the
DB
En
gin
e
No
No
Yes
Yes
Yes
Yes
Ro
bu
st L
ang
uag
e
V9Native SQL
V8,V9SQLJ
V8,V9COBOL
V8,V9C/C++
V8,V9External SQL
V8,V9JDBC
Su
pp
orted
in
DB
2 V
ersion
IBM Software Group
© IBM Corporation
IBM Software Group
© IBM Corporation
Language / API CPU Cost comparisonfor IRWW Workload
0.65x (Significant zIIP)1.14xNative SQL Stored Proc
1.15x (zAAP+ some zIIP) 1.7xSQLJ Stored Proc
0.88x (Some zIIP)1X (BASE)COBOL Stored Proc
0.83x (Some zIIP)0.95xC Stored Proc
1.49x (Some zIIP) 1.62x External SQL Stored Proc
1.76x (zAAP+ some zIIP)2.95xJDBC Stored Proc
Billable CPU/Tran Cost after zIIP and/or zAAP redirect
Base CPU/Tran CostLanguage/API
IBM Software Group
© IBM Corporation
IBM Software Group
© IBM Corporation
Choose the language based on your priorities and needs…
Priorities
– Throughput Performance
– Billable CPU Cost
– Productivity
– Future availability of development resources
IBM Software Group
© IBM Corporation
Suggested languages based on top two priorities
Cost /Productivity
Productivity /Dev. Resources
Dev. Resources / Performance
Performance /Cost
Native SQL, SQLJC, SQLJ
Native SQL,C, COBOL
SQLJ, JDBC, C
IBM Software Group
© IBM Corporation
Stored Procedure Tool Links:
Rational Developer for System Z– http://www-01.ibm.com/software/awdtools/rdz/about/?S_CMP=wspace
IBM Data Studio V1.2
– http://www-01.ibm.com/software/data/studio/
IBM Software Group
© IBM Corporation
© Copyright IBM Corporation [current year]. All rights reserved.U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
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 IBM’S 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, NOR SHALL HAVE THE EFFECT OF, CREATING ANY WARRANTIES OR REPRESENTATIONS FROM IBM (OR ITS SUPPLIERS OR LICENSORS), OR ALTERING THE TERMS AND CONDITIONS OF ANY AGREEMENT OR LICENSE GOVERNING THE USE OF IBM PRODUCTS AND/OR SOFTWARE.
IBM, the IBM logo, ibm.com, and DB2 are trademarks or registered trademarks of International Business Machines Corporation in the United States, other countries, or both. If these and other IBM trademarked terms are marked on their first occurrence in this information with a trademark symbol (® or ™), these symbols indicate U.S. registered or common law trademarks owned by IBM at the time this information was published. Such trademarks may also be registered or common law trademarks in other countries. A current list of IBM trademarks is available on the Web at “Copyright and trademark information” at www.ibm.com/legal/copytrade.shtml
Disclaimer
IBM Software Group
© IBM Corporation