© ibm corporation 2007 1 patrick bossman ibm silicon valley lab tuning with optimization service...

108
© IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

Upload: tiffany-mcdonald

Post on 18-Dec-2015

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

1

Patrick Bossman

IBM Silicon Valley Lab

Tuning with Optimization Service Center

Part I

®

Columbia, MDSeptember 12, 2007

Page 2: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

2

Agenda

• Overview of Optimization Service Center

• Connect and configure OSC

• Workload (application) Tuning

• Query tuning (Part II)

Page 3: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

3

Overview

• Optimization Service Center (OSC)– New no charge product supported for connections

to DB2 9. • Support for DB2 for z/OS V8 connections in open beta

– Workstation tool for monitoring and tuning of queries

– Facilitates the identification and tuning of workloads (sets of queries) as well as individual queries

– New powerful query diagnostic tools enable faster deep analysis of queries

Page 4: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

4

Overview

• OSC feature list– Support for workload tuning

• Stand-alone workload creation

• Push-out model (monitoring)

– Visual Explain query graphing capabilities

– Query formatting and annotation

– Query report

– Visual Plan Hint

– Statistics Advisor - query and workload

Page 5: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

5

Connect and configure

• Launch OSC– Initial screen is connection and configuration

– Review look and feel

– Review layout of screen

Page 6: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

6

Launch OSC

Page 7: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

7

Project navigator area

Page 8: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

8

Project navigator

• Navigate through open projects

Page 9: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

9

Top navigation tabs

Page 10: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

10

Top navigator tabs close-up

Page 11: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

11

Connection / configuration

Page 12: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

12

Connection close-up

• Connection– Subsystems cataloged in DB2 Connect listed– Use subsystem menu option to add / remove subsystems

Page 13: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

13

Add Subsystem

• Add DB2 subsystem connection– Select subsystem button

– Choose Add

Page 14: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

14

Connection information

• Add DB2 subsystem connection– Subsystem alias is a meaningful name to you

– Location, hostname, port• Can be found in <ssid>MSTR address space DDF startup message DSNL004I

Page 15: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

15

DSNL004I

• DSNL004I message– Location = location– Domain = hostname– TCPPORT = port

Page 16: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

16

Jeez Pat, Connect already!

• Connect to subsystem– Choose Connection, connect– You can connect to more than one subsystem and perform

activities on more than one subsystem at a time.

Page 17: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

17

Login information…

Page 18: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

18

Bind packages

Page 19: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

19

Create explain tables

Page 20: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

20

Create explain tables

Page 21: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

21

Create explain tables

Page 22: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

22

Create alias to explain tables

• Create aliases– You can use OSC to create ALIASes to the explain

tables also.

Page 23: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

23

Create alias to explain tables

Page 24: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

24

Subsystem status

Page 25: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

25

Subsystem status

Page 26: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

26

Explain-enabled Authid’s

Page 27: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

27

EXPLAIN enabled authid’s

Page 28: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

28

Connection complete.Now what?

(Welcome menu…)

Page 29: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

29

Go to welcome page…

Page 30: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

30

Welcome page

Page 31: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

31

Welcome page close-ups

Page 32: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

32

Welcome page close-ups

Page 33: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

33

Welcome page close-ups

Page 34: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

34

Application tuning

• Application tuning– Creating workloads

– Workload options

– Workload tuning features

Page 35: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

35

Application tuning process

• What is application tuning?– Identify what the application workload is

• Individual SQL statements

– Get an understanding of the applications behavior• How often are individual SQL statements executing?• What is the performance of individual SQL statements?

– Determine statistics for workload • Workload statistics advisor• More workload analysis features coming… (?)

– Remeasure workload• Identify top tuning candidates• Use query based tools to further analyze (next session)

Page 36: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

36

Creating workloads

• Creating a workload– Tune a workload

– View workloads

– Monitoring functions

Page 37: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

37

Tune a workload

Page 38: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

38

Workload sources• Workload sources

– Snap statement cache– Catalog (static SQL)– QMF / QMF HPO– File– Categories– Other workloads

Page 39: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

39

Workload sources

Page 40: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

40

Catalog source…

Page 41: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

41

Catalog source

Page 42: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

42

