50
Table Controlled Partitioning The rules of the game Kurt Struyf, Competence Partners Réunion du Guide DB2A pour z/OS France Jeudi 31 janvier 2008 Hôtel Mercure, Paris-La Défense

Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

  • Upload
    dophuc

  • View
    221

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Table Controlled Partitioning The rules of the game

Kurt Struyf, Competence Partners

Réunion du Guide DB2A pour z/OS France Jeudi 31 janvier 2008

Hôtel Mercure, Paris-La Défense

Page 2: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Kurt Struyf started his career at a major Belgian bank. Where he was part of the system DBA team.He worked for an outsourcing company where he installed, tuned and migrated DB2 systems for multiple customers. He was also directly involved in the design and tuning of DB2 related applications and structures.

Currently Kurt is working as a consultant/contractor for Competence Partners. He has over ten years experience as a (system) DBA and has been installing, migrating, troubleshooting and tuning DB2 systems throughout Europe. Besides his consultancy missions he has been teaching a broad spectrum of DB2 courses through IBM education services, both in Europe and the USA. These courses range from basic courses like DB2 fundamentals, SQL workshops, application programming, database administration workshops, over DB2 application data recovery and application Performance and Tuning, towards more advanced classes like DB2 System Administration, System Performance Analysis, System/ Disaster Recovery Workshop etc

He was a speaker at several IDUG European and North America conferences . He’s been a speaker at numerous DB2 regional user groups in Europe.

Bio Kurt Struyf

Page 3: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Agenda

• Partitioning Pre-V8• Partitioning during V8• Consequences of table controlled

partitioning• Partition Management

• Add partition• Rotate partition• Reorg rebalance

• Partitioning during V9

3

Page 4: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Before Version 8

100

200

300

Partitioning indexPartitioned table

Partitioned tablespace

Non-Partitioning index1 (NPI1)

Non-Partitioning index2 (NPI2)

4

Page 5: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Syntax Before Version 8

CREATE TABLE TRUYK.Z9PARTTB (COL1 SMALLINT, COL2 CHAR(2))

IN ZTRUYKDB.Z9PARTTS ;

CREATE TABLESPACE Z9PARTTS IN ZTRUYKDB NUMPARTS 3 ;

INCOMPLETE

SYSIBM.SYSTABLESColumn STATUS =‘I’

5

Page 6: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

CREATE INDEX TRUYK.Z9PARTI1 ON TRUYK.Z9PARTTB ( COL1 ASC ) CLUSTER( PART 1 VALUES ( 100)

PART 2 VALUES ( 200)PART 3 VALUES ( 300))

SYSIBM.SYSINDEXESColumn TYPE = ‘2’

SYSIBM.SYSINDEXPARTColumn LIMITKEY = 100Column LIMITKEY = 200Column LIMITKEY = 300

6

Syntax Before Version 8

Page 7: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Problem Before Version 8

100

200

300

Partitioning indexPartitioned table

Partitioned tablespace

Non-Partitioning index1 (NPI1)

Non-Partitioning index2 (NPI2)

Has to be the CLUSTERING index Build2 phase

Only one PARTITIONEDindex

7

Page 8: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Agenda

• Partitioning Pre-V8• Partitioning during V8• Consequences of table controlled

partitioning• Partition Management

• Add partition• Rotate partition• Reorg rebalance

• Partitioning during V9

8

Page 9: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

You have a choice

CREATE TABLE TRUYK.Z9PARTTB ( EMPNO SMALLINT,

FNAME CHAR(10)LASTNAME CHAR(10)ADDRESS CHAR(20)CITY CHAR(10)STATE CHAR(2)) IN ZTRUYKDB.Z9PARTTS ;

- - - - - - - - - - - - - -CREATE INDEX TRUYK.Z9PARTI1

ON TRUYK.Z9PARTTB ( EMPNO ASC )

