39
i want stress-free IT. i want control. i want an i. IBM System i 8 CopyrightIBM Corporation, 2007. A llRightsReserved. Thispublication m ay referto productsthatare notcurrently availablein yourcountry. IBM m akesno com m itm entto m ake availableany productsreferred to herein. © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie Maw IT Specialist IBM (UK) LTD

I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

Embed Size (px)

Citation preview

Page 1: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

i want stress-free IT.

i want control.

i want an i.

IBM System i™

8 Copyright IBM Corporation, 2007. All Rights Reserved.This publication may refer to products that are not currently available in your country. IBM makes no commitment to make available any products referred to herein.

© 2006 IBM Corporation

Are you making the most of your investment in DB2 for i ?

Julie Maw

IT Specialist

IBM (UK) LTD

Page 2: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

• Reduce costs– DB2 for i SWMA costs built into standard SWMA – DB2 for i costs built into IBM i costs – Fewer FTE required to support DB2 for i– Low cost browser based query/reporting tool server license available

• Optimise use of existing assets– DB2 for i is integrated into IBM i– New database applications or LPARs can be easily created without the need

for additional license keys – DB2 for i is integrated into single level storage – no special file system

considerations, or table spaces to maintain– Supports standard interfaces – familiarity for developers writing code– Database partitioning, clustering etc not required– No separate user accounts to be created and maintained

Go Further. Go Leaner. Go GreenGo Further. Go Leaner. Go Green

Page 3: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Are you making the most of your investment?

• What percentage of your queries are running SQE ?• Do you know how to find out ?• If queries are still running CQE – do you know how to find out the reason

for this ?• If a query is performing below expectation – do you know how to find out

what it’s doing ?• Do you have sufficient understanding of database optimisation to enable

you to make suggestions for possible performance improvements ?• Do you know how to measure your changes to evaluate their

effectiveness ?• Have you ever considered EVI’s ?• Have you ever considered creating MQTs ?• Are you taking advantage of SMP ?• Do you have a DBA ?

Page 4: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

V5R2, V5R3, V5R4 and V6R1 Database Architecture

Optimizer

Query Dispatcher

CQE Optimizer SQE Optimizer

SLIC

DB2 UDB (Data Storage & Management)

SQE Optimizer

SQE Primitives

SQE Statistics Manager

CQE Database Engine

SLICThe optimizer and database engine

merged to form the SQL Query Engine,

and much of the work was moved to SLIC

Page 5: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

CQE/SQE – why should we care ?

Self-Optimizing Query Environment

QU

ER

Y1

QU

ER

Y2

QU

ER

Y3

QU

ER

Y4

QU

ER

Y5

QU

ER

Y6

QU

ER

Y7

QU

ER

Y8

QU

ER

Y9

QU

ER

Y1

0

QU

ER

Y11

QU

ER

Y1

2

QU

ER

Y1

3

QU

ER

Y1

4

QU

ER

Y1

5

QU

ER

Y1

6

QU

ER

Y1

7

QU

ER

Y1

8

QU

ER

Y1

9

QU

ER

Y2

0

0

1

2

3

4

5

6

7

8

9

Tho

usan

dsS

econ

ds V5R1

V5R2

Analytical Join Queries

Sample Queries

0

2000

4000

6000

8000

10000

12000

mS

ec V5R1

V5R2

OLTP Queries

AND…

This is for SQE stage 1.

V6R1 implements SQE stage 6

Page 6: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Priority actions

• SQE

• A good indexing strategy

The interface for managing the The interface for managing the database and performing database and performing database analysis is iSeries database analysis is iSeries NavigatorNavigator

SQL Performance Monitors

Page 7: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Database Performance Monitor data

• Integrated tools to gather database performance related statistics for SQL-based requests

• Will tell you whether the query was executed by CQE or SQE

• The database performance monitor data is dumped into tables which can then be analyzed at a system, job or statement level

• STRDBMON/ENDDBMON or

In all versionsAdded in V5R4

V6R1 adds filters for port number and query governor

Page 8: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Analysis of Database Performance Monitor data

• V5R3– Custom queries due to lack

of selectivity in the GUI

• V5R4 and V6R1– Custom queries or analysis

reports

– Can import a V5R3 monitor into a V5R4 or V6R1 system

