Professional Documents
Culture Documents
DB2 For i5/OS: V6R1 Overview
DB2 For i5/OS: V6R1 Overview
DB2 For i5/OS: V6R1 Overview
Kent Milligan
i5/OS ISV Solutions Enablement
1
IBM Power Systems Software
2
IBM Power Systems Software
3
IBM Power Systems Software
4
IBM Power Systems Software
OPEN cur1;
FETCH cur1 INTO :orddat:inds; Indicator Meaning
… Values
inds2 = -7; 0 Value is provided
UPDATE orders
-1,-2,-3,-4,-6 Null value
SET shipdate = :nsdate:inds1,
quantity = :nqty:inds2, -5 Default value
status = :nstat:inds3 -7 Column is ignored
WHERE CURRENT OF cur1;
5
IBM Power Systems Software
Executed at 11:32
Executed at 11:30, not yet committed SELECT * FROM flights
UPDATE flights
WHERE
SET departTime=’05:25’
departTime >= ’05:15’
WHERE departTime = ’04:30’
FLIGHTS AND destCity=’HNL’
AND flightNum=331
SKIP LOCKED DATA
AND destCity=’HNL’ flightNum destCity departTime
… … …
4388 RST 08:23
331 HNL 05:25 Wait or Skip?
3044 MSP 03:07
1025 SYD 02:45
389 HNL 06:10
… … …
© 2008 IBM Corporation
6
IBM Power Systems Software
VALUES on FROM
§ Allows programmer to dynamically generate & populate temporary
tables as part of the query definition
– Enable SQL access of in-memory tables maintained by application
– Supports table-less queries
Examples:
SELECT deptnum, deptname FROM org WHERE deptnum <20
UNION ALL
SELECT * FROM (VALUES(77,'New Department')) AS tmp(c1,c2)
7
IBM Power Systems Software
§ Limit Improvements
– 120 columns on GROUP BY
– 128-byte cursor and statement names
– Partial support for 64K Result Set width (V5R4)
© 2008 IBM Corporation
§ V6R1 grouping and OLAP capabilities allow data to be grouped in multiple ways
with a single SQL request
– GROUPING SETS
Less Coding
– ROLLUP for Developers!
– CUBE
8
IBM Power Systems Software
ROLLUP
§ ROLLUP on GROUP BY clause results in DB2 returning aggregates for
each level of the hierarchy implicitly represented in the grouping columns
– ROLLUP(Country, Region) will result in the data being summarized at the following
levels
– (Country, Region)
– (Country)
– ( ) << represents Grand Total
§ Example Query:
SELECT country, region, SUM(sales)
FROM trans
GROUP BY ROLLUP (country, region)
GROUP BY
country,NULL Country Region Sum(Sales)
Canada - 100,000
Canada NW 100,000
U.S.A. - 3,250,000
U.S.A. NE 450,000
U.S.A. NW 940,000
U.S.A. SE 550,000
GROUP BY U.S.A. SW 1,310,000
NULL, NULL
- - 3,350,000
9
IBM Power Systems Software
CUBE
§ CUBE on GROUP BY clause results in DB2 returning aggregates
for all possible distinct combinations represented by the grouping
columns
– CUBE(Country, Region) will result in the data being summarized at the
following levels
– (Country, Region)
– (Country)
– (Region)
– ( ) << represents Grand Total
–Returns results at multiple intersection points
§ Example Query:
SELECT country, region, SUM(sales)
FROM trans
GROUP BY CUBE(country, region)
10
IBM Power Systems Software
GROUPING SETS
§ GROUPING SET on GROUP BY clause enables DB2 to return
aggregates for multiple sets of grouping columns
– GROUPING SETS((Country, Region), (Country, Store)) will result in the data
being summarized at the following levels
– (Country, Region)
– (Country, Store)
§ Example Query:
SELECT country, region, SUM(sales)
FROM trans
GROUP BY GROUPING SETS((country, region), (country, store))
11
IBM Power Systems Software
§ Performance Considerations
– SQE query optimizer contains patented technology allowing DB2 to internally
compute multiple aggregates in single pass of data
– Help optimizer by creating indexes that cover all of the grouping columns in
addition to any local, equal selection predicates
– Best Index keys for sample query above: (transYear, country, region, store)
– Index Advisor enhanced to support new grouping capabilities too!
§ Miscellaneous
– Improved metadata with COMMENT & LABEL Enhancements
– Statement-level Instead Of Triggers
– NEXT_IDENTITY_VALUE for table available in QSYS2.SYSPARTITIONSTAT
© 2008 IBM Corporation
12
IBM Power Systems Software
13
IBM Power Systems Software
Examples:
CREATE TABLESPACE TS1 MANAGED BY DATABASE USING (device
’/dev/rcont $N’ 20000)
SQLSTATE: 01505 / SQLCODE: +143
Message: Statement CREATE TABLESPACE ignored.
14
IBM Power Systems Software
15
IBM Power Systems Software
Performance Enhancements
16
IBM Power Systems Software
§ Create Index statement also supports the ability to create sparse indexes
(ie, Select/Omit criteria) but there currently is no optimizer awareness
– Short-term value: provide SQL replacement of DDS Select/Omit logicals
– EXAMPLE: CREATE INDEX cust_ix1 ON customers(cust_id) WHERE activCust=’Y’
§ Database Monitor
– Enhanced support for OPNQRYF and Query/400 requests (1000 record)
– Enhanced host variable and parameter marker value collection (3010 record)
– New filters for Query Governor and TCP/IP Ports
17
IBM Power Systems Software
V5R4 GA V6R1 GA
Test Environment
1400 § IBM Technology for Java VM – 32 bit
+68%
Transactions per Second
•Improvements shown above are valid only for these specific workloads -- Your results may vary and are dependent on the application.
§ Values accessible with Database Monitor & “SQL Details for Job” tool
– 1000 record type
– Register values
can also be
retrieved with SQL
SELECT
CURRENT
CLIENT_APPLNAME
FROM anyTable
18
IBM Power Systems Software
19
IBM Power Systems Software
20
IBM Power Systems Software
Compare
summary data
before jumping into
low-level analysis
21
IBM Power Systems Software
22
IBM Power Systems Software
23
IBM Power Systems Software
Additional Information
§ DB2 for i5/OS Websites
– Home Page: ibm.com/systemi/db2
– DeveloperWorks Zone: ibm.com/developerworks/db2/products/db2i5OS
– Porting Zone: ibm.com/servers/enable/site/db2/porting.html
§ Newsgroups
– USENET: comp.sys.ibm.as400.misc, comp.databases.ibm-db2
– System i Network DB2 Forum -
http://systeminetwork.com/isnetforums/forumdisplay.php
§ Education Resources - Classroom & Online
– ibm.com/systemi/db2/gettingstarted.html
– ibm.com/servers/enable/site/education/ibo/view.html?oc#db2
§ DB2 for i5/OS Publications
– White Papers: ibm.com/partnerworld/wps/reference/systemi
– Online Manuals: ibm.com/systemi/db2/books.html
– DB2 for i5/OS Redbooks (http://ibm.com/redbooks)
– Getting Started with DB2 Web Query for System i (SG24-7214)
– OnDemand SQL Performance Analysis … in V5R4 (SG24-7326)
– Preparing for and Tuning the SQL Query Engine on DB2 for i5/OS (SG24-6598)
– Modernizing iSeries Application Data Access (SG24-6393)
© 2008 IBM Corporation
24