![Page 1: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/1.jpg)
© IBM Corporation 2007
1
Patrick Bossman
IBM Silicon Valley Lab
Tuning with Optimization Service Center
Part II
®
Columbia, MDSeptember 12, 2007
![Page 2: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/2.jpg)
© IBM Corporation 2007
2
Agenda
• Query tuning with OSC– Statistics Advisor
– Query annotation
– Query report
– Access plan graph
– Visual plan hint
• Demo as time permits
![Page 3: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/3.jpg)
© IBM Corporation 2007
3
Tuning a query
• Steps to tuning a query– Identify statement
• Collect information regarding SQL– Review SQL
– Physical design of referenced objects
– Statistics
– Access path
– Mentally compute, is access path efficient?
– Could we do better?
![Page 4: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/4.jpg)
© IBM Corporation 2007
4
Identify query
• Choose a query from an existing workload– Selecting query from a workload
• Use Tune Query input options– Copy / paste / manually type within “Tune a query”
option
– Grab static SQL from the catalog
– Choose from statement cache
– Retrieve from QMF
![Page 5: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/5.jpg)
© IBM Corporation 2007
5
Tune query from workload
• Right click on selected query
OR
• Select query Query Tools
![Page 6: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/6.jpg)
© IBM Corporation 2007
6
Select query from workload…
![Page 7: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/7.jpg)
© IBM Corporation 2007
7
Press Query Tools button
![Page 8: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/8.jpg)
© IBM Corporation 2007
8
Tune query input options
• Manual input (type, copy / paste)• Use catalog search options (static SQL)• Select SQL from snap statement cache• Select from QMF
![Page 9: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/9.jpg)
© IBM Corporation 2007
9
Welcome page
![Page 10: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/10.jpg)
© IBM Corporation 2007
10
Tune single query
![Page 11: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/11.jpg)
© IBM Corporation 2007
11
Choose identify target query…
![Page 12: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/12.jpg)
© IBM Corporation 2007
12
Query options
• Top of window, select query source– Top of window varies based on selected source
• Bottom of window – Show selected SQL
– Tuning options
![Page 13: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/13.jpg)
© IBM Corporation 2007
13
Query selection window
![Page 14: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/14.jpg)
© IBM Corporation 2007
14
Query source
![Page 15: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/15.jpg)
© IBM Corporation 2007
15
Query text
![Page 16: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/16.jpg)
© IBM Corporation 2007
16
Query tuning options
![Page 17: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/17.jpg)
© IBM Corporation 2007
17
Query menu
![Page 18: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/18.jpg)
© IBM Corporation 2007
18
Query menu
![Page 19: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/19.jpg)
© IBM Corporation 2007
19
Query menu
![Page 20: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/20.jpg)
© IBM Corporation 2007
20
Choose query source…
![Page 21: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/21.jpg)
© IBM Corporation 2007
21
Text input…
![Page 22: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/22.jpg)
© IBM Corporation 2007
22
Source: Statement cache…
• Improved statement cache interface!– Use predefined cache views sorted in popular use
sequence– Define and save your own display of the cache
![Page 23: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/23.jpg)
© IBM Corporation 2007
23
Other cache improvements
• Design your own cache display view– Choose filter criteria
– Choose how to sort rows retrieved from cache
– Choose which columns to display
– After rows retrieved, you can re-sort the rows displayed on the screen also
• Vastly improved statement cache interface– One-time setup, repeating use
![Page 24: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/24.jpg)
© IBM Corporation 2007
24Cache new view optionsFilter…
![Page 25: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/25.jpg)
© IBM Corporation 2007
25Cache new view optionssort on…
![Page 26: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/26.jpg)
© IBM Corporation 2007
26Cache new view optionsdisplay columns…
![Page 27: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/27.jpg)
© IBM Corporation 2007
27
Source section of window
• Double left click to see SQL text• Left click on row to select SQL• Left-click on column header to sort retrieved
records by column
![Page 28: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/28.jpg)
© IBM Corporation 2007
28
Source: Catalog
• Build catalog search criteria as a view
![Page 29: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/29.jpg)
© IBM Corporation 2007
29
Package filter options• Package filter options
– Collection id, name, owner, …
– Can use equals, like, in, etc.
![Page 30: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/30.jpg)
© IBM Corporation 2007
30
Package filter options
![Page 31: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/31.jpg)
© IBM Corporation 2007
31
Plan filter options• Plan filter options
– Plan name, plan creator, etc.
– Can use equals, like, in, etc.
![Page 32: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/32.jpg)
© IBM Corporation 2007
32
Plan filter options
![Page 33: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/33.jpg)
© IBM Corporation 2007
33
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 34: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/34.jpg)
© IBM Corporation 2007
34
Cost & Object filter options
![Page 35: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/35.jpg)
© IBM Corporation 2007
35
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 36: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/36.jpg)
© IBM Corporation 2007
36
Access path filter options
![Page 37: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/37.jpg)
© IBM Corporation 2007
37
Catalog SQL list
• Left click on row to select…
![Page 38: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/38.jpg)
© IBM Corporation 2007
38
Source QMF / QMF HPO
![Page 39: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/39.jpg)
© IBM Corporation 2007
39
QMF search options
• Searching for Bob’s QMF queries…
![Page 40: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/40.jpg)
© IBM Corporation 2007
40
Source: File
![Page 41: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/41.jpg)
© IBM Corporation 2007
41
Source: Categorized SQL
![Page 42: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/42.jpg)
© IBM Corporation 2007
42
Source: Plan Table
![Page 43: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/43.jpg)
© IBM Corporation 2007
43
Plan table sort options
![Page 44: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/44.jpg)
© IBM Corporation 2007
44
Plan table display options
![Page 45: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/45.jpg)
© IBM Corporation 2007
45
Plan table display options
• Plan table comments– OSC will map plan_table to SYSPACKSTMT / SYSSTMT– Explain row selected must map to currently bound version of
SQL to retrieve SQL statement text– Ease of use TIP: Make sure you also sort by BIND_TIME
DESC if you have history
![Page 46: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/46.jpg)
© IBM Corporation 2007
46
After you’ve selected a query…
• Query options– Run SQL
– Categorize SQL
• Advisors– Run statistics advisor
• Tools– Query annotation
– Query graph
– Visual Plan Hint
– Query report
![Page 47: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/47.jpg)
© IBM Corporation 2007
47
Query menu
![Page 48: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/48.jpg)
© IBM Corporation 2007
48
Categorize query
• Categorize and store SQL you work with
![Page 49: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/49.jpg)
© IBM Corporation 2007
49
Categorize query
![Page 50: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/50.jpg)
© IBM Corporation 2007
50
Run query(just click run…)
![Page 51: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/51.jpg)
© IBM Corporation 2007
51
Run query output
![Page 52: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/52.jpg)
© IBM Corporation 2007
52
Statistics Advisor
• “Why” statistics advisor outside scope of this session – Covered somewhat in part I
– Covered as session in and of itself.
• Run Statistics Advisor• Statistics Advisor Options
![Page 53: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/53.jpg)
© IBM Corporation 2007
53
FYI - Switching SQL…
SELECT X.DISCOUNT
, SUM(X.QUANTITY) AS SUMQ
, AVG(X.QUANTITY * X.PRICE) AS AVGP
FROM LITEM_UIV_NOGBY AS X
WHERE X.QUANTITY <= 5
AND X.DISCOUNT > 0.08
AND ORDERKEY >30000000
GROUP BY X.DISCOUNT
![Page 54: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/54.jpg)
© IBM Corporation 2007
54
Generate targeted 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 55: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/55.jpg)
© IBM Corporation 2007
55
Run Statistics Advisor
![Page 56: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/56.jpg)
© IBM Corporation 2007
56
Run Statistics Advisor
![Page 57: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/57.jpg)
© IBM Corporation 2007
57
Statistics Advisor Options
• General options– Enable / disable certain analysis options
– Histogram predicate types
• Typical default list– In addition to DDL defined defaults
• Conflict thresholds
![Page 58: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/58.jpg)
© IBM Corporation 2007
58
Statistics Advisor options
![Page 59: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/59.jpg)
© IBM Corporation 2007
59
SA general options
![Page 60: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/60.jpg)
© IBM Corporation 2007
60
SA general options
![Page 61: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/61.jpg)
© IBM Corporation 2007
61
RUNSTATS collection parameters
![Page 62: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/62.jpg)
© IBM Corporation 2007
62
Report type
![Page 63: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/63.jpg)
© IBM Corporation 2007
63
Defaults and conflicts
• Typical default list– Default values typically skewed– If SA observes a “typical default” or a DDL defined default
value within a predicate, it will trigger frequent value collection
• Conflict thresholds– Statistics Advisor looks for inconsistent statistics– Could be inconsistent collection strategy
• Collect table / index statistics at different intervals• Collect statistics on indexes on same columns at different times
– Minor inconsistencies OK and can naturally occur even with consistent collection strategies
• Index cardinalities more accurate than column collected cardinalities (simulation)
![Page 64: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/64.jpg)
© IBM Corporation 2007
64
Predefined defaults
![Page 65: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/65.jpg)
© IBM Corporation 2007
65
Conflict threshold (1)
![Page 66: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/66.jpg)
© IBM Corporation 2007
66
Conflict threshold (2)
![Page 67: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/67.jpg)
© IBM Corporation 2007
67
Query Annotation
![Page 68: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/68.jpg)
© IBM Corporation 2007
68
Query annotation
• Original SQL– Format SQL
– Annotate SQL with statistics
– Helpful highlighting
– Expand / collapse query sections
![Page 69: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/69.jpg)
© IBM Corporation 2007
69
Original SQL
SELECT S_SUPPKEY, S_NAME , SUM(L_EXTENDEDPRICE*(1-L_DISCOUNT)) AS REVENUE FROM SYSADM.ORDER , SYSADM.LINEITEM , SYSADM.SUPPLIER WHERE L_ORDERKEY = O_ORDERKEY AND S_SUPPKEY = L_SUPPKEY AND O_ORDERDATE >= DATE('1993-10-01') AND O_ORDERDATE < DATE('1993-10-01') + 3 MONTH AND L_RETURNFLAG = 'R' AND S_NATIONKEY IN (1,2,3,4,5) AND S_SUPPKEY < 10000 GROUP BY S_SUPPKEY, S_NAME HAVING SUM(L_EXTENDEDPRICE*(1-L_DISCOUNT)) > 1000000 ORDER BY REVENUE DESC QUERYNO 3
![Page 70: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/70.jpg)
© IBM Corporation 2007
70
FormattedSELECT SYSADM.SUPPLIER.S_SUPPKEY , SYSADM.SUPPLIER.S_NAME , SUM( SYSADM.LINEITEM.L_EXTENDEDPRICE * ( 1 -
SYSADM.LINEITEM.L_DISCOUNT ) ) AS REVENUEFROM SYSADM.SUPPLIER , SYSADM.ORDER , SYSADM.LINEITEMWHERE ( SYSADM.LINEITEM.L_ORDERKEY = SYSADM.ORDER.O_ORDERKEY AND SYSADM.SUPPLIER.S_SUPPKEY = SYSADM.LINEITEM.L_SUPPKEY AND SYSADM.LINEITEM.L_RETURNFLAG = 'R' AND SYSADM.ORDER.O_ORDERDATE < ( DATE( '1993-10-01' ) + 3 MONTHS ) AND SYSADM.ORDER.O_ORDERDATE >= DATE( '1993-10-01' ) AND SYSADM.SUPPLIER.S_NATIONKEY IN ( 1, 2, 3, 4, 5 ) AND SYSADM.SUPPLIER.S_SUPPKEY < 10000 )GROUP BY SYSADM.SUPPLIER.S_SUPPKEY , SYSADM.SUPPLIER.S_NAMEHAVING SUM( SYSADM.LINEITEM.L_EXTENDEDPRICE * ( 1 -
SYSADM.LINEITEM.L_DISCOUNT ) ) > 1000000ORDER BY REVENUE DESC
![Page 71: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/71.jpg)
© IBM Corporation 2007
71
AnnotatedSELECT SYSADM.SUPPLIER.S_SUPPKEY , SYSADM.SUPPLIER.S_NAME , SUM( SYSADM.LINEITEM.L_EXTENDEDPRICE * ( 1 - SYSADM.LINEITEM.L_DISCOUNT ) ) AS REVENUEFROM SYSADM.SUPPLIER CARDF=10,000 QUALIFIED_ROWS=1,526.2466 NPAGESF=402 , SYSADM.ORDER CARDF=1,500,000 QUALIFIED_ROWS=57,114.59 NPAGESF=42,417 , SYSADM.LINEITEM CARDF=4,254,339 QUALIFIED_ROWS=1,048,737.0 NPAGESF=141,743WHERE ( SYSADM.LINEITEM.L_ORDERKEY = SYSADM.ORDER.O_ORDERKEY COLCARDF=1,063,455/1,500,00
MAX_FREQ=0.0001645%/0.000066666666FF=6.666666649834951E-7
AND SYSADM.SUPPLIER.S_SUPPKEY = SYSADM.LINEITEM.L_SUPPKEY COLCARDF=10,000/10,000 MAX_FREQ=99.99%/
0.011917244958617542% FF=9.99999901978299E-5
AND SYSADM.LINEITEM.L_RETURNFLAG = 'R' COLCARDF=4MAX_FREQ=50.75460606218732%
FF=0.24650996923446655
AND SYSADM.ORDER.O_ORDERDATE < ( DATE( '1993-10-01' ) + 3 MONTHS ) COLCARDF=2,304 MAX_FREQ=0.0414% FF=0.30288922786712646 LOW2KEY=1992-01-02 HIGH2KEY=1998-
08-01 AND SYSADM.ORDER.O_ORDERDATE >= DATE( '1993-10-01' ) COLCARDF=2,304
MAX_FREQ=0.0414% FF=0.7351873517036438 LOW2KEY=1992-01-02 HIGH2KEY=1998-
08-01 AND SYSADM.SUPPLIER.S_NATIONKEY IN ( 1, 2, 3, 4, 5 ) COLCARDF=25
MAX_FREQ=4.21%FF=0.1526399850845337
AND SYSADM.SUPPLIER.S_SUPPKEY < 10000 COLCARDF=10,000 MAX_FREQ=99.99% FF=0.9998999834060669 LOW2KEY=2 HIGH2KEY=9999
)GROUP BY SYSADM.SUPPLIER.S_SUPPKEY , SYSADM.SUPPLIER.S_NAMEHAVING SUM( SYSADM.LINEITEM.L_EXTENDEDPRICE * ( 1 - SYSADM.LINEITEM.L_DISCOUNT ) ) > 1000000 FF=0.3333333134651184ORDER BY REVENUE DESC
![Page 72: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/72.jpg)
© IBM Corporation 2007
72
Annotated within OSC
![Page 73: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/73.jpg)
© IBM Corporation 2007
73
Annotation table details
• Table annotations– CARDF – number of rows in the table
– NPAGESF – number of pages
– Qualified rows – optimizer estimated number of rows after local filtering (as though table is the outer table)
• Value– Poor join sequence often due to inaccurate filtering estimate at
the single table level
– Qualified rows shows optimizer estimate, is it accurate?
– CARDF, NPAGESF – useful to have this embedded as you’re looking at SQL and predicates
![Page 74: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/74.jpg)
© IBM Corporation 2007
74
Annotation table close-upsSELECT cols…
FROM SYSADM.SUPPLIER
CARDF=10,000
QUAL_ROWS=1,526.2466
NPAGESF=402
, SYSADM.ORDER
CARDF=1,500,000
QUAL_ROWS=57,114.59
NPAGESF=42,417
, SYSADM.LINEITEM
CARDF=4,254,339
QUAL_ROWS=1,048,737.0
NPAGESF=141,743
![Page 75: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/75.jpg)
© IBM Corporation 2007
75
Annotation predicate details
• Column information– COLCARDF – number of distinct values for a
column. For join predicate, both COLCARDF’s shown
• Show selectivity of each predicate
– Max Freq – Maximum frequency (if collected)• Skew statistics collected?
• Show most skewed frequency (indicator of degree of skew)
![Page 76: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/76.jpg)
© IBM Corporation 2007
76
Annotation predicate details
• Column information (cont.)– FF (filter factor) – optimizer single predicate filter
factor estimate• Show optimizer filtering estimate• Is it accurate? (Compare to actual filtering)
– LOW2KEY / HIGH2KEY – shown for range predicates.
• Observe literal value with “domain” of actual values• Can spot stale columns statistics…• Eg. HIGH2KEY = 2006-11-01, you’ve got 2007 data in the
table…• WHERE SALES_DT BETWEEN 2007-01-01 AND 2007-
01-31
![Page 77: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/77.jpg)
© IBM Corporation 2007
77
Annotation predicate close-up( SYSADM.LINEITEM.L_ORDERKEY = SYSADM.ORDER.O_ORDERKEY
COLCARDF=1,063,455/1,500,00MAX_FREQ=0.0001645%/0.000066666666FF=6.666666649834951E-7
AND SYSADM.SUPPLIER.S_SUPPKEY = SYSADM.LINEITEM.L_SUPPKEY COLCARDF=10,000/10,000 MAX_FREQ=99.99%/0.0119% FF=9.99999901978299E-5
AND SYSADM.LINEITEM.L_RETURNFLAG = 'R' COLCARDF=4MAX_FREQ=50.75460606218732%
FF=0.24650996923446655
AND SYSADM.ORDER.O_ORDERDATE < ( DATE( '1993-10-01' ) + 3 MONTHS ) COLCARDF=2,304 MAX_FREQ=0.0414%FF=0.30288922786712646 LKEY=1992-01-02 HKEY=1998-08-01
AND SYSADM.ORDER.O_ORDERDATE >= DATE( '1993-10-01' ) COLCARDF=2,304 MAX_FREQ=0.0414%FF=0.7351873517036438 LOW2KEY=1992-01-02HIGH2KEY=1998-08-01
AND SYSADM.SUPPLIER.S_NATIONKEY IN ( 1, 2, 3, 4, 5 ) COLCARDF=25 MAX_FREQ=4.21%FF=0.1526399850845337
AND SYSADM.SUPPLIER.S_SUPPKEY < 10000 COLCARDF=10,000 MAX_FREQ=99.99% FF=0.9998999834060669 LOW2KEY=2 HIGH2KEY=9999
![Page 78: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/78.jpg)
© IBM Corporation 2007
78
General annotation comments
• SQL analysis– Start at the table level
• Identify any tables where qualified rows estimate looks off
– Examine predicates on that table• Any individual predicates look too
– Optimistic?– Pessimistic?– Frequencies, histograms?
• After individual predicates are OK, any unaddressed correlation?
– KEYCARD, COLGROUP?
– Difficult to estimate predicate?• WHERE SUBSTR(C1,1,4) = ‘ABCD’
![Page 79: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/79.jpg)
© IBM Corporation 2007
79
Query annotation transformed SQL
• Transformed SQL– All original SQL annotation benefits plus
– Show optimizer rewritten SQL• Predicate transitive closure
• Predicate transformations
• Distribution and pruning
• Merge / materialization
![Page 80: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/80.jpg)
© IBM Corporation 2007
80
Query annotation transformed SQL
• Transformed SQL– Show SQL before / after distribution
– Before / after pruning
![Page 81: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/81.jpg)
© IBM Corporation 2007
81
Untransformed UIV SQL
– Where predicates referencing the view
![Page 82: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/82.jpg)
© IBM Corporation 2007
82
Transformed UIV SQL
Hey, where are the predicates?!?
![Page 83: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/83.jpg)
© IBM Corporation 2007
83
Transformed UIV SQL
– Predicates distributed into each leg of the union all view
– Wonder what transformations optimizer did with your query?
– Wonder no more…
![Page 84: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/84.jpg)
© IBM Corporation 2007
84Untransformed UIV5 union all legs
1
2
3
4
5
![Page 85: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/85.jpg)
© IBM Corporation 2007
85Transformed UIV SQL3 union all legs
1
2
3
![Page 86: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/86.jpg)
© IBM Corporation 2007
86
Query report
• Easy to read report which shows– Database / table space
– Table
– Index
– Indexed columns
– Column group cardinality
• Quick reference– Statistics on objects
– Statistics on indexed columns
– KEYCARD statistics mapped into index
![Page 87: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/87.jpg)
© IBM Corporation 2007
87
Query Report
![Page 88: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/88.jpg)
© IBM Corporation 2007
88
New SQL
SELECT <cols>FROM SYSIBM.SYSPACKSTMT AS A , SYSIBM.SYSPACKAGE AS CWHERE ( A.QUERYNO > -1 AND C.COLLID = 'TEST' AND C.NAME = 'PGM1' AND A.COLLID = C.COLLID AND A.LOCATION = C.LOCATION AND A.NAME = C.NAME AND A.VERSION = C.VERSION )ORDER BY <cols>
![Page 89: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/89.jpg)
© IBM Corporation 2007
89
Query report table 1
![Page 90: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/90.jpg)
© IBM Corporation 2007
90
Query report table 2
• Looks like someone forgot to run RUNSTATS…
• Hey… this is MY database!
![Page 91: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/91.jpg)
© IBM Corporation 2007
91
Statistics advisor says…
RUNSTATS TABLESPACE DSNDB06.SYSPKAGE
TABLE(SYSIBM.SYSPACKSTMT)
COLUMN(NAME,QUERYNO,VERSION,COLLID)
TABLE(SYSIBM.SYSPACKAGE)
COLUMN(NAME,VERSION,COLLID)
INDEX(SYSIBM.DSNKSX01 KEYCARD
,SYSIBM.DSNKKX02 KEYCARD
,SYSIBM.DSNKKX01 KEYCARD)
SHRLEVEL CHANGE REPORT YES
![Page 92: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/92.jpg)
© IBM Corporation 2007
92
Query report table 1
• Nice to see cascading MCARD’s– Only matching on 2 or 3 columns?
– Easy to see the KEYCARD bound…
![Page 93: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/93.jpg)
© IBM Corporation 2007
93
Query report table 2
• Easy to read index, indexed columns report.• Observations…
– Clusterratiof of DSNKKX01? 0.795 (reorg?)
– COLCARDF of CONTOKEN?• Not used as a predicate!
![Page 94: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/94.jpg)
© IBM Corporation 2007
94
Access Plan Graph
• Visual explain– Ported from Visual Explain product
– Graphically display access path
![Page 95: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/95.jpg)
© IBM Corporation 2007
95
Access plan graph
![Page 96: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/96.jpg)
© IBM Corporation 2007
96
Access plan graph
![Page 97: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/97.jpg)
© IBM Corporation 2007
97
Access plan graph
![Page 98: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/98.jpg)
© IBM Corporation 2007
98
Query graph overview
• Reading query graph– Read from bottom up
– Left to right
![Page 99: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/99.jpg)
© IBM Corporation 2007
99
Access plan graph
![Page 100: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/100.jpg)
© IBM Corporation 2007
100
Access plan graph zoom
![Page 101: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/101.jpg)
© IBM Corporation 2007
101
Query graph zoom reading
• Access index– Plan_table_IDX1
– Qualifies 2 rows
• Fetch from table– Plan table has 930 rows
– Approximately 1.6 survive
– Inner table is accessed approximately 1.6 times
![Page 102: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/102.jpg)
© IBM Corporation 2007
102
Access plan graph zoom
![Page 103: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/103.jpg)
© IBM Corporation 2007
103
Descriptor
![Page 104: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/104.jpg)
© IBM Corporation 2007
104
Descriptor
![Page 105: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/105.jpg)
© IBM Corporation 2007
105
Descriptor
• Displays detailed information– Descriptor changes as you navigate plan graph
– Click on index node for index information
– Click on table node, table information shown
– Double click node will pop-up independent descriptor window for node
![Page 106: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/106.jpg)
© IBM Corporation 2007
106
Index descriptor
• Index node information– Index creator, name
– Statistics on index
– Uniqueness
– Clustering attribute
– …
![Page 107: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/107.jpg)
© IBM Corporation 2007
107
Index scan descriptor
• Index scan information– Index cardinality
– Index leaf pages
– Matching predicates• Individual matching predicate filter factor
• Bounded matching predicate filter factor
– Total index filtering (matching and screening)
– Estimated scanned leaf pages
– Estimated index qualified rows
![Page 108: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/108.jpg)
© IBM Corporation 2007
108
There’s more…
• Other information…– Identify matching, screening, S1, S2 predicates– Filter factors for predicates– Qualified partitions– Parallelism
• Key range • Page Range• Degree of parallelism
– Sort keys, sort key length– Estimated number of records at
• Index matching, total index filtering• Data access• Sort input / output• Join
![Page 109: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/109.jpg)
© IBM Corporation 2007
109
Demo query graph as time permits
![Page 110: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/110.jpg)
© IBM Corporation 2007
110
Textual explain view…
![Page 111: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/111.jpg)
© IBM Corporation 2007
111
Textual explain view…
• OSC shows plan_table rows• Short / long format• … this is obviously a truncated view…
![Page 112: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/112.jpg)
© IBM Corporation 2007
112
Visual Plan Hint
• Visual Plan Hint– Graphically alter the explain table
• Will show an overview– More details included as part of
– Optimization hints presentation• http://www.bwdb2ug.org/PDF/Optimization%20Hints.pdf
![Page 113: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/113.jpg)
© IBM Corporation 2007
113Visual Plan HintVisual Plan Hint
![Page 114: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/114.jpg)
© IBM Corporation 2007
114Change join sequenceChange join sequence
![Page 115: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/115.jpg)
© IBM Corporation 2007
115Join connectors removedJoin connectors removed
![Page 116: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/116.jpg)
© IBM Corporation 2007
116Move the tables aroundMove the tables around
![Page 117: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/117.jpg)
© IBM Corporation 2007
117Create, connect nodesCreate, connect nodes
![Page 118: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/118.jpg)
© IBM Corporation 2007
118Validate hintValidate hint
Hint
![Page 119: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/119.jpg)
© IBM Corporation 2007
119Validate hint(will show screen shot)
![Page 120: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/120.jpg)
© IBM Corporation 2007
120
Deploy hint
Input query level settings
![Page 121: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/121.jpg)
© IBM Corporation 2007
121
Visual Plan Hint Summary
• Visual Plan Hint– Graphically alter the explain table
– Use of drop down lists reduces errors
– Validation of optimization hint built in
– Colorful compare of before / after access path, very nice
![Page 122: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/122.jpg)
© IBM Corporation 2007
122
OSC Summary
• Optimization Service Center overview– Support for workloads, workload advisors– Monitoring allows for profiling of applications and exception
generated workloads– Consolidated inputs / outputs– Improved statement cache display (allow customized views)
• Improved query tuning tools– Statistics advisor– Annotation– Query report– Access plan graph– Visual plan hint
![Page 123: © IBM Corporation 2007 1 Patrick Bossman IBM Silicon Valley Lab Tuning with Optimization Service Center Part II ® Columbia, MD September 12, 2007](https://reader035.vdocuments.site/reader035/viewer/2022062619/5518a119550346881f8b489c/html5/thumbnails/123.jpg)
© IBM Corporation 2007
123
Patrick Bossman
Tuning with Optimization Service Center II
®