db2 for zos stored procedures trends and technology

Upload: usersupreeth

Post on 03-Jun-2018

228 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    1/44

    2011 IBM Corporation

    DB2 for z/OS Stored Procedures Trends andTechnoo!"#o$ert CatteraIBMrfcatter%us&i$'&co'

    Bati'ore/(ashin!tonDB2 )sers *roup

    Dece'$er +, 2011

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    2/44

    2011 IBM Corporation

    -!enda

    . - ision of a 'odern DB2 for z/OS dataserin!

    s"ste'

    . - $rief reie of adances in DB2 for z/OS stored

    procedure functionait" since DB2 3. 4atie S56 procedures

    . So'e !oforard reco''endations

    . 7ints, tips, etc&

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    3/44

    2011 IBM Corporation

    - ision of a 'odern DB2 for z/OS dataserin! s"ste'

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    4/44

    2011 IBM Corporation

    DB2 data serer

    Stored procedures

    Data

    8aa appication

    serer 9(e$Sphere

    or (e$6o!ic or:;

    (indos/&4

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    5/44

    2011 IBM Corporation

    Points a$out the >ision? dia!ra'

    . The DB2 serer patfor' is not specifica" identified

    coud $e z/OS, or 6inu@, or )4IA, or (indos

    . - pet peee of 'ine

    . 5uit usin! >DB2? as shorthand for DB2 for z/OS and >)DB? asshorthand for DB2 for 6inu@/)4IA/(indos

    . Perpetuates the unhepfu notion DB2 for z/OS and DB2 for

    6)( inco'pati$iit", hereas fro' a cient/serer appication

    deeop'ent and architecture perspectie, the to DB2

    patfor's are irtua" identica

    . 8ust sa" >DB2?

    . If "ou ant to refer 'ore specifica" to a DB2 serer patfor', sa"

    >DB2 for z/OS? or >DB2 for 6)(?

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    6/44

    2011 IBM Corporation

    More on the ision dia!ra'

    . The DB2 serer is a pure data$ase serer there is no

    transaction 'ana!e'ent su$s"ste' on the serer

    . This has $een the standard setup for so'e ti'e in the

    distri$uted s"ste's ord. Mainfra'es ith DB2 often hae CICS or IMS, as e usua"

    $ecause the or!anization ran a DB2accessin! transactiona

    oroad $efore DB2 stored procedure functionait" as aaia$e

    . Static, sererside S56 9i'portant for scaa$iit"; can $e paca!ed in

    CICS or IMS transaction pro!ra's or in DB2 stored procedures. Man" 'ainfra'ers $eiee that "ou hae to hae CICS or IMS/TM to

    support a hi!hou'e DB2 for z/OS$ased transactiona oroad

    Not so

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    7/44 2011 IBM Corporation

    Mainfra'e

    M5 6istener

    Stored procedure

    DB2

    Messa!e

    M5 =ueue

    -nd a itte 'ore:

    . M5 is a er" i'portant part of the picture

    . 7o M5 and DB2 stored procedures can or to!ether

    . Cient pro!ra' puts a 'essa!e 9so'e infor'ation; on an M5 =ueue

    . - process caed the M5 6istener can perfor' an action in responseto a 'essa!e arriin! on a =ueue

    .

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    8/44 2011 IBM Corporation

    *reat use of M5 and DB2 SPs 91;

    . or data$ase updates that need to occur in nearreati'e $ut not s"nchronous" reatie to end user input

    . Possi$e e@a'pes custo'er chan!es persona infor'ation 9e&!&,

    address;, or 'aes an onine pa"'ent

    . )ser cics on >Su$'it,? input infor'ation captured in M5 'essa!e

    . -ppication can i''ediate" respond to end user ith 9for e@a'pe; >Eour

    update has $een receied and i $e appied to "our profie 'o'entari"?

    . Bacend DB2 data$ase updates ie" to occur ithin seconds

    . -danta!es of as"nchronous approach

    . Potentia" $etter enduser response ti'e 9er" fast rep" after >Su$'it?;

    . I'proed s"ste' aaia$iit" 9fro' userFs perspectie; if $acend

    data$ase serer is unaaia$e, 'essa!es si'p" accu'uate on =ueue

    and are processed hen data$ase serer is $ac onine

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    9/44 2011 IBM Corporation

    (orfo orchestration appication

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    10/44 2011 IBM Corporation

    - $rief reie of adances in DB2 for z/OS storedprocedure functionait" since DB2 3

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    11/44 2011 IBM Corporation

    MSTR

    z/OS

    DBM1 IRLM DDF SPAS.Stored procedure

    programs run here,

    using DB2 call attach

    acilit! interace

    3 stored procedures introduced

    . 4e address space DB2'ana!ed stored procedure

    address space 9aa SP-S;

    . - shortco'in! caer coud not fetch resuts of cursordecared and opened in a stored procedure

    . 7ad to use output para'eters 9not idea for resut sets ith

    indeter'inate nu'$er of ros, not feasi$e for ar!e resut sets;

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    12/44 2011 IBM Corporation

    MSTR

    z/OS

    DBM1 IRLM DDF DB2"managedSPAS.#se not

    recommended.$one in DB2 %

    &LM"managedSPAS ', (1

    SPAS ', (2

    SPAS ', ()

    &LM"managedSPAS *, (1

    H to si!nificant enhance'ents

    . Caer of a stored procedure can fetch ros fro' acursor decared and opened in the stored procedure

    . (6M'ana!ed stored procedure address spaces

    introduced

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    13/44 2011 IBM Corporation

    More on (6M'ana!ed SP-Ss. Eou can hae seera of the'

    . )sefu for stored procedure 'ana!e'ent and 'onitorin!

    . Ma"$e hae a SP-S for neer stored procedure pro!ra's

    . Ma"$e !roup stored procedures $" appication

    . (6M can auto'atica" fire up additiona instances of a !ienSP-S in response to oroad de'ands

    . Stored procedure tophase co''it capa$iit" ia ##S-

    . #ecoera$e resource serices attach faciit" re=uired for stored

    procedure pro!ra's e@ecutin! in a (6M'ana!ed SP-S

    . Coordinated co''it/ro$ac for update of DB2 S-M or DB2 M5

    . Proide support for stored procedures ritten in 8aa

    .

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    14/44 2011 IBM Corporation

    K and + DD6, S56P6, COMMIT

    . DB2 K C#

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    15/44 2011 IBM Corporation

    fe@i$e a$end i'it, (6M s"ner!"

    . Stored procedure a$end i'it can $e set at indiidua storedprocedure ee, ersus a DB2 su$s"ste'ide settin!

    . If a stored procedure a$ends n ti'es, paced in stopped status 9after

    $ein! fi@ed, restarted ia ST-#T P#OC

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    16/44

    2011 IBM Corporation

    N >natie? S56 procedures

    . -s far as IF' concerned, the 'ost i'portant adance

    in DB2 for z/OS stored procedure technoo!" since

    stored procedures ere introduced ith DB2 3

    Gets its own section in this presentation

    (DB2 10 stored procedure enhancements will be covered later in this session)

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    17/44

    2011 IBM Corporation

    4atie S56 procedures

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    18/44

    2011 IBM Corporation

    4atie S56 procedures $i! chan!e

    . Before S56 procedure turned into a C an!ua!e

    pro!ra' under the coers

    . #uns as an e@terna stored procedure in a (6M'ana!ed SP-S

    . 4otinDB2 part of a C pro!ra' !enera" consu'es 'ore CP)

    than does e=uiaent COBO6 code 9thou!h ess than 8aa;

    . - natie S56 procedure 9aaia$e $e!innin! ith DB2 N

    in ne function 'ode; is Just a paca!e a >runti'e

    structure? $ased on the S56 state'ents to $e e@ecuted

    . - natie S56 procedure runs in the DB2 data$ase serices

    address space 9DBM1;

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    19/44

    2011 IBM Corporation

    Use mythread.

    4atie S56 procedure efficienc" 91;

    . -n e@terna stored procedure runs under its on TCB

    . CaerFs tas 9TCB or S#B; is suspended, and stored proc tas uses

    caerFs thread for co''unication ith DB2

    . In so'e cases, there can $e processin! dea"s and a $uidup of DBM1 irtua

    stora!e consu'ption associated ith the sitchin! of threads fro' cain!pro!ra' tass to stored procedure tass

    . - natie S56 procedure runs under the cain! pro!ra'Fs tas

    . 4o =ueuin!, no dea"s reated to threadsitchin!

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    20/44

    2011 IBM Corporation

    4atie S56 procedure efficienc" 92;

    . or eer" S56 state'ent in an e@terna stored procedure

    9or an" other e@ternatoDB2, S56issuin! pro!ra';, an

    >addressa$iit" round trip? is re=uired

    . Pro!ra'Fs tas sitches addressa$iit" fro' >ho'e? address space

    9for e@terna S56 procedure, thatFs a (6M'ana!ed storedprocedure address space; to DB2 DBM1 for S56 e@ecution, then

    sitches $ac

    .

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    21/44

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    22/44

    2011 IBM Corporation

    The zIIP factor

    . zIIP speciat" 'ainfra'e en!ine that costs ess than a!enerapurpose processor and does not factor into softare

    pricin!

    . - natie S56 procedure is zIIPei!i$e if it is inoed ia a

    re'ote ca throu!h the DB2 Distri$uted Data aciit" 9DD;

    . (h" restricted to re'ote s& oca C-66s 9>oca C-66s? $ein! those that

    are issued $" pro!ra's runnin! on the sa'e serer as DB2;

    . Technica", $ecause DD re=uests run under encae S#Bs

    . M" opinion IBM is encoura!in! or!anizations to use DB2 for z/OS as a dataserer in 'utitier cientserer appication eniron'ents

    . -'ount of CP) processin! directed to a zIIP en!ine tends to

    $e around HH for natie S56 procedures caed throu!h DD

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    23/44

    2011 IBM Corporation

    T!pe o procedure Base cost +P#-tran. ost ater /IIP redirect

    COBO6 1A 9$ase; &A

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    24/44

    2011 IBM Corporation

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    25/44

    2011 IBM Corporation

    Simpleis good

    4atie S56 procedure ifec"ce

    . Si'per creation, 'ana!e'ent, 'aintenance ersuse@terna stored procedures

    . 4o e@ternatoDB2 resources inoed 9e&!&, no source /

    o$Ject / oad i$raries;

    . The natie S56 procedure paca!e is the e@ecuta$e, and it is storedin the DB2 director"

    . 4o e@ternatoDB2 processes inoed 9e&!&, no need for

    co'pie and in processes;

    . -'on! other !ood thin!s no orries a$out

    pro!ra'/paca!e coordination

    . 4atie S56 procedures hae a consistenc" toen 9used to

    'atch e@ternatoDB2 pro!ra's ith correspondin! paca!e;,

    $ut itFs Just a >s"non"'? for the procedureFs ersion ID

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    26/44

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    27/44

    2011 IBM Corporation

    *ettin! fro' here to there:

    . >There? $ein! a situation in hich "ouFre !ettin!'a@i'u' $enefit fro' the use of DB2 stored

    procedures

    . irst use stored procedures 9if not aread" doin! so;

    . If "ou are in a DB2 or DB2 N CM eniron'ent,code and depo" so'e S56 stored procedures to

    !ain fa'iiarit" ith their deeop'ent

    .

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    28/44

    2011 IBM Corporation

    If "ou use CICS:

    . Tr" 'ain! functionait" of one or 'ore CICSDB2 transactionsaaia$e to D#D- re=uesters ia stored procedure cas

    . - 'ore >open? a" to e@pose the transaction functionait"

    . Coud $e done $" conertin! COBO6 CICS pro!ra' to COBO6

    stored procedure 9often inoes itte chan!e;, or repicatin!transaction functionait" in S56 procedure

    . Coud aso inoe CICS transaction ia stored procedure

    . One option DS4-CICS stored procedure that co'es ith DB2

    . -ternatie code to CICS

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    29/44

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    30/44

    2011 IBM Corporation

    )sin! e@terna S56 procedures

    . *et fa'iiar and co'forta$e ith the different ifec"ce

    processes of natie S56 procedures

    . 4e D

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    31/44

    2011 IBM Corporation

    7ints, tips, etc&

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    32/44

    2011 IBM Corporation

    - co''on =uestion

    . >I thou!ht that hain! 'utipe (6M'ana!ed stored

    procedure address spaces as !ood for scaa$iit"& 4atie

    S56 procedures run in one address space onFt that

    hae a constrainin! effect on throu!hput?

    . -nser 4O, it i not

    . Thin a$out it a natie S56 procedureFs e@ecuta$e is a paca!e,

    and paca!es aa"s run in DBM1

    . If "ouFre runnin! 1000 CICSDB2 transactions per second fro' 'utipe

    CICS re!ions, each one has a paca!e that runs in DBM1

    . DonFt orr" a$out DBM1 >runnin! out of tass? a natie S56

    procedure runs under the caerFs tas, hich is e@terna to DBM1

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    33/44

    2011 IBM Corporation

    -nother co''on =uestion

    . >Mutipe stored procedure address spaces $oost aaia$iit"

    9e&!&, "ou can isoate ne stored procedures in their on

    address space;& (ith natie S56 procedures a runnin! in

    DBM1, onFt that ne!atie" i'pact appication sta$iit"

    . -nser 4O, it i not

    . Thin a$out it eer"thin! that e@ecutes in DBM1 is DB2!enerated,

    DB2'ana!ed code

    . Mutipe address spaces for e@terna stored procedures hep to protect the

    s"ste' fro' an error that 'i!ht e@ist in userritten code thatFs not apro$e' ith natie S56 procedures

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    34/44

    2011 IBM Corporation

    aa"s true? condition used to enter an I$ased hander 9I 1Q1T7!oin! natie?, chan!e these condition handers to co'pound S56

    state'ents set off $" B

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    35/44

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    36/44

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    37/44

    2011 IBM Corporation

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    38/44

    2011 IBM Corporation

    etchin! resut sets 91;

    . -n area in hich there is a !ood $it of confusion

    . E

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    39/44

    2011 IBM Corporation

    F5T6

    etchin! resut sets 92;

    . The stored procedure decares one or 'ore cursors

    (IT7 #

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    40/44

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    41/44

    2011 IBM Corporation

    etchin! resut sets 93;

    . The cain! pro!ra' issues an -66OC-T< C)#SO#

    state'ent for each resut set ocator aria$e na'ed in

    an -SSOCI-T< 6OC-TO#S state'ent

    . 4o need for the cursor na'e in an -66OC-T< C)#SO#

    state'ent to 'atch the na'e of the cursor decared in thecaed stored procedure

    . The cain! pro!ra' fetches ros fro' the resut sets,

    usin! the cursors na'ed in the -66OC-T< C)#SO#

    state'ents

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    42/44

    2011 IBM Corporation

    DB2 10 #

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    43/44

    2011 IBM Corporation

    Preious sideFs point, in a picture:

    . DB2 N

    . DB2 10

    Pro!ra' AE

    Stored proc -

    Stored proc BDECLARE C1 CURSOR

    C-66

    C-66

    WITH RETURN TO CALLER

    Pro!ra' AEStored proc -

    Stored proc B

    DECLARE C1 CURSOR

    C-66

    C-66

    WITH RETURN TO CALLER

    WITH RETURN TO CLIENT

  • 8/11/2019 DB2 for ZOS Stored Procedures Trends and Technology

    44/44

    #o$ert Catterarfcatter%us&i$'&co'

    Than7s or !our time8