81
Using SPUFI to Explore DB2 Using SPUFI to Explore DB2 Hints Mike Bell S HLS Technologies,Inc. May 20, 2008 • 2:45 P.M. –3:45 P.M. Platform: DB2 for Z/OS

Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

  • Upload
    lamcong

  • View
    216

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Using SPUFI to Explore DB2Using SPUFI to Explore DB2 Hints

Mike BellSHLS Technologies,Inc.

May 20, 2008 • 2:45 P.M. – 3:45 P.M.Platform: DB2 for Z/OS

Page 2: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Session V04_15897

Using SPUFI to Explore DB2 Hints

Mike BellHLS Technologies, Inc.g ,

[email protected]

2

Page 3: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

OverviewOverviewThe theory of hintsThe theory of hints• The pragmatics of hints• Requirements for using SPUFIequ e e ts o us g S U• SPUFI examples• Exposure in using hintsp g• Our Hint Management Solutions

3

Page 4: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

The Theory of Hints• Sometimes the optimizer needs help in finding the

correct index• Sometimes the optimizer needs help in picking the

correct access path• Changing the statistics are not always an option• The statistics changes needed for a correctly

changed access path are not always knownchanged access path are not always known

4

Page 5: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Catch 22 in the Theory• We are told to use query numbers to avoid the hint

number changing underneath us• The reason we have to revert to a hint is because

we can not modify the originating source even to insert q er n mbersinsert query numbers

• We will deal with the SQL sequence number in the examples and show a method for their use inexamples and show a method for their use in production later

5

Page 6: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

The Pragmatics of Hints• Hints are a method of suggesting an alternative to

the optimizer• The suggestion has to be valid• Not all access path options are accepted. e.g., MAXCOLS

• You must use a V6 or higher PLAN_TABLEO l hi t i ll d i bi d• Only one hint name is allowed in a bind

• You must bind for the hint to take effect

6

Page 7: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Requirements for using SPUFI• The DSNZPARM for hints needs to be turned on• The PLAN_TABLE must be at V6 or higher• You will need to add an index to the PLAN_TABLE• Be careful in V8 CM not to use the V8

PLAN_TABLE as you will be unable to add indexes as needed

7

Page 8: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Assumptions for our SPUFI Examplesp

• You are on a test or sandbox system where you may try things before working in a more production-like environment

• You either have hints turned on in your DSNZPARM orDSNZPARM or

• You have downloaded file Hints Utility from the HLS website to turn hints on and offHLS website to turn hints on and off

8

Page 9: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Unintentional Exposures in using Hints

• Most generated rebinds are unaware of the presence of hints and so rebinds drop the hint

• A bind of program changes will drop a hint unless the hint is specified in the Bind control statements

• Usually the person doing the rebinds is unaware of a• Usually the person doing the rebinds is unaware of a hint being present

• Often the programmer making changes is unaware of a hint being present

9

Page 10: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Setting up Hints using Spufi• SPUFI to do an INSERT• Building an INSERT using SPUFIg g• Testing your hint using SPUFI• SPUFI to INSERT (SELECT FROM)• What values do you have to include• What values are ignored• Some samples of error messages

10

Page 11: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Method 1INSERT INTO P390H.PLAN_TABLE

VALUES (327 , 1 , ' ' ,

'TEST01 ' , 1 , 0 ,

'PUBLIC ' ,

'S SCO S ' 1 ' ' 2 'SYSCOLUMNS ' , 1 , 'I ' , 2 ,

'PUBLIC ' ,

'DSNDCX01 ' , 'N' , 'N' , 'N' , 'N' , 'N' , 'N' , 'N' , 'N‘

'N' ,

' IS' , '2007121211104887' , ' ' , 'L' , ' ' , 0 ,

'2007-11-017.30.05.785661‘

'TESTCOLLX ' , , , , , , , ' ' , ' ' , ' ' , ' ' , ' ', ' ',

'SELECT' , '2007-12-12-11.10.48.870000' ,

'PRODHINT' ,' ')

11

Page 12: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

ResultsDSNT408I SQLCODE = -104, ERROR: ILLEGAL SYMBOL ",". SOME SYMBOLS THAT

