2. Introduction
Stored Procedures, User Defined Functions and Triggers, collectively called “routines”, have been an integral
part of the programming inventory for some time. Depending upon your Application Programming Architecture
some routines, such as WLM-Managed External Stored Procedures, will run outside of DB2. Others, notably
Native SQL Stored Procedures and triggers, execute within a DB2 managed address space and as a result you
have more control over how they perform. Tuning such internal routines is often very similar to tuning any other
packages or SQLs but there are some significant differences too. For instance Non-SQL CPU used by a WLM
Managed Cobol Stored Procedure which does a lot of CPU Intensive work using a complex business Algorithm is
charged to the Allied Address Space (AS), whereas a native SQL procedure with the same complexity increases
the CPU usage of the DBM1 AS. Both behaviors require different measuring and tuning techniques. During this
discussion we’ll focus how to use Apptune for DB2 reports to understand where the Stored Procedures (SPs)
are executing externally or internally with respect to DB2. We will then show how to tell what program or plan is
calling the stored procedure.
Is it External or Native Stored Procedure?
Before drilling down into any SP in an APPTUNE for DB2 online report, it’s a good idea to identify whether the
procedure is executing as an External SP or Native SQL SP. The “Pgm Type” column value STPR means Stored
Procedure in the reports as you can see in the example below.
Drilling down using the Details option (T) of the Program Analysis you will see the “SQL STATEMENT DETAIL
ANALYSIS” screen. At the bottom of this there is a section called “Stored Procedure/WLM Address Space”. If you
can see values other than zero in “Elapsed Time” or “Total SQL operations”, then this tells you that you’re looking
at an External Stored Procedure.
1
3. For instance in the example above the GET_DAILY_TOTAL_CUST_GROUP (the name has been truncated
to GET_DA>>) procedure is an WLM Managed External Stored Procedure, whereas the screen shot below
is from another procedure’s detail and the values circled in red here indicate that this is a Native SQL SP
Sometimes it is important to know from where a procedure is CALLed or invoked. For instance a SP can be called
from Distributed Environment through DDF, from a Batch job, or from an online CICS or IMS/TM program using
Cobol. From a tuning perspective it’s important to know the caller’s application environment. For instance if we
use the ( P ) Plan drilldown of the first SP whose name is GET_DA>>, we see a PLAN named POINET as follows.
This tells us that the Procedure is NOT being called from a standard Distributed Environment because if it was the
plan name would be DISTSERV.
2
4. It is also important to distinguish the type of incoming transactions. For instance what is the percentage
of incoming workload from Distributed compared to Batch/CICS/IMS? Knowing this percentage helps you
to focus on which section of the DB2 Subsystem needs more tuning. The following secreen shot is a PLAN
ANALYSIS report of 2-way datasharing group. As you’ll see from one hour consolidated report more than
90% of the work this group is processing are Distributed Transactions coming from DDF.
3
5. About the Author
IBM Champion Cuneyt Goksu is an independent DB2 specialist and IBM Gold Consultant
since 2009. His main activity is linked to DB2 for z/OS and LUW Installation, Migration,
Administration and Performance Tuning. He has presented papers at several conferences,
local events and writing articles for IT magazines. Cuneyt is currently a member IDUG Board
of Directors, he is the leader of Turkish DB2 Users Group and IBM Authorized DB2 Training
Partner. Cuneyt can be reached at cuneytgoksu@usa.net
4