CLUSTER PARTITION BY RANGE (

PARTITION 1 ENDING AT ( 100)PARTITION 2 ENDING AT ( 200) PARTITION 3 ENDING AT ( 300))

CREATE TABLE TRUYK.Z9PARTTB ( EMPNO SMALLINT,

FNAME CHAR(10)LASTNAME CHAR(10)ADDRESS CHAR(20)CITY CHAR(10)STATE CHAR(2))

PARTITION BY (EMPNO ASC) (PARTITION 1 ENDING AT ( 100),PARTITION 2 ENDING AT ( 200), PARTITION 3 ENDING AT ( 300))

IN ZTRUYKDB.Z9PARTTS ;

INDEX CONTROLLED TABLE CONTROLLED

COMPLETE

9

Page 10: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

What has changed in Version 8

• Any index can become the clustering index.• Any index can be PARTIONED.• An index is qualified as partioning or secondary.

Table controlled partitioning means :NO INDEX needed to control partitioned table

10

Page 11: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Clustering index

CREATE TABLE TRUYK.Z9PARTTB ( EMPNO SMALLINT,

FNAME CHAR(10)LASTNAME CHAR(10)ADDRESS CHAR(20)CITY CHAR(10)STATE CHAR(2))

PARTITION BY (EMPNO ASC) (PARTITION 1 ENDING AT ( 100),PARTITION 2 ENDING AT ( 200),PARTITION 3 ENDING AT ( 300))

IN ZTRUYKDB.Z9PARTTS ;

CREATE INDEX TRUYK.Z9PARTI1 ON TRUYK.Z9PARTTB (EMPNO ASC )PARTITIONED ;

CREATE INDEX TRUYK.Z9PARTI2 ON TRUYK.Z9PARTTB (STATE ASC )

CLUSTER

Z9PARTI1

EMPNO

Z9PARTI2

ALAZCACTILMDNYOHTX

STATE

100

200

300

Z9PARTTB005…AL002…CT050…NY001…OH

120…AZ187…CA150…NY111…OH

205…AL202…AZ250…NY201…TX

11

Page 12: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Change Clustering index

• Active immediately• Reorg recommended

Old clustering index (empno)

Insert values (301, ‘AAA’)

Insert values (302, ‘AAA’)

New clustering index (Name) Insert values (302, ‘AAA’)

ALTER CLUSTER

12

Page 13: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Partitioning or Secondary

NEW definition of partitioning index

PARTITIONING index =

FIRST columns of the index, match the columns of the “PARTITION BY” clause

EVERY other index is a SECONDARY index

13

Page 14: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Partitioning or Secondary

CREATE TABLE TRUYK.Z9PARTTB ( EMPNO SMALLINT,

FNAME CHAR(10)LASTNAME CHAR(10)ADDRESS CHAR(20)CITY CHAR(10)STATE CHAR(2))

PARTITION BY (EMPNO ASC)(PARTITION 1 ENDING AT ( 100),PARTITION 2 ENDING AT ( 200),PARTITION 3 ENDING AT ( 300))

IN ZTRUYKDB.Z9PARTTS ;

CREATE INDEX TRUYK.Z9PARTI1 ON TRUYK.Z9PARTTB (EMPNO ASC )PARTITIONED ;

CREATE INDEX TRUYK.Z9PARTI2 ON TRUYK.Z9PARTTB (STATE ASC )

CLUSTER

CREATE INDEX TRUYK.Z9PARTI3 ON TRUYK.Z9PARTTB (EMPNO ASC ,LASTNAME DESC );

CREATE INDEX TRUYK.Z9PARTI4 ON TRUYK.Z9PARTTB (LASTNAME ASC ,CITY ASC )

PARTITIONED

PARTITIONING

PARTITIONING

SECONDARY

SECONDARY

14

Page 15: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Partitioned or Non-partitioned