Package filter options• Package filter options

– Collection id, name, owner, …

– Can use equals, like, in, etc.

Page 43: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

43

Package filter options

Page 44: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

44

Plan filter options• Plan filter options

– Plan name, plan creator, etc.

– Can use equals, like, in, etc.

Page 45: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

45

Plan filter options

Page 46: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

46

Cost & Object filter options• Cost and Object filters

– Filters SQL within package / plan filter– Requires the static SQL be bound with explain yes.– DSN_STATEMNT_TABLE must already be populated.– Show only SQL with PROCSU > …– Show SQL which uses table…– Show SQL which uses index…

• Choice to return rows which qualify for ANY or ALL of the cost / object filter conditions

Page 47: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

47

Cost & Object filter options

Page 48: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

48

Access path filters• Access path filters

– Filters SQL within package / plan filter

– Requires the static SQL be bound with explain yes.

– PLAN_TABLE must already be populated.

• Show SQL which performs…– Tablespace scan

– Sort

– Non-matching index scan

– List prefetch

– Outer join

– ….

Page 49: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

49

Cost & Object filter options

Page 50: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

50

Capture the workload

• After selecting packages / plans / filters…– Click finish to capture workload

– OSC goes about the business of collecting the statements…

• Queue Jeopardy music, get some coffee.

Page 51: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

51

Workload captured…

Page 52: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

52

Review workload screen

• Workload header

• Workload options

• Project Navigator

Page 53: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

53

Workload header

Page 54: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

54

Workload header

Page 55: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

55

Workload options

Page 56: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

56

Workload options

Page 57: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

57

Workload option close-up (1)

Page 58: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

58

Workload options close-up (2)

Page 59: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

59

Workload statements…

Page 60: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

60

Workload statements

• Workload statements– Show the SQL within the workload

– Refine execution runtime information• For catalog capture, runtime information would have to be

manually obtained.

• You don’t really need to change it for statistics advisor…

– Let’s walk through it…

Page 61: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

61

Workload statements view

Page 62: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

62

Capture more statements…

Page 63: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

63

Description

Page 64: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

64

Schedule workload activity

Page 65: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

65

Remove statements from workload

Page 66: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

66

Execute query tools on selected SQL

Page 67: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

67

Select “edit runtime information…”

Page 68: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

68

Edit runtime information

Page 69: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

69

Run workload advisors (SA)

Page 70: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

70

Why Statistics Advisor?

• Importance of statistics• Difficulty of determining what statistics to

collect

• Solution: Workload Statistics Advisor!!!

Page 71: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

71

Estimating query cost

• Accurately estimating the number of rows is important for to accurately cost a query– Index matching

• Accurately estimate index cost

– Total index filtering• Estimate table access cost via index(es)• Choose how to use index (prefetch?)

– Total table level filtering• Efficient join order• Efficient join method• Appropriate sorts

Page 72: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

72Symptoms of inaccurate estimation

• Sometimes - great performance!– Few competitive choices

– Good performance possible, but not a "winning" strategy

• Inefficient access path– Query never performs at optimal level

• Unstable access path– Slight changes in input result in dramatic swings in actual

performance

– Efficient and inefficient access paths can end up with close cost estimates

– More accurate selectivity estimates can improve optimizer "differentiation" of efficient and inefficient access

Page 73: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

73

Some observations

• Several candidate indexes?– Need sufficient statistics to differentiate the candidates

• Local filtering spread across many tables?– The more "potentially" desirable outer tables there are, the more

important it is to accurately estimate the true qualified rows

• Lot's of predicates which don't filter much?– Important to make sure DB2 knows that

– When many rows are processed, a single bad choice can be magnified

• The necessity for accurate estimation is related to the number of competitive choices.

Page 74: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

74

Why statistics advisor?

• Statistics are collected to help optimizer in costing available access paths

• Determination of statistics required can be daunting

• Automate the determination of statistics required

Page 75: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

75

What are the right statistics?

• Identify interesting objects– Tables– Indexes

• Identify interesting columns, column groups– Predicate analysis

• Which column (groups) have predicates?

• Which column (groups) are indexed?

• Which statistics should I collect?– Column statistics– Correlation statistics– Frequencies– Histograms