MIGHT BE LEGAL ARE: ( + - ? : CASE CAST NULL USER <FLOAT> CURRENT DEFAULT <DECIMAL>

DSNT418I SQLSTATE = 42601 SQLSTATE RETURN CODEDSNT415I SQLERRP = DSNHPARS SQL PROCEDURE DETECTING ERROR DSNT415I SQLERRP = DSNHPARS SQL PROCEDURE DETECTING ERROR DSNT416I SQLERRD = 0 0 0 -1 489 0 SQL DIAGNOSTIC INFORMATION DSNT416I SQLERRD = X'00000000' X'00000000' X'00000000' X

'FFFFFFFF' X'000001E9' X'00000000' SQL DIAGNOSTIC INFORMATION

• Have to specify NULL not just multiple commas for null values

12

Page 13: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Method 2INSERT INTO P390H.PLAN_TABLE

VALUES(327 , 1 , ' ' ,

'TEST01 ' , 1 , 0 ,

'PUBLIC ' PUBLIC ,

'SYSCOLUMNS ' , 1 , 'I ' , 2 ,

'PUBLIC ',

'DSNDCX01 ' , 'N' , 'N' , 'N' , 'N' , 'N' , 'N' , 'N' , 'N' , 'N' , ' IS' , '2007121211104887' , ' ' , , , , , , , ,'L' , ' ' , 0 , '2007-11-05-17.30.05.785661' ,

'TESTCOLLX ' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , ' ' , ' ' , ' ' , ' ' , ' ' , ' ', ' ' ,

'SELECT' , '2007-12-12-11.10.48.870000' ,

'PRODHINT' ' ')'PRODHINT' ,' ')

13

Page 14: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Next ResultDSNT408I SQLCODE = -408, ERROR: THE VALUE IS NOT COMPATIBLE WITH THE

DATA TYPE OF ITS TARGET DSNT418I SQLSTATE = 42821 SQLSTATE RETURN CODE DSNT415I SQLERRP = DSNXOCAS SQL PROCEDURE DETECTING ERROR DSNT416I SQLERRD = -100 0 0 -1 0 0 SQL DIAGNOSTIC INFORMATION DSNT416I SQLERRD = X'FFFFFF9C' X'00000000' X'00000000'

X'FFFFFFFF' X'00000000' X'00000000' SQL DIAGNOSTIC INFORMATION

H ll t d I d t k it• How many null parameters do I need to make it line up?

14

Page 15: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Method 3INSERT INTO P390H.PLAN_TABLE