CREATE TABLE TRUYK.Z9PARTTB ( EMPNO SMALLINT,

FNAME CHAR(10)LASTNAME CHAR(10)ADDRESS CHAR(20)CITY CHAR(10)STATE CHAR(2))

PARTITION BY (EMPNO ASC) (PARTITION 1 ENDING AT ( 100),PARTITION 2 ENDING AT ( 200),PARTITION 3 ENDING AT ( 300))

IN ZTRUYKDB.Z9PARTTS ;

CREATE INDEX TRUYK.Z9PARTI1 ON TRUYK.Z9PARTTB (EMPNO ASC )PARTITIONED ;

CREATE INDEX TRUYK.Z9PARTI2 ON TRUYK.Z9PARTTB (STATE ASC )

CLUSTER

CREATE INDEX TRUYK.Z9PARTI3 ON TRUYK.Z9PARTTB (EMPNO ASC ,LASTNAME DESC );

CREATE INDEX TRUYK.Z9PARTI4 ON TRUYK.Z9PARTTB (LASTNAME ASC ,CITY ASC )

PARTITIONED

15

Page 16: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

16

Partitioned or Non-partitioned

100

200

300

Z9PARTTBZ9PARTI1

EMPNO

Z9PARTI2

ALAZCACTILMDNYOHTX

STATE

005…AL002…IL050…NY001…OH

120…AZ187…CA150…NY111…OH

205…AL202…AZ250…NY201…TX

Z9PARTI3

EMPNO, Lastname

001, Presley002, Sinatra003, Berry004, Lewis…121, Cole122, Martin…

299, Cash300, Holly

PARTITIONED

Z9PARTI4

Lastname,City

…Cole, MontgomeryMartin, Steubenville…

…Cash, NashvilleHolly, Lubbock…

PARTITIONED

Presley, MemphisSinatra, ChicagoBerry, St.-LouisLewis, Ferriday

Page 17: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

DPSI

Z9PARTI4

Lastname,City

…Cole, MontgomeryMartin, Steubenville…

…Cash, NashvilleHolly, Lubbock…

PARTITIONED

Presley, MemphisSinatra, ChicagoBerry, St.-LouisLewis, Ferriday

SECONDARY

• Data Partitioned Secondary Index

• Advantages :- No Build2 phase- No contention during LOAD part- Performance, if partition is known

• Disadvantages : - Cannot be UNIQUE- Performance, if partition not known- Increased DSMAX- Larger EDMPOOL

17

Page 18: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Display statement

18

Page 19: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Agenda

• Partitioning Pre-V8• Partitioning during V8• Consequences of table controlled

partitioning• Partition Management

• Add partition• Rotate partition• Reorg rebalance

• Partitioning during V9

19

Page 20: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

V8 syntax table controlled

CREATE TABLE TRUYK.Z9PARTTB ( EMPNO SMALLINT,

FNAME CHAR(10)LASTNAME CHAR(10)ADDRESS CHAR(20)CITY CHAR(10)STATE CHAR(2))

PARTITION BY (EMPNO ASC) (PARTITION 1 ENDING AT ( 100),PARTITION 2 ENDING AT ( 200), PARTITION 3 ENDING AT ( 300))

IN ZTRUYKDB.Z9PARTTS ;

• CREATE INDEX PARTITIONED

• ALTER INDEX NOT CLUSTER on the partitioning index

• ALTER INDEX CLUSTER on the partitioning index

• DROP PARTITIONING INDEX

• ALTER TABLE ADD PARTITION

• ALTER TABLE ROTATE PARTITION

• ALTER TABLE ALTER PARTITION “n”

• CREATE INDEX ENDING AT ...

BE CAREFUL !!

20

Page 21: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

21

Consequence of alter

ALTER INDEX TRUYK.Z9PARTI1 NOT CLUSTER;