– In V6R1 you can customise the columns in the reports

– In V6R1 you can save the reports in text, XML or spreadsheet format

List of statements filled after Retrieve or Refresh Visual Explain button

Page 9: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Compare Database Performance Monitor data

Page 10: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Visual Explain is available from many different starting points

Page 11: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Page 12: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

CQE

SELECT * FROM STARDEMO. FACTWHEREFACT.CUSTKEY = 472 AND FACT.PARTKEY IN (100, 200, 300);

Page 13: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Set IGNORE_DERIVED_INDEX *YES in the active QAQQINI

Page 14: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

And re-run the query

Now SQE

SELECT * FROM STARDEMO. FACTWHEREFACT.CUSTKEY = 472 AND FACT.PARTKEY IN (100, 200, 300);

Page 15: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Toggle the IGNORE_DERIVED_INDEX or switch between QAQQINI files

Further analysis with the database monitor data

Start/Stop and analyse the database monitor data

Page 16: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

The ability to control what is being traced

Page 17: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Analyse the Performance Monitor Data

Page 18: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Show Statements

Page 19: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

CQE/SQE example querying a VIEWCREATE VIEW MY_VIEW01 ASCREATE VIEW MY_VIEW01 ASSELECT YEAR, QUARTER, MONTH, sum(QUANTITY) AS TOTAL_QUANTITYSELECT YEAR, QUARTER, MONTH, sum(QUANTITY) AS TOTAL_QUANTITYFROM ITEM_FACTFROM ITEM_FACTGROUP BY YEAR, QUARTER, MONTHGROUP BY YEAR, QUARTER, MONTH

SELECT YEAR, QUARTER, min(TOTAL_QUANTITY), max(TOTAL_QUANTITY), SELECT YEAR, QUARTER, min(TOTAL_QUANTITY), max(TOTAL_QUANTITY), avg(TOTAL_QUANTITY)avg(TOTAL_QUANTITY)FROM MY_VIEW01FROM MY_VIEW01WHERE YEAR=1997WHERE YEAR=1997and upper('x')='X'GROUP BY year, quarter;GROUP BY year, quarter;

833 833 rowsrows

12 12 rowsrows

48 48 rowsrows

4rows4rows

CQECQE

SQESQE

Here CQE is Here CQE is materialising the VIEW materialising the VIEW (GROUP BY in view and (GROUP BY in view and query)query)

Here SQE creates a Here SQE creates a composite VIEWcomposite VIEW

Page 20: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

SQE Plan Cache

• Self managed cache for all plans produced by SQE optimiser

• Cleared at IPL

Page 21: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Create Plan Cache Snapshots

Page 22: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

System-WideIndex Advisor

SQE Plan Cache

Query Optimization

SQL request

DetailedDB Monitor

Data

DebugJob Log

MessagesPrint SQL

InformationMessages

VisualExplain

Feedback and analysis

SummarizedDB Monitor

Data

SQE Plan Cache

Snapshots

Page 23: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

System wide Index Advisor added in V5R4

V5R3 V5R4

Page 24: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Index Advised – System wide

Show the SQE statements that led to this advice

Show SQL Show SQL option in V6R1 and save as a script

Page 25: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

SYSTEM WIDE INDEX ADVISOR – SHOW STATEMENTS

Page 26: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

For specific query advice click on Actions > AdvisorFor specific query advice click on Actions > Advisor

Page 27: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Page 28: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Page 29: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

CREATE INDEX STARDEMO.DEMO_IDX_01 ON STARDEMO.FACT ( PARTKEY ASC , ORDERPRIORITY ASC ) ;

Runtime down from 5116 to

65ms

Page 30: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

CREATE INDEX STARDEMO.DEMO_IDX_01 ON STARDEMO.FACT ( PARTKEY ASC , ORDERPRIORITY ASC ) ;

What will happen with this query ?

SELECT PARTKEY, ORDERPRIORITY from STARDEMO.FACT

WHERE PARTKEY=28 and ORDERPRIORITY=’1-URGENT’;

Page 31: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

SHOW INDEXES

e.g.

Last query use and query use count

Last query stats use and query stats use count

Key columns

Current size

Estimated rebuild time

Maintenance

AND

See the existence of temp indexes !!

Page 32: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Autonomic Index Creation