VALUES(327 , 1 ,' ' ,

'TEST01 ' , 1 , 0 ,

'PUBLIC ' ,

'SYSCOLUMNS ' , 1 , 'I ' , 2 , SYSCOLUMNS , 1 , I , 2 ,

'PUBLIC ',

'DSNDCX01 ' , 'N' , 'N' , 'N' , 'N' , 'N' , 'N', 'N' , 'N' , 'N' , ' IS' , '2007121211104887' , ' ' , 'L' , ' ' , 0 , '2007-11-05-17.30.05.785661' ,

'TESTCOLLX ' , NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL ,' ' , ' ' , ' ' , ' ' , ' ' , ' ', 'SELECT' , '2007-12-12-11.10.48.870000' , 'PRODHINT' ,' ' , ' ‘

15

Page 16: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Aha!DSNE615I NUMBER OF ROWS AFFECTED IS 1

DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

• And this was just to insert a row into PLAN_TABLE

16

Page 17: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

I was CheatingSELECT 'INSERT INTO P390H.PLAN_TABLE

VALUES('CONCAT CHAR(QUERYNO ) CONCAT ' , '

CONCAT CHAR(QBLOCKNO ) CONCAT ' , '''

CONCAT APPLNAME CONCAT ''' '''CONCAT APPLNAME CONCAT ''' , '''

CONCAT PROGNAME CONCAT ''' , '

CONCAT CHAR(PLANNO ) CONCAT ' , '

CONCAT CHAR(METHOD ) CONCAT ' , '''

CONCAT CREATOR CONCAT ''' '''CONCAT CREATOR CONCAT ,

CONCAT TNAME CONCAT ''' , '

• And continued with Columns and ConcatAnd continued with Columns and Concat

17

Page 18: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Select from PLAN_TABLESELECT FROM P390H.PLAN_TABLE

WHERE APPLNAME = ''

AND COLLID = 'TESTCOLLX'

AND PROGNAME = 'TEST01'

AND QUERYNO = 327

18

Page 19: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Some Comments on Building the Insert with SPUFI

• The default value for a text literal is VARCHAR• Means the maximum length is 255

DSNE612I DATA FOR COLUMN HEADER COLUMN NUMBER 1 WAS TRUNCATED

• Even with V7 the generated INSERT statementEven with V7 the generated INSERT statement was over 512 bytes

• Broke it into 3 SELECT statements• And put it together with edit

19

Page 20: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Other AlternativesCAST('INSERT INTO P390H.PLAN_TABLE VALUES(' AS VARCHAR (1024))

• Just for the first item in the SELECTJust for the first item in the SELECT• Makes the whole string LONG VARCHAR• Then you get to set the limit for SPUFIy g

11 MAX CHAR FIELD .. ===> 255 (Maximum width for character fields)

• Or use DSNTIAUL

20

Page 21: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Testing the HintSET CURRENT OPTIMIZATION HINT = 'PRODHINT';

EXPLAIN PLAN SET QUERYNO = 327

FOR SELECT NAME, TBNAME, COLNO, COLTYPE, LENGTH FROM PUBLIC.SYSCOLUMNS WHERE TBNAME = ?

;

21

Page 22: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

OOPS!DSNT404I SQLCODE = 20007, WARNING: USE OF OPTIMIZATION HINTS IS

DISALLOWED BY A DB2 SUBSYSTEM PARAMETER.THE SPECIAL REGISTER 'OPTIMIZATION HINT‘IS SET TO THE DEFAULT VALUE OF BLANKS.

DSNT418I SQLSTATE = 01602 SQLSTATE RETURN CODE

DSNT415I SQLERRP = DSNXRSQO SQL PROCEDURE DETECTING ERROR

DSNT416I SQLERRD 0 0 0 1 0 0 SQL DIAGNOSTIC INFORMATION DSNT416I SQLERRD = 0 0 0 -1 0 0 SQL DIAGNOSTIC INFORMATION

DSNT416I SQLERRD = X'00000000' X'00000000' X'00000000' X'FFFFFFFF' X'00000000' X'00000000' SQL DIAGNOSTIC INFORMATION

22

Page 23: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Fix it//HINTSON EXEC PGM=HINTON,PARM=DB7G

//STEPLIB DD DISP=SHR,DSN=DSN710.SDSNEXIT

• Available at www.hlstechnologies.com• Or you can assemble DSNZPARM and restart DB2

23

Page 24: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Hints onIEF236I ALLOC. FOR P390HT3 HINTSON

IEF237I 0A25 ALLOCATED TO STEPLIB

IEF142I P390HT3 HINTSON - STEP WAS EXECUTED - COND CODE 0000

IEF285I DSN710 SDSNEXIT KEPT IEF285I DSN710.SDSNEXIT KEPT

IEF285I VOL SER NOS= Z7DB71.

• Not much of a report but we do receive a pCondition code 0000

24

Page 25: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

RetrySET CURRENT OPTIMIZATION HINT = 'PRODHINT'; ---------+---------+---------+---------+---------+---------+---DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0 ---------+---------+---------+---------+---------+---------+-EXPLAIN PLAN SET QUERYNO = 327 FOR

SELECT NAME, TBNAME, COLNO, COLTYPE, LENGTH FROM PUBLIC.SYSCOLUMNS WHERE TBNAME ? WHERE TBNAME = ? ;

---------+---------+---------+---------+---------+---------+-DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

25

Page 26: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Why SQLCODE = 0 ?

If Collid =DSNESPCS If Collid DSNESPCS

Progname =DSNESM68

Queryno = what ever you test with (327)

26

Page 27: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Redo the Insert with DSNESM68 (SPUFI Program Name)( g )

INSERT INTO P390H.PLAN_TABLE VALUES(327 , 1 , ' ' , 'DSNESM68' , 1 , 0 ,

'PUBLIC ' , PUBLIC ,

'SYSCOLUMNS ' , 1 , 'I ' , 2 ,

'PUBLIC ' ,

'DSNDCX01 ' , 'N' , 'N' , 'N', 'N' , 'N' , 'N' , 'N' , 'N' , 'N' ,

' ' '2007121211104887' ' ' ' ' ' ' 0 ' IS' , '2007121211104887' , ' ' , 'L' , ' ' , 0 ,

'2007-11-05-17.30.05.785661' ,

'DSNESPCS ' , NULL , NULL , NULL , NULL , NULL , NULL,

NULL , NULL , ' ' , ' ' , ' ' , ' ' , ' ' ,' ' , 'SELECT' , '2007-12-12-11.10.48.870000' , 'PRODHINT' ,' ' , ' ' )

27

Page 28: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Still no goodSET CURRENT OPTIMIZATION HINT = 'PRODHINT'; ---------+---------+---------+---------+---------+---------+---STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0 ---------+---------+---------+---------+---------+---------+---EXPLAIN PLAN SET QUERYNO = 327 FOR

SELECT NAME, TBNAME, COLNO, COLTYPE, LENGTH FROM PUBLIC.SYSCOLUMNS WHERE TBNAME = ? ;

---------+---------+---------+---------+---------+---------+---+ + + + + +DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

• Remember to change version along with Progname and Collid

28

Page 29: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Change the Insert AgainINSERT INTO P390H.PLAN_TABLE

VALUES(327 , 1 , ' ' ,

'DSNESM68' , 1 , 0 ,

'PUBLIC' ,

'SYSCOLUMNS' , 1 , 'I ' , 2 ,

'PUBLIC' ,

'DSNDCX01' , 'N' , 'N' , 'N' , 'N' , 'N' , 'N' , 'N' , 'N' , 'N' , ' IS' , '2007121211104887' , ' ' , 'L' , ' ' , 0 , '' , , , , , , , ,'DSNESPCS' , NULL , NULL , NULL, NULL , NULL , NULL, NULL , NULL , ' ' , ' ' , ' ' , ' ' , ' ' ,' ' , 'SELECT' , '2007-12-12-11.10.48.870000' , 'PRODHINT' ,' ' , ' ' )

29

Page 30: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Finally!DSNT404I SQLCODE = 394, WARNING: USER SPECIFIED OPTIMIZATION HINTS

USED DURING ACCESS PATH SELECTION DSNT418I SQLSTATE = 01629 SQLSTATE RETURN CODE DSNT415I SQLERRP = DSNXOPTH SQL PROCEDURE DETECTING ERROR DSNT416I SQLERRD = 20 0 0 1141936894 0 0 SQL DIAGNOSTIC

INFORMATION DSNT416I SQLERRD = X'00000014' X'00000000' X'00000000'

X'441092FE'X'00000000' X'00000000' SQL DIAGNOSTIC INFORMATION

30

Page 31: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

DB2 Validates that the Hint is Intended for this Programg

• PROGNAME, APPLNAME, COLLID, VERSION, , , , ,QUERYNO, QBLOCKNO, OPTHINT

• If you intend to do many hints, it would make a good index

31

Page 32: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Check the HintCOLLID PROGNAME QUERYNO OPTHINT HINT_USED

+---------+---------+---------+---------+---------+---------+---

DSNESPCS DSNESM68 327 PRODHINT

DSNESPCS DSNESM68 327 PRODHINT

32

Page 33: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Changed the Correlation Name to Table1

EXPLAIN ALL FOR

SELECT NAME, TBNAME, COLNO, COLTYPE, LENGTH

FROM PUBLIC.SYSCOLUMNS TABLE1

WHERE TBNAME = ? QUERYNO 327

;

---------+---------+---------+---------+---------+---------+------- --+---------+

DSNT404I SQLCODE = 394, WARNING: USER SPECIFIED OPTIMIZATION HINTS USED DURING ACCESS PATH SELECTION

• Still used the hint

33

Page 34: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Changed the Where ClauseEXPLAIN ALL FOR

SELECT NAME, TBNAME, COLNO, COLTYPE, LENGTH FROM PUBLIC.SYSCOLUMNS TABLE1 WHERE NAME = ? QUERYNO 327 QUERYNO 327 ;

---------+---------+---------+---------+---------+---------+---------+--DSNT404I SQLCODE = 394, WARNING: USER SPECIFIED OPTIMIZATION HINTS USED

DURING CCESS PATH SELECTION

• It used the hint even though the index forIt used the hint even though the index for the hint does Not contain that column

34

Page 35: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

What Happened?MATCHCOLS

+---------+---------+---------

0 PUBLIC DSNDCX01

• Instead of the hint2 PUBLIC DSNDCX01

• You can use the hint to force DB2 to use a specific index but you can Not force match p ycolumns from what the optimizer knows

35

Page 36: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Another SQL to Build a HintINSERT INTO P390H.PLAN_TABLE

("QUERYNO“),

QBLOCKNO,

APPLNAME,

PROGNAME,

PLANNO,

METHOD,

CREATORCREATOR,

• Leaving out the columns for parallel processing because they can be nullbecause they can be null

36

Page 37: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

The SELECT PortionSELECT

"QUERYNO“, QBLOCKNO, APPLNAME

• ........etc leaving out the columns for parallel processing because they can be null FROM PUBLIC.PLAN_TABLE

WHERE APPLNAME = '' AND COLLID = 'TESTCOLLX' AND PROGNAME 'TEST01' AND PROGNAME = TEST01 AND QUERYNO = 327 AND BIND_TIME = '2007-07-19-12.29.49.402261‘ ;

37

Page 38: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

And it WorksDSNE615I NUMBER OF ROWS AFFECTED IS 1

DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0

• Unless your hint is disposable, you may want a special PLAN TABLE that doesn’t get purged tospecial PLAN_TABLE that doesn t get purged to keep them in

38

Page 39: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Let’s Test a BindDSN SYSTEM(DB7G)

BIND PACKAGE(TESTCOLL) MEMBER(TEST01) -

OWNER (P390H) QUALIFIER (PUBLIC) OPTHINT('PRODHINT') -

ACTION(REPLACE) VALIDATE(BIND) ISOLATION(CS) EXPLAIN (YES)

END

• Normal bind package with OPTHINT specified

39

Page 40: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

The OutputDSNT232I -DB7G SUCCESSFUL BIND FOR

PACKAGE = DALLAS7.TESTCOLL.TEST01.(2007-11-05-17.30.05.785661)

• Not what we wanted to see• Did not give +394 or +395 so it didn’t find theDid not give +394 or +395 so it didn t find the

hint• More likely the hint specifies a different version y p

identifier

40

Page 41: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

So let’s Fix itUPDATE P390H.PLAN_TABLE

SET VERSION = '2007-11-05-17.30.05.785661' , COLLID = 'TESTCOLL' WHERE APPLNAME = '' AND COLLID = 'TESTCOLLX' AND BIND_TIME = '2007-07-19-12.29.49.402261' ;

---------+---------+---------+---------+---------+-------DSNE615I NUMBER OF ROWS AFFECTED IS 1

• I had the COLLID wrong in the bind and the• I had the COLLID wrong in the bind and the version

41

Page 42: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

It Found the Hint

DSNX105I -DB7G BIND SQL WARNING

USING P390H AUTHORITY

PLAN=(NOT APPLICABLE)

DBRM=TEST01

STATEMENT=327

SQLCODE=395

SQLSTATE=01628

TOKENS=32

• But it didn’t like it

42

Page 43: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Error Codes are listed under SQLCODE +395

2 TABNO is invalid.

3 TNAME is not specified.

4 TNAME is ambiguous.

5 TABNO doesn't agree with TNAME.

6 QBLOCKNO doesn't agree with TNAME.

7 PAGE RANGE is invalid7 PAGE_RANGE is invalid.

8 PREFETCH is invalid.

9 METHOD is invalid.

10 SORTN_JOIN is invalid.

43

Page 44: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Error Codes are listed under SQLCODE +395 continued

11 SORTC_JOIN is invalid.12 ACCESSTYPE is invalid. 13 ACCESSCREATOR or ACCESSNAME is invalid. 13 ACCESSCREATOR or ACCESSNAME is invalid. 14 TYPE 1 index can't be used with isolation level 'UR'.15 Specified index can't be used as requested.16 Multi-index access can't be done.17 Invalid ACCESSTYPE combination.17 Invalid ACCESSTYPE combination.18 METHOD specified for first table accessed.19 Nested-loop join can't be done as requested.20 Merge join can't be done as requested.

44

Page 45: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Error Codes are listed under SQLCODE +395 continued

21 Hybrid join can't be done as requested. 22 PARALLELISM_MODE requested can't be done. 23 PARALLELISM_MODE is invalid. 24 ACCESS DEGREE i i lid 24 ACCESS_DEGREE is invalid. 25 JOIN_DEGREE is invalid. 26 A table is missing.27 A table is redundant.28 PRIMARY ACCESSTYPE i i lid 28 PRIMARY_ACCESSTYPE is invalid. 29 ACCESS_PGROUP_ID is not specified.30 JOIN_PGROUP_ID is not specified.

45

Page 46: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Error Codes are listed under SQLCODE +395 continued

31 PARALLELISM_MODE is not specified.

32 CREATOR or TNAME is invalid.

33 Join sequence is incorrect33 Join sequence is incorrect.

34 Full outer join requires merge join method.

35 WHEN_OPTIMIZE is invalid or inconsistent.

99 Unexpected Error.p

46

Page 47: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Our Error was 32CREATOR or TNAME is invalid.

• They lied – it was the correlation nameThey lied it was the correlation name

327 PUBLIC SYSCOLUMNS 1

327 PRODHINT PUBLIC SYSCOLUMNS 1 --------

47

Page 48: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

So Fix it

UPDATE P390H.PLAN_TABLE

SET CORRELATION_NAME = ' '

WHERE APPLNAME = ''

AND COLLID = 'TESTCOLL'

AND BIND_TIME = '2007-07-19-12.29.49.402261'

; ;

---------+---------+---------+---------+----

DSNE615I NUMBER OF ROWS AFFECTED IS 1

DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL,

SQLCODE IS 0SQLCODE IS 0

48

Page 49: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Finally!DSNX105I -DB7G BIND SQL WARNING

USING P390H AUTHORITY PLAN=(NOT APPLICABLE)

DBRM=TEST01

STATEMENT=327 STATEMENT=327

SQLCODE=394

SQLSTATE=01629

TOKENS=

49

Page 50: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Now Check itQUERYNO OPTHINT HINT_USED

327 PRODHINT

327 PRODHINT

• Still have to check the actual access path

50

Page 51: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Let’s review Matching• PROGNAME, APPLNAME, COLLID, VERSION, QUERYNO, QBLOCKNO, OPTHINT

• Version(AUTO) means you have to update the hint for• Version(AUTO) means you have to update the hint for each compile

• QUERYNO means you have to change the QUERYNO if a programmer adds an IF statement and moves the queryprogrammer adds an IF statement and moves the query

• QBLOCKNO means a V7 hint will NOT work when V8 does a transformation and collapses the access path

• OPTHINT only has one value for the BIND so if you have• OPTHINT only has one value for the BIND so if you have multiple hints for the same program, they have to have the same OPTHINT value

51

Page 52: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

More Matching• Table creator, name, tabno, and correlation_name have to match

• If you specify an index, the ACCESSCREATOR and ACCESSNAME have to match

• You can only have one hint in the plan_table for a given program and queryno

• If you want to change it delete the old hint and• If you want to change it, delete the old hint and create a new one

52

Page 53: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

This is just to Make an Old Access Path into a Hint

• Did Not change any of the old values for tables or g yindexes

• Did Not change JOIN sequence or method

53

Page 54: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Some Columns that the Optimizer Ignores if they are in a Hintg y

• MATCHCOLS – you can force the optimizer to use an index but you can NOT force it to use the data in theindex but you can NOT force it to use the data in the index

• All the sort columns SORTN_UNIQ, SORTN_JOIN, SORTN_ORDERBY, SORTN_GROUPBY, SORTC_UNIQ, SORTC_JOIN, SORTC_ORDERBY, SORTC_GROUPBY

• The optimizer decides on sorts based on the SQL

54

Page 55: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Now some easier MethodsExpress Hints for DB2

COMMAND ===>

Select the entity to be processed: Select the entity to be processed:

Subsystem ID . . . . . . DB7G PLAN_TABLE owner . . . . p390h

DBRM/package name . . . . test01 /p g

Enter "/" to Select option Process packages only

Press ENTER to proceed.

55

Page 56: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

So I might be a little sloppy with Test Programsg

Express Hints - Item Selection COMMAND ===>

Target DBRM . . . . . . . . . . . : TEST01 Target DBRM . . . . . . . . . . . : TEST01

Choose an item to process:

Type Plan or Collection ---- ------------------. PKG HEXCOLL . PKG TESTCOLL . PKG TESTCOLLNEW . PKG TESTCOLLX . PKG TESTCOLLXX1 PKG TESTCOLL7 . PKG TESTCOLL7

. PKG TESTFREE

. PKG TESTFREE2

. PKG TESTFREE3

. PKG TESTFREE4

56

Page 57: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Three Old VersionsExpress Hints - Version List

COMMAND ===>

Package (DBRM) . . : TEST01 g ( )Collection . . . . : TESTCOLLX

Choose the version to process:

--------------------------- Version -----------------. 2005-04-11-18.20.42.913225 . 2005-04-11-18.34.53.754785 . 2006-05-23-19.00.27.449848

57

Page 58: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Look! Queryno 327 AgainExpress Hints - Statement Selection Row 1 to 10

COMMAND ===> Scroll===>

Package . . . . . . : TEST01 Collection . . . . . : TESTCOLL Version . . . . . . : 2005-04-11-18.20.42.913225

Choose a statement to process:

Queryno Statement ------- ------------------------------------------------------------. 154 DECLARE SYSIBM . SYSCOLUMNS TABLE ( NAME VARCHAR ( 18 ) NOT . 225 DECLARE SYSIBM . SYSTABLES TABLE ( NAME VARCHAR ( 18 ) NOT N . 327 DECLARE SELECT-1 CURSOR FOR SELECT NAME , TBNAME , COLNO , C 333 DECLARE SELECT 2 CURSOR FOR SELECT NAME CREATOR TYPE D . 333 DECLARE SELECT-2 CURSOR FOR SELECT NAME , CREATOR , TYPE , D . 444 OPEN SELECT-1 . 450 FETCH SELECT-1 INTO : H , : H , : H , : H , : H . 462 CLOSE SELECT-1 . 466 OPEN SELECT-2 . 472 FETCH SELECT-2 INTO : H , : H , : H , : H , : H 484 2

58

. 484 CLOSE SELECT-2

Page 59: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Start with Option 1COMMAND ===>

DBRM . . . . . . . : TEST01 Collection . . . . : TESTCOLLX Version . . . . . : 2005-04-11-18.20.42.913225 Queryno . . . . . : 327

Select one of the options below: 1 MODIFY Change access path 1 MODIFY Change access path 2 NAME Assign hint name 3 MAKE Create hint

59

Page 60: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Only Accesses a Single TableCOMMAND ===> Scroll ===>

DBRM . . . . . . . : TEST01 Collection . . . . : TESTCOLL Version . . . . . : 2007-11-05-17.30.05.785661 Queryno . . . . . : 327

Choose a query element to edit or specify a different sequenceChoose a query element to edit, or specify a different sequence

Sequence Table Accessed -------- ---------------------------

1 P390H.SYSCOLUMNS

60

Page 61: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

So let’s turn off PrefetchExp COMMAND ===>

Package . . : TEST01 Query No. . : 327

Prefetch mode (PREFETCH) 1. S Sequential prefetch 2. L List prefetch 3. D Dynamic (Version 8 only) 4 Bl k ( f t h) 4. Blank (no prefetch)

Type of Access (ACCESSTYPE) 1. I By the index named below 2 1 1 f h i d 2. I1 1-fetch index scan 3. N Index scan with 'IN' predicate 4. R Table space scan 5. M Multiple index scan 6. Blank Not applicable

61

Page 62: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Back out to the MenuExpress Hints - Access Path Control

COMMAND ===>

DBRM . . . . . . . : TEST01 Collection . . . . : TESTCOLLX Version . . . . . : 2005-04-11-18.20.42.913225 Queryno . . . . . : 327

Select one of the options below:Select one of the options below: 1. MODIFY Change access path 2. NAME Assign hint name 3. MAKE Create hint

62

Page 63: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Now Specify the Hint Name (OPTHINT)( )

Express Hints - Hint Name COMMAND ===>

Current hint name: New hint name: (none) Prodhint

63

Page 64: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

If you use the same Hint Name (OPTHINT Value)( )

Confirm Hint COMMAND ===>

++ WARNING ++

The hint name you have specified is already used by at least one PLAN_TABLE entry. If you y y yuse this hint name, the hint may be shared by multiple queries with unintended results.

64

Page 65: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Back to the Menu to Create the Hint

Express Hints - Access Path Control COMMAND ===>

DBRM . . . . . . . : TEST01 Collection . . . . : TESTCOLLX Version . . . . . : 2005-04-11-18.20.42.913225 Queryno . . . . . : 327

Select one of the options below:Select one of the options below: 1. MODIFY Change access path 2. NAME Assign hint name 3. MAKE Create hint

65

Page 66: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

What Happened?Confirm Hint

COMMAND ===>

This Hint has been validated and accepted by DB2. If you wish, the hint can be saved in the plan table so that it may be used to bind with in the future.

Press ENTER to save the hint in the planPress ENTER to save the hint in the plan table.

Press END to return to the previous panel without saving the hint.

66

Page 67: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

So now we have two Hints for theSo now we have two Hints for the same Collid, Progname, and

VersionVersionDELETE

FROM P390H.PLAN_TABLE

WHERE APPLNAME = ''

AND PROGNAME = 'TEST01'

AND COLLID = 'TESTCOLL'

AND TIMESTAMP = '2007071912294940' AND TIMESTAMP 2007071912294940

;

67

Page 68: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Forgot to Change the QualifierDSNX105I -DB7G BIND SQL WARNING

USING P390H AUTHORITY PLAN=(NOT APPLICABLE)

DBRM=TEST01

STATEMENT=327 STATEMENT 327

SQLCODE=395

SQLSTATE=01628

TOKENS=32

68

Page 69: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Another Successful HintDSNX105I -DB7G BIND SQL WARNING

USING P390H AUTHORITY

PLAN=(NOT APPLICABLE)

DBRM=TEST01 DBRM TEST01

STATEMENT=327

SQLCODE=394

SQLSTATE=01629

TOKENS=

69

Page 70: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Hint was UsedQUERYNO OPTHINT HINT_USED

---------+---------+--------327 PRODHINT 327 PRODHINT 327 PRODHINT AndPREFETCH--+------

• Hard to show prefetch value = spaces but?

70

Page 71: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

HLS Product PATHCHK//STEP EXEC PGM=PATHCHK

//SYSIN DD *

OPTIONS CONVERTHINT PRODHINT

CONNECT TO DB7G

SET CURRENT SQLID = 'P390H'

TEST DBRM TEST01 AS PACKAGE

TESTCOLL.* IN P390H.PLAN_TABLE

71

Page 72: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Batch ProgramIN QRYNO M CREATOR TNAME TBNO AC MC CREATOR ACCESSNAME

* 327 0 P390H SYSCOLUMNS 1 R 0 PCK220I DATA CHANGE FOR COLUMN PREFETCH WAS PCK221I DATA CHANGE FOR COLUMN PREFETCH IS NOW S PCK224I DSN STATEMNT TABLE ESTIMATED COST CHANGE OLD EST SVC UNITS 209PCK224I DSN_STATEMNT_TABLE ESTIMATED COST CHANGE - OLD EST SVC UNITS 209PCK223I DSN_STATEMNT_TABLE ESTIMATED COST CHANGE - NEW EST SVC UNITS 209

72

Page 73: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Another Lazy way to Get a HintDSNX105I -DB7G BIND SQL WARNING

USING P390H AUTHORITY PLAN=(NOT APPLICABLE)

DBRM=TEST01

STATEMENT=327 STATEMENT 327

SQLCODE=394

SQLSTATE=01629

TOKENS=

73

Page 74: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Path Check• Will preserve a hint across SQL changes• Can even create the hint if queryno changesq y g• Corrects for the new VERSION(AUTO)• Make the access path the same as the old access

path• Don’t think about it

74

Page 75: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Now Recompile to get new Version

14.29.35 JOB03691 -JOBNAME STEPNAME PROCSTEP RC

14.29.35 JOB03691 -P390HC01 PRECOMP 00

14 29 36 JOB03691 P390HC01 COB2COMP 00 14.29.36 JOB03691 -P390HC01 COB2COMP 00

14.29.37 JOB03691 -P390HC01 LKED2 00

14.29.37 JOB03691 -P390HC01 DB2BIND 00

75

Page 76: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Building a Presentation at the Last Minute

DSNX105I -DB7G BIND SQL WARNING

USING P390H AUTHORITY PLAN=(NOT APPLICABLE) DBRM=TEST01 STATEMENT=327 SQLCODE=394 SQLSTATE=01629 TOKENS=

DSNT254I -DB7G DSNTBCM2 BIND OPTIONS FOR DSNT254I DB7G DSNTBCM2 BIND OPTIONS FOR PACKAGE = DALLAS7.TESTCOLL.TEST01.(2008-02-28-20.29.35.368621)

76

Page 77: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Notice we Aren’t Using Queryno =327

IN QRYNO M CREATOR TNAME TBNO AC MC CREATOR ACCESSNAME * 333 0 P390H SYSCOLUMNS 1 R 0 PCK220I DATA CHANGE FOR COLUMN PREFETCH WAS PCK221I DATA CHANGE FOR COLUMN PREFETCH IS NOW S PCK221I DATA CHANGE FOR COLUMN PREFETCH IS NOW S PCK224I DSN_STATEMNT_TABLE ESTIMATED COST CHANGE - OLD EST SVC UNITS 209PCK223I DSN_STATEMNT_TABLE ESTIMATED COST CHANGE - NEW EST SVC UNITS 209

77

Page 78: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Created the Hint Row with the New Querynoy

QUERYNO OPTHINT HINT_USED

---------+---------+--------

333 PRODHINT 333 PRODHINT

333 PRODHINT

78

Page 79: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

And No Hints for Parallel Access• I am only trying to cover basic DEGREE=1 access

paths• Didn’t even cover multiple step access paths. The

first method has to be 0 then 1-4See the Presentation Titled Implementing DB2 for• See the Presentation Titled Implementing DB2 for z/OS Optimization Hints by Patrick Bossman

79

Page 80: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

Our Hint Management Solutions• Path Check – Convert Hint will insure hints are not

lost in the bind process• Hint / Rebind – Will insure that hints are not lost in

the rebind process, which is the most common so rce of a losssource of a loss

• Express Hints – An ISPF interface that finds and sets the correct values and then does a test to seesets the correct values and then does a test to see if the hint will take

80

Page 81: Using SPUFI to Explore DB2Using SPUFI to Explore … SPUFI to Explore DB2Using SPUFI to Explore DB2 ... • We will deal with the SQL sequence number in the ... DSNT408I SQLCODE =

You are Now a HINT Expert!Please Come visit us at our Booth to receive your

Expert Pin!

81