---------+---------+---------+---------+---------+- --------+---------+----DSNT404I SQLCODE = 20272, WARNING : TABLE SPACE Z9PARTTS HAS BEEN CONVERTED TO USE TABLE-CONTROLLED PARTITIONING INSTEAD OF INDEX- CONTROLLED

PARTITIONING, ADDITIONAL INFORMATION: 300

PARTKEYCOLNUM PARTKEYCOLNUM0 1SYSIBM.SYSTABLES

TYPE 2SYSIBM.SYSINDEXES

TYPE P

LIMITKEY 100SYSIBM.SYSINDEXPART

PART 1LIMITKEY 200PART 2LIMITKEY 300PART 3

LIMITKEYPART 1LIMITKEYPART 2LIMITKEYPART 3

LIMITKEYPART 1LIMITKEYPART 2LIMITKEYPART 3

LIMITKEY 100PART 1LIMITKEY 200PART 2LIMITKEY X’FF’PART 3

SYSIBM.SYSTABLEPART

Page 22: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

22

Consequence of alter

LIMITKEY 100PART 1LIMITKEY 200PART 2LIMITKEY X’FF’PART 3

INSERT INTO Z9PARTTB VALUES(305,'Richie','Vallens', 'some street', 'LosAngeles', 'CA')

HIGH LIMIT KEY IS ENFORCED

Index controlled partitioning Table controlled partitioning

Page 23: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Agenda

• Partitioning Pre-V8• Partitioning during V8• Consequences of table controlled

partitioning• Partition Management

• Add partition• Rotate partition• Reorg rebalance

• Partitioning during V9

23

Page 24: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Add Partition

• Before V8– Unload all partitions– Drop tablespace– Create tablespace

with more parts– Load partitions– Full Image Copy

• In V8– Alter table

Table Controlled partitioning needed

24

Page 25: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Add Partition

100

200

300

Z9PARTTB005…AL002…CT050…NY001…OH

120…AZ187…CA150…NY111…OH

205…AL202…AZ250…NY201…TX

A001

A002

A003

500

A004

ALTER TABLE ADDPART_TESTADD PARTITION ENDING AT (500) INCLUSIVE

NO partition number

CAN NOT specify size

25

Page 26: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Recover add Partition

100

200

300

005…AL002…CT050…NY001…OH

120…AZ187…CA150…NY111…OH

205…AL202…AZ250…NY201…TX

100

200

300

005…AL002…CT050…NY001…OH

120…AZ187…CA150…NY111…OH

205…AL202…AZ250…NY201…TX

500

305…AL302…AZ350…NY301…TX

100

200

300

005…AL002…CT050…NY001…OH

120…AZ187…CA150…NY111…OH

205…AL202…AZ250…NY201…TX

100

200

300

005…AL002…CT050…NY001…OH

120…AZ187…CA150…NY111…OH

205…AL202…AZ250…NY201…TX

600

T1 T3 T4recover toT2

T2

FIC

Alter add partition

Alter add partition

500

500

26

Page 27: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Index controlled partitioningand add partition (1/3)

100

200

300

005…AL002…CT050…NY001…OH

120…AZ187…CA150…NY111…OH

305…AL202…AZ250…NY201…TX

T1 T2

Alter add partition ending at 500

DSNT408I SQLCODE = -636, ERROR: THE PARTITIONING K EYS FOR PARTITION 4 ARE NOT SPECIFIED IN ASCENDING OR DESCE NDING ORDER

T3

LIMITKEY 100PART 1

LIMITKEY 200PART 2

LIMITKEY X’FF’PART 3

Why ?

27

Page 28: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

28

T3

LIMITKEY 100PART 1

LIMITKEY 200PART 2

LIMITKEY X’FF’PART 3

DSNT404I SQLCODE = 610, WARNING: A CREATE/ALTER ON OBJECT TRUYK.Z9PARTTB HAS PLACED OBJECT IN REORG PENDING

ALTER TABLE Z9PARTTB ALTER PARTITION 3 ENDING AT ( 300)