• The optimiser can request that DB2 for i creates a temp index

• CQE– Temp indexes are not reused– Temp indexes are not shared– Can significantly impact performance (query and system)

• SQE– New feature in V5R4 (MTI)– Temp indexes are reused and shared across jobs and queries– Creation is based on “watching” the query requests over time– Creation is based on the optimiser’s own advice– Maintenance is delayed

Page 33: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Encoded Vector Index (EVI)

• Announced in V4R3• EVI is composed of two parts...

SYMBOL TABLE:

Key Value Code Count

Aberdeen 1 1000

Bath 2 450

Birmingham 3 10000

Bristol 4 6500

Cardiff 5 5000

… … …

Warwick 49 340

York 50 1280

• Symbol table contains information for each distinct key value

Row

1 1

17 2

5 3

9 4

2 5

7 6

49 7

49 8

5 9

… …

OnlyCodes

VECTOR:

Page 34: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Index ANDing/ORing

SELECT * FROM STARDEMO.ITEM_F_12M AS FACT WHERE FACT.CUSTKEY BETWEEN 100 and 300 OR FACT.PARTKEY BETWEEN 1000 AND 5000;

Page 35: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

MQTSELECTSELECT FACT.YEAR, FACT.QUARTER, FACT.YEAR, FACT.QUARTER, CUST.COUNTRY, CUST.REGION, PART.BRAND, CUST.COUNTRY, CUST.REGION, PART.BRAND, sum(FACT.REVENUE_WQ_TAX) as sum(FACT.REVENUE_WQ_TAX) as TOTAL_REVENUE, TOTAL_REVENUE, sum(FACT.PROFIT_WO_TAX) AS "GROSS sum(FACT.PROFIT_WO_TAX) AS "GROSS PROFIT", sum(FACT.PROFIT_W_TAX) AS "NET PROFIT", sum(FACT.PROFIT_W_TAX) AS "NET PROFIT" PROFIT" FROMFROM STARDEMO.ITEM_FACT AS FACT, STARDEMO.ITEM_FACT AS FACT, STARDEMO.PART_DIM AS PART, STARDEMO.PART_DIM AS PART, STARDEMO.CUST_DIM AS CUST STARDEMO.CUST_DIM AS CUST WHEREWHERE FACT.PARTKEY=PART.PARTKEY AND FACT.PARTKEY=PART.PARTKEY AND FACT.CUSTKEY=CUST.CUSTKEY AND FACT.CUSTKEY=CUST.CUSTKEY AND CUST.MKTSEGMENT='FURNITURE' AND CUST.MKTSEGMENT='FURNITURE' AND YEAR=1997 AND COUNTRY='UNITED YEAR=1997 AND COUNTRY='UNITED KINGDOM'KINGDOM'GROUP BYGROUP BY FACT.YEAR, FACT.QUARTER, FACT.YEAR, FACT.QUARTER, CUST.COUNTRY, CUST.REGION, PART.BRAND CUST.COUNTRY, CUST.REGION, PART.BRAND ORDER BYORDER BY FACT.YEAR, FACT.QUARTER, FACT.YEAR, FACT.QUARTER, CUST.COUNTRY, CUST.REGION, PART.BRANDCUST.COUNTRY, CUST.REGION, PART.BRAND