– Statistic needed depends on predicate types (range, equal)

Page 76: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

76

Determining the "right" statistics

• Manual analysis very time consuming, requires significant skill– Format the query to make it readable

– Recognize predicate transformations • Predicate transitive closure

• Between to equal opens new possibilities

• Or to IN creates new boolean term predicates

• Has DB2 rewritten the query (predicate transitive closure)

– Some columns used as predicates hidden in views

– Recognize which statistics are appropriate in which circumstances

• Significant effort even for expert

• Error prone

Page 77: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

77

Run workload advisors (WSA)

Page 78: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

78

Complete recollection, or repair?

Page 79: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

79

RUNSTATS command

Page 80: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

80

Table portion of commandRUNSTATS TABLESPACE DB2OSC.WSATS0 TABLE(DB2OSC.DSN_WSA_DATABASES) COLUMN(NAME,SESSIONID) TABLE(DB2OSC.DSN_WSA_CGFREQS) COLUMN(TBCREATOR,TBNAME,COLGROUPCOLNO,SESSIONID) TABLE(DB2OSC.DSN_WSA_KTGFREQS) COLUMN(IXCREATOR,IXNAME,SESSIONID,KEYGROUPKEYNO) TABLE(DB2OSC.DSN_WSA_SESSIONS) COLUMN(SESSIONID) TABLE(DB2OSC.DSN_WSA_COLGROUPS) COLUMN(TBCREATOR,TBNAME,COLGROUPCOLNO,SESSIONID) COLGROUP(COLGROUPCOLNO,SESSIONID,TBCREATOR,TBNAME) TABLE(DB2OSC.DSN_WSA_TSS) COLUMN(NAME,DBNAME,SESSIONID) COLGROUP(DBNAME,SESSIONID) COLGROUP(DBNAME,NAME,SESSIONID) TABLE(DB2OSC.DSN_WSA_KTGS) COLUMN(IXCREATOR,IXNAME,SESSIONID) TABLE(DB2OSC.DSN_WSA_KEYS) COLUMN(IXCREATOR,IXNAME,SESSIONID) TABLE(DB2OSC.DSN_WSA_CGHISTS) COLUMN(TBCREATOR,TBNAME,COLGROUPCOLNO,SESSIONID) TABLE(DB2OSC.DSN_WSA_KTGHISTS) COLUMN(IXCREATOR,IXNAME,SESSIONID,KEYGROUPKEYNO) TABLE(DB2OSC.DSN_WSA_INDEXES) COLUMN(TBCREATOR,TBNAME,SESSIONID) TABLE(DB2OSC.DSN_WSA_TABLES) COLUMN(CREATOR,NAME,TSNAME,DBNAME,SESSIONID) COLGROUP(CREATOR,NAME,SESSIONID) TABLE(DB2OSC.DSN_WSA_LITERALS) COLUMN(TBCREATOR,TBNAME,SESSIONID,COLNO,VALUE) COLGROUP(COLNO,SESSIONID,TBCREATOR,TBNAME,VALUE) TABLE(DB2OSC.DSN_WSA_KEYTARGETS) COLUMN(IXCREATOR,IXNAME,SESSIONID) TABLE(DB2OSC.DSN_WSA_COLUMNS) COLUMN(TBCREATOR,TBNAME,SESSIONID) SORTDEVT SYSDA SHRLEVEL CHANGE REPORT YES

Page 81: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

81

Index portion of suggestionRUNSTATS TABLESPACE DB2OSC.WSATS0 …INDEX(DB2OSC.DSN_WSA_IDX_DBS, DB2OSC.DSN_WSA_IDX_CGFS, DB2OSC.DSN_WSA_IDX_KTGFS, DB2OSC.DSN_WSA_IDX_SSNS, DB2OSC.DSN_WSA_IDX_CGS, DB2OSC.DSN_WSA_IDX_TSS, DB2OSC.DSN_WSA_IDX_KTGS, DB2OSC.DSN_WSA_IDX_KEYS KEYCARD, DB2OSC.DSN_WSA_IDX_CGHS KEYCARD, DB2OSC.DSN_WSA_IDX_KTGHS KEYCARD, DB2OSC.DSN_WSA_IDX_IDXS, DB2OSC.DSN_WSA_IDX_TABLES, DB2OSC.DSN_WSA_IDX_LTRS KEYCARD, DB2OSC.DSN_WSA_IDX_KTS KEYCARD, DB2OSC.DSN_WSA_IDX_COLS KEYCARD) SHRLEVEL CHANGE REPORT YES