T4Alter add partition ending at 500

T5

REORP

REORP

Reorg tablespace Z9PARTS

T6

Index controlled partitioningand add partition (2/3)

Page 29: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

29

Index controlled partitioningand add partition (3/3)

T3

LIMITKEY 100PART 1

LIMITKEY 200PART 2

LIMITKEY X’FF’PART 3

DSNT404I SQLCODE = 610, WARNING: A CREATE/ALTER ON OBJECT TRUYK.Z9PARTTB HAS PLACED OBJECT IN REORG PENDING

ALTER TABLE Z9PARTTB ALTER PARTITION 3 ENDING AT ( 300)

T4 T5

Reorg tablespace Z9PARTS

LIMITKEY 100PART 1

LIMITKEY 200PART 2

LIMITKEY 300PART 3

Child tables in CHKP

1 row discarded

BUT !!

Page 30: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Agenda

• Partitioning Pre-V8• Partitioning during V8• Consequences of table controlled

partitioning• Partition Management

• Add partition• Rotate partition• Reorg rebalance

• Partitioning during V9

30

Page 31: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Rotate Partition

CREATE TABLESPACE Z9ROTATS IN ZTRUYKDBNUMPARTS 3 ;

CREATE TABLE Z9ROTATB( YEAR SMALLINT,SALES CHAR(10),REGION CHAR(10))

PARTITION BY (YEAR ASC)(PARTITION 1 ENDING AT (2004),PARTITION 2 ENDING AT (2005),PARTITION 3 ENDING AT (2006))IN ZTRUYKDB.Z9ROTATS

31

Page 32: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Rotate Partition

32

Page 33: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Rotate Partition

ALTER TABLE ROT_PART_TESTROTATE PARTITION FIRST TO LASTENDING AT (2007 ) INCLUSIVE RESET

2004

2005

�2006

1

2

3

1

2

3

2005

2006

2007

1

2

3

1

2

3

2006

2007

2008

1

2

3

1

2

3

ALTER TABLE ROT_PART_TESTROTATE PARTITION FIRST TO LASTENDING AT (2008) INCLUSIVE RESET

33

Page 34: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Rotate Partition

34

Page 35: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Rotate Partition

SELECT DSNUM, LOGICAL_PART, ICTYPE, STYPEFROM SYSIBM.SYSCOPYWHERE DBNAME = 'ZTRUYKDB'AND TSNAME = 'Z9ROTATS' ;

---------+---------+---------+---------+---DSNUM LOGICAL_PART ICTYPE STYPE

---------+---------+---------+---------+---1 1 Q2 2 Q3 3 Q1 1 F2 2 F3 3 F ---------+---------+---------+---------+

DSNUM LOGICAL_PART ICTYPE STYPE---------+---------+---------+---------+

2 3 A R1 3 A R1 1 Q2 2 Q3 3 Q1 1 F2 2 F3 3 F

35

Page 36: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Rotate Partition

DB2 issues individual deletes

- logging- performanceDB2 holds DBD-lock

DB2 invalidate plans, packages, statement cache

GOOD IDEA :

LOAD PART REPLACE

36

Page 37: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

37

Houston We HaveA Problem

NO Point-in-time RECOVERYPossible

Page 38: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Agenda

• Partitioning Pre-V8• Partitioning during V8• Consequences of table controlled

partitioning• Partition Management

• Add partition• Rotate partition• Reorg rebalance

• Partitioning during V9

38

Page 39: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Reorg Rebalance

ALTER TABLE Z9ROTATBADD PARTITIONENDING AT (2009 ) ;

ALTER TABLE Z9ROTATBROTATE PARTITION FIRST TO LASTENDING AT (2010 ) INCLUSIVE RESET ;

+

39

Page 40: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Reorg Rebalance

---------+---------+---------+---------+--

DSNUM LOGICAL_PART ICTYPE STYPE