SELECTSELECT FACT.YEAR, FACT.QUARTER, FACT.YEAR, FACT.QUARTER, FACT.MONTH, CUST.COUNTRY, CUST.REGION, FACT.MONTH, CUST.COUNTRY, CUST.REGION, CUST.TERRITORY, CUST.MKTSEGMENT, CUST.TERRITORY, CUST.MKTSEGMENT, PART.BRAND, PART.TYPE, PART.BRAND, PART.TYPE, sum(FACT.REVENUE_WO_TAX) as sum(FACT.REVENUE_WO_TAX) as TOTAL_REVENUE, TOTAL_REVENUE, sum(FACT.PROFIT_WO_TAX) AS "GROSS sum(FACT.PROFIT_WO_TAX) AS "GROSS PROFIT", sum(FACT.PROFIT_W_TAX) AS "NET PROFIT", sum(FACT.PROFIT_W_TAX) AS "NET PROFIT", COUNT(*) AS ROW_PER_GROUP PROFIT", COUNT(*) AS ROW_PER_GROUP FROMFROM STARDEMO.ITEM_FACT AS FACT, STARDEMO.ITEM_FACT AS FACT, STARDEMO.PART_DIM AS PART, STARDEMO.PART_DIM AS PART, STARDEMO.CUST_DIM AS CUST STARDEMO.CUST_DIM AS CUST WHEREWHERE FACT.PARTKEY=PART.PARTKEY AND FACT.PARTKEY=PART.PARTKEY AND FACT.CUSTKEY=CUST.CUSTKEY FACT.CUSTKEY=CUST.CUSTKEY GROUP BYGROUP BY FACT.YEAR, FACT.QUARTER, FACT.YEAR, FACT.QUARTER, FACT.MONTH, CUST.COUNTRY, CUST.REGION, FACT.MONTH, CUST.COUNTRY, CUST.REGION, CUST.TERRITORY, CUST.MKTSEGMENT, CUST.TERRITORY, CUST.MKTSEGMENT, PART.BRAND, PART.TYPEPART.BRAND, PART.TYPEORDER BYORDER BY FACT.YEAR, FACT.QUARTER, FACT.YEAR, FACT.QUARTER, FACT.MONTH, CUST.COUNTRY, CUST.REGION, FACT.MONTH, CUST.COUNTRY, CUST.REGION, CUST.TERRITORY, CUST.MKTSEGMENT, CUST.TERRITORY, CUST.MKTSEGMENT, PART.BRAND, PART.TYPEPART.BRAND, PART.TYPE

WITH INDEXES – 2.5WITH INDEXES – 2.5

WITH MQT – 1.8WITH MQT – 1.8

WITH INDEX ON MQT – 0.08WITH INDEX ON MQT – 0.08

Page 36: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Predictive Query Governor

• Specify a time limit and/or a temporary storage limit

• Stop queries running before they start

• System value QQRYTIMLMT

• CHGQRYA parameters QRYTIMLMT and QRYSTGLMT

• QAQQINI parameters QUERY_TIME_LIMIT and TEMP_STORAGE

• Causes an inquiry message to be issued– I to ignore or C to cancel– An exit program can be called (V5R4)

Page 37: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Some other stuff

• LF on the FROM clause - CQE

• Consider fair share of memory

• *FIRSTIO versus *ALLIO

• Environment

• SMP

Page 38: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

Go Further. Go Leaner. Go GreenGo Further. Go Leaner. Go Green

• DB2 for i SQE includes a sophisticated, self-learning optimiser

• DB2 for i is unique in that it is designed and built into the system– DBA is freed from the traditional DBA technical tasks required on other

RDBMSs– IBM POWER systems running IBM i – a modern database appliance

• Fewer technical staff required

• To get the best out of your investment:To get the best out of your investment:

• Implement a good indexing strategyImplement a good indexing strategy

• Make best use of the DB2 for i GUI toolset Make best use of the DB2 for i GUI toolset

• Get educated – Mike Cain from Rochester will be teaching a performance Get educated – Mike Cain from Rochester will be teaching a performance workshop in the UK (June 22-24).workshop in the UK (June 22-24).http://www-304.ibm.com/jct03001c/services/learning/ites.wss/gb/en?pageType=course_description&includeNotScheduled=y&courseCode=OL40ZGBhttp://www-304.ibm.com/jct03001c/services/learning/ites.wss/gb/en?pageType=course_description&includeNotScheduled=y&courseCode=OL40ZGB

Page 39: I want stress-free IT. i want control. i want an i. IBM System i ™ © 2006 IBM Corporation Are you making the most of your investment in DB2 for i ? Julie

IBM System i

© 2009 IBM Corporationi want an i.

IBM Education

• DB2 for i SQL Performance Monitoring and Tuning Workshop (taught by Mike Cain from IBM Rochester):

http://www-304.ibm.com/jct03001c/services/learning/ites.wss/gb/en?pageType=course_description&includeNotScheduled=y&courseCode=OL40ZGB

• DB2 Web Query courses are now available from IBM Education:

http://www-304.ibm.com/jct03001c/services/learning/ites.wss/gb/en?pageType=course_description&courseCode=OD04GB

http://www-304.ibm.com/jct03001c/services/learning/ites.wss/gb/en?pageType=

course_description&courseCode=OD05GB