Page 82: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

82

Output looks complex…

• RUNSTATS commands are more targeted– Only collect on tables used in queries

– Only collect column statistics on columns used as predicates

– Collect frequency and histogram statistics based on predicates which would benefit

Page 83: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

83

Pause for questions on WSA?

Page 84: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

84

Back to our regularly scheduled programming…

Page 85: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

85

More OSC GUI review

Page 86: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

86

Open projects as tabs on top…

Page 87: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

87

Project Navigator

Page 88: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

88

Project navigator

• Navigate across projects– As multiple projects opened, you can switch between

projects you’re working on

• Navigate within a project– As you perform different tasks within a project, you

can navigate through the different tuning sections

Page 89: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

89

Project Navigator

Page 90: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

90

Project tabs

Page 91: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

91

Project tabs

Page 92: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

92

Project tabs

• Navigate within project– As multiple projects opened, you can switch between

projects you’re working on

• Close sections of project you’re done with– Click x on the tab to close selected tab

Page 93: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

93

More OSC GUI review

Page 94: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

94

Workload sources - cache

Page 95: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

95

Cache statement view

• Cache statement view– Number of executions

– Accumulated & average CPU time

– Accumulated & average elapsed time

– SQL text

• Cache as input provides more visibility into how often SQL executing, cost of statements

Page 96: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

96

Workload – cache statements view

Page 97: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

97

Monitor workload

• Normal monitor workload– All SQL based on certain criteria

– Useful to profile an application• Which SQL running most frequently?

• Which queries consuming most elapsed / execution time?

• Exception monitor– Workload generated based on exception criteria

• All SQL for package > x seconds elapsed

• All SQL for package > x seconds elapsed

Page 98: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

98Application tuning process(revisit)

• What is application tuning?– Identify what the application workload is

• Individual SQL statements

– Get an understanding of the applications behavior• How often are individual SQL statements executing?• What is the performance of individual SQL statements?

– Determine statistics for workload • Workload statistics advisor• More workload analysis features coming… (?)

– Remeasure workload• Identify top tuning candidates• Use query based tools to further analyze (next session)

Page 99: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

99

Create normal monitor

Page 100: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

100

Add monitor sources

Page 101: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

101

Set monitor options

Page 102: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

102

Monitor statement view

Page 103: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

103

Exception monitor options

Page 104: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

104

Application tuning

• Normal monitor allows for capture of all SQL– Specify list of packages

• Prevents workload “pollution” which can occur with statement cache

– Capture valuable execution information

– Ideally initially used in QA environment to profile / tune application before production implementation

• “How often does this execute?”

• “How long does this run?”

• … you can have answers to these questions…

– Selectively use in production to develop application profile and tune application

Page 105: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

105Application tuning process(review)

• What is application tuning?– Identify what the application workload is

• Individual SQL statements

– Get an understanding of the applications behavior• How often are individual SQL statements executing?• What is the performance of individual SQL statements?

– Determine statistics for workload • Workload statistics advisor• More workload analysis features coming… (?)

– Remeasure workload• Identify top tuning candidates• Use query based tools to further analyze (next session)

Page 106: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

106

Which workload source to use?

• Which workload source provides…– Identification of all SQL statements executed

– Accurate number of execution counts

– Accurate accumulated and average execution performance

– Provides runtime information for any source

– Can re-measure and expect to see the same SQL again, compare results

– Is not polluted with dynamic SQL which are not relevant to the application?

• Workload monitoring (normal)

Page 107: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

107

Tuning with OSC I

• End of OSC tuning Part I– Show some demo if time permits

• Next up, Query tuning with OSC– Statistics Advisor

– Query annotation

– Query report

– Visual Explain

– Visual plan hint

Page 108: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part I ® Columbia, MD September 12, 2007

© IBM Corporation 2007

108

Patrick Bossman

[email protected]

Tuning with Optimization Service Center I

®