---------+---------+---------+---------+--

3 4 W

2 2 W

REORG TABLESPACE ZTRUYKDB.Z9ROTATS PART(2:3)SHRLEVEL REFERENCE ;

Expected result reorg part 2, 4, 3

ACTUAL result : reorg of DSNUM 2 and 3

40

Page 41: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Add and Rotate Partition Combined

When combined with “add partition” ����

keep track of physical dataset

ALTER TABLESPACE… PART N

-or-

REORG TABLESPACE… PART NReorg doesn’t solve

logical/physicalproblem

41

Page 42: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Reorg Rebalance

• Reorg rebalance allows an automatic “more even” distribution of data over the partitions

• New limit keys are determined at reorg time

• Shrlevel reference is possible

42

Page 43: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Reorg Rebalance

SELECT CARD, DSNUM, LIMITKEY, LOGICAL_PARTFROM SYSIBM.SYSTABLEPARTWHERE DBNAME = 'ZTRUYKDB'AND TSNAME = 'Z9PARTTS';---------+---------+---------+--------+---------+

CARD DSNUM LIMITKEY LOGICAL_PART---------+---------+---------+--------+---------+

25 1 100 125 1 200 2

350 1 300 3

43

Page 44: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Reorg Rebalance

SELECT CARD, DSNUM, LIMITKEY, LOGICAL_PART

FROM SYSIBM.SYSTABLEPART

WHERE DBNAME = 'ZTRUYKDB'

AND TSNAME = 'Z9PARTTS';

---------+---------+---------+--------+---------+

CARD DSNUM LIMITKEY LOGICAL_PART

---------+---------+---------+--------+---------+152 1 210 1

130 1 216 2

118 1 300 3

REORG TABLESPACE ZTRUYKDB.Z9PARTTS PART(N:M)REBALANCESHRLEVEL REFERENCE

44

Page 45: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Reorg Rebalance

ALTER TABLE Z9ROTATBADD PARTITIONENDING AT (2009 ) ;

ALTER TABLE Z9ROTATBROTATE PARTITION FIRST TO LASTENDING AT (2010 ) INCLUSIVE RESET ;

+

45

Page 46: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Reorg Rebalance

REORG TABLESPACE ZTRUYKDB.Z9ROTATS PART(2:3) REBALANCESHRLEVEL REFERENCE ;

DSNUGUTC - REORG TABLESPACE ZTRUYKDB.Z9ROTATS PART(2:3) REBALANCE SHRLEVEL REFEERENCE

DSNURFIT - PARTITION RANGE NOT CONTIGUOUS - REBALANCE IGNOREDDSNUGBAC - UTILITY EXECUTION TERMINATED, HIGHEST RETURN CODE=8

46

Page 47: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Reorg rebalance

• Be careful : repartition based on amount of keys.

• Varchar rows can still cause unevenVSAM size

• Uneven distribution of keys can still cause uneven VSAM size (e.g. many dupilcate keys)

47

Page 48: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Agenda

• Partitioning Pre-V8• Partitioning during V8• Consequences of table controlled

partitioning• Partition Management

• Add partition• Rotate partition• Reorg rebalance

• Partitioning during V9

48

Page 49: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Partitioning during V9

Introduction of Universal Table spaces

Advantages :

• partition by growth

• better space management

• improved mass delete performance

• immediate of segments after drop table

Restrictions :

• Cannot be used as workfile

• More space map pages

CREATE TABLESPACE TEST01TS IN TEST01DB USING STOGROUP SG1 DSSIZE 2GMAXPARTITIONS 24LOCKSIZE ANY SEGSIZE 4; COMMIT;

Partition by growth

Page 50: Table Controlled Partitioning - The rules of the · PDF fileTable Controlled Partitioning The rules of the game ... Kurt Struyf started his career at a major Belgian bank. ... towards

Questions ?

[email protected]

www.cp.be