goodman understanding the power and pitfalls of ... the power and pitfalls...understanding the power...
TRANSCRIPT
1
� San Ramon, CANov 10 -11 2008
� Camp Hill, PANov 17 -18 2008
� Kansas City, MONov 19 -20 2008
Regional Forums
Robert GoodmanSr DBA
Understanding the Power Understanding the Power and Pitfalls of Partitioningand Pitfalls of Partitioning
In V8, 9 and BeyondIn V8, 9 and Beyond
November 10th, 2008 – Session 2
The Power and Pitfalls of PartitioningThe Power and Pitfalls of Partitioning
• Major Points
• Recent major partitioning enhancements
• Overview of major partitioned table concepts
• Good and bad fits
• Implementation options
• Power and pitfalls of options
DB2 Tablespace HistoryDB2 Tablespace History
V1 V2 V3 V4 V5 V6 V7 V8 9 x X+1
Simple
Index Ctrl Partitioned
Table Ctrl Partitioned
Segmented
LOBs
Universal
pureXML
Major Partitioning EnhancementsMajor Partitioning Enhancements
• DB2 V8• Table Based Partitioning
• Multiple Partitioned Indexes
• Clustering Sequence
• Rotate
• DB2 9• Universal (PBG & PBR)
• Clone Tables
• pureXML
• DB2 x• No New Structures
• Enhanced Capabilities
Significant EnhancementsSignificant Enhancements
• Table Controlled Partitioning
• Multiple Partitioned Indexes
• Clustering Index Flexibility
• Rotate Partition
• Universal Table Space
• Clone Tables
• pureXML
Critical AwarenessCritical Awareness
• What Features?
� Rotate
� Clone
• Why?� Unusual behavior
� Physical - logical mapping
� DDL & utility behavior
� Destroy data
� Recovery restrictions
2
Table Controlled PartitioningTable Controlled Partitioning
Table Controlled Partitioning A type of partitioning in which partition boundaries for a partitioned table are controlled by values that are defined in the CREATE TABLE statement.
V8 PartitioningV8 Partitioning
Index-Controlled <OR> Table-Controlled
DB2Catalog
DB2Catalog
Partitioning
Index
Partitioned
Table
PartitionedTable
V8 Partitioned FlexibilityV8 Partitioned Flexibility
Cluster Sequence Independence
Ind
ex C
on
trolle
d
Partitio
nin
g
Table ControlledPartitioning
Multiple Partitioned Indexes
Indexes Optional
Add Partitions
Alter Ranges
Future Enhancem
ents
Future Enhancem
entsFuture E
nhancements
Future Enhancem
ents
Rotate PartitionsRebalance Partitions
Partitioning Index Not Required
Enforce Limitkeys
Table Controlled Partitioning UsageTable Controlled Partitioning Usage
• Why?• Eliminate partitioning index
• Easier admin
• Enforces LIMITKEYs
• Logically cluster data
• Lower overhead
• Multiple partitionedindexes
• Partition independence
• Exploit new functions• CLUSTERING
• ADD PART
• ROTATE
• REBALANCE
• Future Enhancements
CREATE TABLESPACE tablespaceNUMPARTS 4(PARTITION 1 USING …PARTITION 2 USING …PARTITION 3 USING …PARTITION 4 USING …
) IN databaseCREATE TABLE table
(I_COLR,I_ACCN_PATN)PARTITION BY
(I_COLR ASC)(PARTITION 1 ENDING AT ‘BL’ …,PARTITION 2 ENDING AT ‘GR’ …,PARTITION 3 ENDING AT ‘RD’ …,PARTITION 4 ENDING AT ‘YL’ …)
CREATE TABLESPACE tablespaceNUMPARTS 4(PARTITION 1 USING …PARTITION 2 USING …PARTITION 3 USING …PARTITION 4 USING …
) IN databaseCREATE TABLE table
(I_COLR,I_ACCN_PATN)PARTITION BY
(I_COLR ASC)(PARTITION 1 ENDING AT ‘BL’ …,PARTITION 2 ENDING AT ‘GR’ …,PARTITION 3 ENDING AT ‘RD’ …,PARTITION 4 ENDING AT ‘YL’ …)
Creating Table Controlled PartitioningCreating Table Controlled Partitioning
Defines Data Buckets
Defined In The DB2 Catalog,Not By An Index!
Defines Elements &
Ranges, Not An Index!Defines Elements &
Ranges, Not An Index!
Converting to Table ControlledConverting to Table Controlled
ALTER INDEX clustering_index NOT CLUSTER;
(conversion to table-controlled partitioning)
COMMIT WORK;
Simple, Non Disruptive and Quick
ALTER INDEX clustering_index CLUSTER;(clustering index reestablished)
3
Other Ways to ConvertOther Ways to Convert
• Implicit ConversionINDEX CHANGES
ALTER INDEX partitioning-index NOT CLUSTER
CREATE INDEX … PARTITIONED
CREATE INDEX … ENDING AT … omitting CLUSTER keyword
TABLE CHANGES
ALTER TABLE … ADD PARTITION
ALTER TABLE … ROTATE PARTITION
ALTER TABLE … ALTER PARTITION n
Utility Changes
REORG REBALANCE
Listing Table Based PartitioningListing Table Based Partitioning
SELECT
CREATOR
,NAMEFROM SYSIBM.SYSTABLES
WHERE PARTKEYCOLNUM > 0
WITH UR
SELECT
CREATOR
,NAMEFROM SYSIBM.SYSTABLES
WHERE PARTKEYCOLNUM > 0
WITH UR
Table Based PartitioningTable Based Partitioning
Pitfalls
Can’t enforce uniqueness
without an index
Space map not as good as Universal TS in DB2 9
Power
Flexibility and Features
Just Do It!
Partitioned Index ConceptPartitioned Index Concept
Partitioned Index: An index that is physically partitioned. Both partitioning indexes and secondary indexes can be partitioned.
Partitioned IndexesPartitioned Indexes
Non-Partitioned Index
Partitioned Table
Partitioned Index
Ideal for Inter-Partition Queries!
Ideal for Intra-Partition Queries!
V8 Partition IndependenceV8 Partition Independence
BL GR RD YLYL
CREATE TABLE TAB(I_COLR CHAR(2),A_STAT CHAR(2),I_MONT CHAR(2))
PARTITION BY(I_COLR)
CREATE TABLE TAB(I_COLR CHAR(2),A_STAT CHAR(2),I_MONT CHAR(2))
PARTITION BY(I_COLR)
CREATE INDEX IXBON TAB(I_ACCN ASC)
PARTITIONED
CREATE INDEX IXBON TAB(I_ACCN ASC)
PARTITIONED
IXB Part 1 IXB Part 2 IXB Part 3 IXB Part 4
TAB Part 4TAB Part 3TAB Part 2TAB Part 1
2300
22111
2110
1445
1234
2301
2214
2112
1447
1235
2304
2217
2115
1448
1236
2307
2307
2219
2219
2119
2119
1449
1449
1238
1238
CREATE INDEX IXAON TAB(A_STAT ASC, I _COLR ASC)
PARTITIONED
CREATE INDEX IXAON TAB(A_STAT ASC, I _COLR ASC)
PARTITIONED
IXA Part 1 IXA Part 2 IXA Part 3 IXA Part 4WY
,BL
OH
,BL
GA
,BL
FL
,BL
AL
,BL
WY
,GR
WI,G
R
OH
,GR
GA
,GR
FL
,GR
WY
,RD
WI,R
D
GA
,RD
FL
,RD
AL
,RD
WY
,W
Y, Y
LY
L
PN
,P
N, Y
LY
L
GA
,G
A, Y
LY
L
FL
,F
L, Y
LY
L
AL
,A
L, Y
LY
L
REBUILDINDEX P1
LOAD
TS P2
REORG
TS P3
RECOVER
TS P4
4
Partitioned Index UsagePartitioned Index Usage
• Data Access Isolated by Partition
• Can make utilities more manageable
• If all indexes partitioned, have partition independence
• Excellent performance on intra-partition queries
Data Isolation
V8 Creating Indexes V8 Creating Indexes -- Minimal DisruptionMinimal DisruptionR
/O O
uta
ge
SELECT * FROM table WITH UR(non-peak time, prime the buffers)
-DIS DB(database) SPACENAM(tablespace) USE(check for any users)
CREATE INDEX index ON TABLE tableDEFER YES;
(new index established, index in RBDP)
REBUILD INDEX index STATISTICS(R/O outage - index is populated)
REBIND PACKAGE package(rebind plans/packages to use new index)
Create IndexCreate Index ImprovementsImprovements
• V8 REBUILD INDEX
• R/O Outage• Table
• Indexes
• DB2 9 REBUILD INDEX SHRLEVEL CHANGE
• Non-unique index R/W• Table & Indexes
• Unique index• INSERTs not allowed• DELETEs not allowed• UPDATEs not allowed that
affect unique index
Partitioned Index ListingPartitioned Index Listing
SELECTIXCREATOR
,IXNAMEFROM SYSIBM.SYSINDEXPART
WHERE
PARTITION = 1WITH UR
SELECTIXCREATOR
,IXNAMEFROM SYSIBM.SYSINDEXPART
WHERE
PARTITION = 1WITH UR
-DIS DB(db) SPACENAM(is)
NAME TYPE PART STATUSXRG97001 TS 0001 RW
-THRU 0004
-DIS DB(db) SPACENAM(is)
NAME TYPE PART STATUSXRG97001 TS 0001 RW
-THRU 0004
Partitioned IndexesPartitioned Indexes
Pitfalls
• Initial creation disruption
• Data access changes
• Cross partition queries
• Uniqueness enforcement
Power
• Utility independence
• Manageability
Clustering Index ConceptClustering Index Concept
clustering index An index that determines how rows are physically ordered (clustered) in a table space. If a clustering index on a partitioned table is not a partitioning index, the rows are ordered in cluster sequence within each data partition instead of spanning partitions.
5
Clustering Index ConceptClustering Index Concept
RD YL
CREATE TABLE TAB(I_COLR CHAR(2),A_STAT CHAR(2),I_MONT CHAR(2))
PARTITION BY(I_COLR)
CREATE TABLE TAB(I_COLR CHAR(2),A_STAT CHAR(2),I_MONT CHAR(2))
PARTITION BY(I_COLR)
CREATE INDEX IXBON TAB(I_MONT ASC)CLUSTER
CREATE INDEX IXBON TAB(I_MONT ASC)CLUSTER
TAB Part 4TAB Part 3TAB Part 2TAB Part 1
IXB
12
08
06
03
01
11
09
05
03
02
GRBL 12
10
07
04
03
12
09
05
04
01
12
12
12
11
11
10
09
09
08
07
06
05
05
04
04
03
03
03
02
01
01
SequenceSequence SequenceSequence SequenceSequence SequenceSequence
SequenceSequence
CL
US
TE
R
Any Index Can Be The Clustering Index!
The clustering index defines the physical sequence with each partition
Changing ClusteringChanging Clustering
ALTER INDEX old-clustering_index NOT CLUSTER;(clustering index removed)
COMMIT WORK;
ALTER INDEX new_clustering_index CLUSTER;(new clustering index established, table in AREO*)
REORG TABLESPACE tablespace
SHRLEVEL CHANGE STATISTICS COPYDDN(contents of each table put in new clustering sequence)
REBIND PACKAGE
Clustering Index UsageClustering Index Usage
• Improve sequential processing
• Improve clustered
• Improve cluster ratios
• Better access paths
• Optimizer behaves better
• Sequence matches processing
Clustering Index ListingClustering Index Listing
SELECT
CREATOR
,NAMEFROM SYSIBM.SYSINDEXES
WHERE
CLUSTERING = ‘Y’WITH UR
SELECT
CREATOR
,NAMEFROM SYSIBM.SYSINDEXES
WHERE
CLUSTERING = ‘Y’WITH UR
ClusteringClustering
PitfallsAccess path changes
PowerLogical clustering
Better sequential access
Rotate ConceptRotate Concept
Rotate: A movement of an active partition in a circular motion. Partition rotation reuses the oldest partition for new data.
6
ROTATE ConceptROTATE Concept
1Oldest
Limitkey A
2Old
Limitkey B
3New
Limitkey C
4Newer
Limitkey D
Delete Old Data New High
Part Limitkey
New High
Part Limitkey
ROTATE DDL Command1) Delete Oldest Partition Rows2) Reuse Oldest Partition
ROTATE DDL Command1) Delete Oldest Partition Rows2) Reuse Oldest Partition
1Oldest
Limitkey AA
Bit
Bucket
1Newest
Limitkey AAE
ROTATE DDL
ROTATE In ActionROTATE In Action
catg.DSNDB.db.ts.I0001.A0033
catg.DSNDB.db.ts.I0001.A0022
catg.DSNDB.db.ts.I0001.A0044
catg.DSNDB.db.ts.I0001.A0011
LP 4
LP 1
LP 2
LP 3
LP 4
LP 3
LP 2
LP 1
Logical PartitionSYSTABLEPART(V8)
Logical PartitionAfter The ROTATE
Physical PartitionDataset
catg.DSNDB.db.ts.I0001.A0044
catg.DSNDB.db.ts.I0001.A0011
catg.DSNDB.db.ts.I0001.A0033
catg.DSNDB.db.ts.I0001.A0022
Series of ROTATEsSeries of ROTATEs
P1
P2
P3
P4
P1
P2
P3
P4
P3
P4
P1
P2
P4
P1
P2
P3
P1
P2
P3
P4
1st Rotate 2nd Rotate 3rd Rotate 4th RotateALTER T
ABLE ROTATE ...
ENDING A
T (‘E’)
RESET;
ALTER TABLE R
OTATE ...
ENDING A
T (‘E’)
RESET;
Limitkey
‘A’
‘B’
‘C’
‘D’
‘E’
‘F’
‘G’
‘H’
ALTER TABLE R
OTATE ...
ENDING A
T (‘F’)
RESET;
ALTER TABLE R
OTATE ...
ENDING A
T (‘F’)
RESET;
ALTER TABLE R
OTATE ...
ENDING A
T (‘G’) R
ESET;
ALTER TABLE R
OTATE ...
ENDING A
T (‘G’) R
ESET;
ALTER TABLE R
OTATE ...
ENDING A
T (‘H’)
RESET;
ALTER TABLE R
OTATE ...
ENDING A
T (‘H’)
RESET;
Rotate Table UsageRotate Table Usage
Cyclic Tables with Fixed Cycles
DecDec
NovNov
SepSep
AugAug JunJun
MayMay
MarMar
FebFeb
OctOct AprApr
JulJul
JanJan
Rotating PartitionsRotating Partitions
ALTER TABLE tableROTATE PARTITION FIRST TO LASTENDING AT (limitkey) RESET;
Identifying Rotated TablesIdentifying Rotated Tables
SELECT DBNAME
,TSNAMEFROM SYSIBM.SYSTABLEPART
WHERE
DBNAME = ‘db' AND TSNAME = ‘ts'
AND LOGICAL_PART ^= PARTITION
WITH UR
SELECT DBNAME
,TSNAMEFROM SYSIBM.SYSTABLEPART
WHERE
DBNAME = ‘db' AND TSNAME = ‘ts'
AND LOGICAL_PART ^= PARTITION
WITH UR
SELECT
DBNAME
,TSNAMEFROM SYSIBM.SYSCOPY
WHERE
STYPE = ‘R’WITH UR
SELECT
DBNAME
,TSNAMEFROM SYSIBM.SYSCOPY
WHERE
STYPE = ‘R’WITH UR
-DIS DB(db) SPACENAM(ts)
NAME TYPE PART STATUS
SRG9700 TS 0002 RW -THRU 0004
SRG9700 TS 0001 RW
-DIS DB(db) SPACENAM(ts)
NAME TYPE PART STATUS
SRG9700 TS 0002 RW -THRU 0004
SRG9700 TS 0001 RW
?
7
ROTATE PowerROTATE Power
• Cyclic tables
• Managed by DB2
• Minimal disruptions Rotate PitfallsRotate Pitfalls
Wro
ng T
able
Wro
ng T
able
Non R
ecove
rable
Non R
ecove
rable
Double
Rota
te
Double
Rota
teLo
ng D
elet
es
Long
Del
etes
RE
OR
P S
tatu
s
RE
OR
P S
tatu
sE
nfo
rce L
imitkey
s
Enfo
rce L
imitkey
s
Addin
g Par
t
Addin
g Par
t
Logical Diff
erences
Logical Diff
erences
Phy
sica
l and
Phy
sica
l and
Rotate Sequence
Rotate Sequence
(~40 S
ec / m
illio
n)
(~40 S
ec / m
illio
n)
Universal Table Space ConceptUniversal Table Space Concept
Universal Table Space
A table space that is
both segmented and
partitioned.
The Power OfThe Power OfThe Power OfThe Power OfThe Power OfThe Power OfThe Power OfThe Power Of
Universal Table Space ConceptUniversal Table Space Concept
OneOneOneOneOneOneOneOne
Universal Table Space
Why Universal Table Space?Why Universal Table Space?
• Structure “Do Over”
• Time to fix
• Large only
• Single structure
• New enhancements
• Automation
• Older structures phased out
• We should move there
• DB2 x provides direction
• Solve chronic problems
• All tables are partitioned
• Better for you!
UTSUTS
2 Flavors of Universal Table Spaces2 Flavors of Universal Table Spaces
Partition ByGrowth
Partition ByRange
PBG PBR
8
DB2 9DB2 9
Universal Table Space UsageUniversal Table Space Usage
SegmentedSegmented
Tablespace Tablespace
SimpleSimple
Tablespace Tablespace UniversalUniversal
Tablespace Tablespace
PartitionPartition
By GrowthBy Growth
PartitionedPartitioned
TablespaceTablespace
UniversalUniversal
Tablespace Tablespace
PartitionPartition
By RangeBy Range
The FutureThe FutureV8V8
UTSUTS
Universal Table Space ImplementationUniversal Table Space Implementation
DB2 9
UDCL- Unload
- Drop
- Create- Load
DB2 9
UDCL- Unload
- Drop
- Create- Load
DB2 x
ALTER TABLESPACE SEGSIZE
& MAXPARTS
REORG TABLESPACE
SHRLEVEL CHANGE
DB2 x
ALTER TABLESPACE SEGSIZE
& MAXPARTS
REORG TABLESPACE
SHRLEVEL CHANGE
Listing Universal TablespacesListing Universal Tablespaces
SELECT
CREATOR
,NAMEFROM
SYSIBM.SYSTABLESPACEWHERE
TYPE in (‘G’
,’R’)WITH UR
SELECT
CREATOR
,NAMEFROM
SYSIBM.SYSTABLESPACEWHERE
TYPE in (‘G’
,’R’)WITH UR
Universal Table Space PowerUniversal Table Space Power
• Optimal Performance• APPEND
• Mass deletes
• Reordered Row Format
• TRUNCATE
• Large Tables
• INSERT
• ROTATE
• Space Maps
• Manageability
• Simplicity
• Growth
• Features
• Autonomic
Universal TablespaceUniversal Tablespace
PitfallsOne table per table spaceRestrictions on PBG (better than segmented)Can’t change Segsize or DssizeNot compatible with MEMBER CLUSTER (yet)DB2 9 & x - Unload Drop Create Load for PBRDB2 x - PBG converts with REORG
Clone Table ConceptClone Table Concept
Clone Table A table that is structurally identical to a base table. The base and clone table each have separate underlying VSAM data sets, which are identified by their data set instance numbers.
catg.DSNDBD.db.ts.I0001.A001catg.DSNDBD.db.ts.I000I00011.A001
catg.DSNDBD.db.ts.I0002.A001catg.DSNDBD.db.ts.I000I00022.A001
9
Clone Table UsageClone Table Usage
I0001
I0002
catg.DSNDBD.db.ts.I00011.A001
catg.DSNDBD.db.ts.I00022.A001
SYSTABLESPACE
2
1
BaseBase��������
TablesTable Spaces
Base
Clone
Instance
Creating ClonesCreating Clones
catg.DSNDBD.db.ix.J0001.A001catg.DSNDBD.db.ix.J00011.A001
catg.DSNDBD.db.ix.I0001.A001catg.DSNDBD.db.ix.I00011.A001
catg.DSNDBD.db.ts.I0001.A001catg.DSNDBD.db.ts.I00011.A001P.BT
Bas
e O
bje
cts
catg.DSNDBD.db.ix.J0002.A001catg.DSNDBD.db.ix.J00022.A001
catg.DSNDBD.db.ix.I0002.A001catg.DSNDBD.db.ix.I00022.A001
catg.DSNDBD.db.ts.I0002.A001catg.DSNDBD.db.ts.I00022.A001P.CT
Clo
ne O
bje
cts
ALTER TABLE P.BT ADD CLONE P.CT;ALTER TABLE P.BT ADD CLONE P.CT;
Before Triggers
LOBS
XML
etc.
Before Triggers
LOBS
XML
etc.
What DoesnWhat Doesn’’t Get Cloned?t Get Cloned?
1. Data
2. Security
3. Run Statistics (shared)
4. Views & Aliases
5. Image Copies
Loading ClonesLoading Clones
catg.DSNDB.db.ix.J0002.A001catg.DSNDB.db.ix.J00022.A001
catg.DSNDB.db.ix.I0002.A001catg.DSNDB.db.ix.I00022.A001
catg.DSNDB.db.ts.I0002.A001catg.DSNDB.db.ts.I00022.A001P.CT
EXEC SQLINSERT INTO P.CT…..
END-EXEC
EXEC SQLINSERT INTO P.CT…..
END-EXECLOAD INTO TABLE P.CTLOAD INTO TABLE P.CT
SELECT * FROM P.NEWDATAINSERT INTO P.CT
SELECT * FROM P.NEWDATAINSERT INTO P.CT
Working on Clone Table w/UtilitiesWorking on Clone Table w/Utilities
• DB2 9 Utilities - CLONE Keyword• CHECK DATA / INDEX / LOB
• COPY / COPYTOCOPY / MERGECOPY
• DIAGNOSE / LISTDEF
• MODIFY RECOVERY
• QUIESCE
• BEBUILD / RECOVER
• REORG INDEX / TABLESPACE
• REPAIR
• UNLOAD (can specify table instead)
• DB2 9 Utilities – Without CLONE Keyword• DSN1Copy (ID with OBID/PSID)
• DSN1LOGP (clone PSID high order bit set to “1”)
• LOAD (works on table level)
• RUNSTATS (on base table only – doesn’t work on clone)
Exchanging ClonesExchanging Clones
I0001
I0002
SYSTABLESPACE
2
1
BaseBase��������
Base
CloneInstance
I0001
I0002Base
CloneSYSTABLESPACE
2
1BaseBase��������
Instance
EXCHANGE DATA BETWEEN P.BT AND P.CT;EXCHANGE DATA BETWEEN P.BT AND P.CT;
10
Dropping A Clone TableDropping A Clone Table
catg.DSNDB.db.ts.I0001.A001catg.DSNDB.db.ts.I00011.A001P.CT1
catg.DSNDB.db.ix.I0001.A001catg.DSNDB.db.ix.I00011.A001
catg.DSNDB.db.ix.J0001.A001catg.DSNDB.db.ix.J00011.A001
catg.DSNDB.db.ix.J0002.A001catg.DSNDB.db.ix.J00022.A001
catg.DSNDB.db.ix.I0002.A001catg.DSNDB.db.ix.I00022.A001
catg.DSNDB.db.ts.I0002.A001catg.DSNDB.db.ts.I00022.A001P.BT1
ALTER TABLE P.BT1 DROP CLONE;ALTER TABLE P.BT1 DROP CLONE;
Bit
Bucket
Clo
ne O
bje
cts
NAME TYPE
-------- ----
TS1 TSC1
TS1 TSB2
NAME TYPE
-------- ----
TS1 TSC1
TS1 TSB2
catg.DSNDBD.db.ts.I00022.A001
catg.DSNDBD.db.ts.I00011.A001
Clones In ActionClones In Action
Exchange
I0001
I0002
Create
Instance=1
Clone=
Exchange
Instance=2
Clone=Y
Exchange Drop
Instance=2Clone=Y
I0001 I0001
I0002 I0002 I0002
I0001 I0001
SYSTABLESPACE
SELECT *SELECT *
FROM TBFROM TBSELECT *SELECT *
FROM TBFROM TBSELECT *SELECT *
FROM TBFROM TBSELECT *SELECT *
FROM TBFROM TB
I0002
I0001
Instance=1
Clone=Y
Instance=1
Clone=YInstance=2
Clone=N
SELECT *SELECT *
FROM TBFROM TB
Listing Cloned TablesListing Cloned Tables
SELECT
DBNAME,TSNAME
,INSTANCEFROM
SYSIBM.SYSTABLESPACE
WHERE CLONE = ‘Y’
WITH UR
SELECT
DBNAME,TSNAME
,INSTANCEFROM
SYSIBM.SYSTABLESPACE
WHERE CLONE = ‘Y’
WITH UR
SELECTCREATOR
,NAMEFROM
SYSIBM.SYSTABLES
WHERE TYPE = ‘C’
WITH UR
SELECTCREATOR
,NAMEFROM
SYSIBM.SYSTABLES
WHERE TYPE = ‘C’
WITH UR
Cloned Table HistoryCloned Table History
SELECT
DBNAME
,TSNAME,DSNUM
FROM SYSIBM.SYSCOPY
WHERE ICTYPE = ‘C’
WITH UR
SELECT
DBNAME
,TSNAME,DSNUM
FROM SYSIBM.SYSCOPY
WHERE ICTYPE = ‘C’
WITH URSELECT
DBNAME,TSNAME
,DSNUM
FROM SYSIBM.SYSCOPYWHERE
ICTYPE = ‘A’
AND STYPE = ‘E’WITH UR
SELECT
DBNAME,TSNAME
,DSNUM
FROM SYSIBM.SYSCOPYWHERE
ICTYPE = ‘A’
AND STYPE = ‘E’WITH UR
-DIS DB(PRD) SPACE(TS*)
NAME TYPE PART STATUS
-------- ---- ----- -------
TS1 TS RW
TS2 TSB1 0001 RW
TS2 TSC2 0001 RW,ICOPY
TS3 TSB2 0001 RW,UT
TS3 TSC1 0001 RW
TS4 TSB2 0001 RW
TS5 TSB1 0001 RW
-DIS DB(PRD) SPACE(TS*)
NAME TYPE PART STATUS
-------- ---- ----- -------
TS1 TS RW
TS2 TSB1 0001 RW
TS2 TSC2 0001 RW,ICOPY
TS3 TSB2 0001 RW,UT
TS3 TSC1 0001 RW
TS4 TSB2 0001 RW
TS5 TSB1 0001 RW
Ta
ble
Insta
nc
eT
ab
le In
sta
nc
e
Cloned Table DisplayCloned Table Display
CloneCloneBaseBaseClonedCloned
PairPair
ClonedClonedPairPair
FormerFormerClonesClones
CloneCloneBaseBase
NeverNeverClonedCloned
i0001i0001
i0002i0002
i0002i0002
i0001i0001
Clone PowerClone Power
Ideal Way to Flip-Flop Data
No Invalid Packages, Plans, Cache
Minimal Outage on Exchange
Managed By DB2
11
Clone Table PitfallsClone Table Pitfalls
• Can’t Clone
• Non-UTS
• DB2 Catalog
• A Clone
• Temp Tables
• Materialized Query Tables
• With After Trigger
• With Referential Integrity
• Actively Versioned Table
• Base w/out defined datasets
• Base and Clone
• Separate Security
• Share ID column counter
• Share RUNSTATS
• Separate Object States
• Cloned Tables Can’t
• EXCHANGE by partition
• RENAME base table
• ALTER COLUMNS
• ALTER MAXPARTITIONS
• EXCHANGE w/out Claims
• FASTSWITCH
• Clone Dangers
• EXCHANGE & recoverability
• Double EXCHANGE
• Base / Clone Confusion
• DROP CLONE Deletes• Data
• Tablespaces & Indexes
• Other Stuff
HighLowSimpleNicheClone Tables
HighHighDifficult until
DB2 xWide
Universal Table Space
HighLowSimpleNicheRotate
Partitions
HighHighSimpleWideClustering
Index
HighModerateEasier in DB2
9Limited
Partitioned
Indexes
HighHighSimpleWide
Table
Controlled
Partitioning
Applic-
abilityConversion
EffortUsage
Probability
Pa
rtit
ion
ing
Fe
atu
res
UsageBenefit
The Power of PartitioningThe Power of Partitioning
DB2 Tablespaces Trends?DB2 Tablespaces Trends?
V1 V2 V3 V4 V5 V6 V7 V8 9 x X+1
Universal
pureXML
LOBS
Simple ?Index Ctrl Partitioned ?
Table Ctrl Partitioned ?
Segmented ?
Rules of ThumbRules of Thumb
• DB2 V8• Create only parts need
• Don’t specify extreme limitkey
• One table per tablespace
• Convert table controlled part
• Migrate from simple TS
• DB2 9• Create only parts need
• Don’t specify high limitkey
• One table per table space
• Create only universal TS
• Migrate to universal TS
• Migrate to pureXML
• DB2 x & Beyond• Migrate to universal TS
• Migrate to pureXML
The Promise of The Promise of ““NextNext””
• More online schema changes• Table space type
• Page size
• Utility Enhancements
• Performance• Quicker TRUNCATE
• Better Optimization
• Better Availability
• Maintainability
• Much more …..
DB2 DB2 DB2 DB2 xxxx
Changes that Require UDCLChanges that Require UDCL((UUnload / nload / DDrop / rop / CCreate / reate / LLoad)oad)
Reason DB2V7 DB2V8 DB2 9 DB2 x
Alter Partitioning Index X
Alter Clustering Index X
Add New Partitions X
REORG Rebalance Partitions X
Rotate Partitions X
DSSIZE=0 & Need >Max Parts X X X Reorg
Change DSSIZE X X X Reorg
Change Page Size X X X Reorg
Convert EBCDIC to Unicode X X X X
Change Column Datatype X X X X
Convert to UTS X Reorg
Reason DB2V7 DB2V8 DB2 9 DB2 x
Alter Partitioning Index X
Alter Clustering Index X
Add New Partitions X
REORG Rebalance Partitions X
Rotate Partitions X
DSSIZE=0 & Need >Max Parts X X X Reorg
Change DSSIZE X X X Reorg
Change Page Size X X X Reorg
Convert EBCDIC to Unicode X X X X
Change Column Datatype X X X X
Convert to UTS X Reorg
12
Robert GoodmanRobert Goodman
Day: 1 Session: 2
Understanding the Power and Pitfalls of PartitioningUnderstanding the Power and Pitfalls of Partitioning