Vous êtes sur la page 1sur 20

DB2 Big Data: Partitioning with Universal Tablespaces

Who is CDB Software?


The first in data management solutions for DB2. Focused on DB2 for z/OS since 1985 as the first ISV Purveyor of innovative solutions that enable companies to expand their DB2 systems in order to meet business needs while controlling the overall cost of the mainframe

Why our customers chose CDB Ease of Use Comprehensive automation Optimized production processes Minimize Resources Maximize availability Minimize execution time Eliminate cumbersome/intrusive vendor products Cope with number and size of current and future DB2 objects

2014Themis,Inc.Allrightsreserved.

Themis Education

Most complete DB2 Curriculum in the industry Offerings include a complete mainframe curriculum in addition to z/OS, Java, .NET, Oracle, Linux, UNIX, etc. F Founded d di in 1991 b by t training i i executives ti f from O OnLine Li S Software ft Over 300 IT courses Regularly providing speakers to local DB2, Websphere MQ and CICS User Groups throughout the US and Canada.

2014Themis,Inc.Allrightsreserved.

David Simpson p
David Simpson is currently a Senior Technical Advisor at Themis Inc. He teaches courses on SQL, Application Programming Database Administration as well as Programming, optimization, performance and tuning. He also installs and maintains the database systems used for training at Themis and works with our network of instructors to deliver high quality training solutions to our customers world wide wide. Since 1993 David has worked as a developer and DBA in support of very large transactional and business intelligence systems David is a certified DB2 DBA on both z/OS and systems. LUW. David was voted Best User Speaker and Best Overall Speaker at IDUG North America 2006. He was also voted Best User Speaker at IDUG Europe 2006 and is a member of the IDUG Speakers Hall of Fame Fame. dsimpson@themisinc.com www.themisinc.com

2014Themis,Inc.Allrightsreserved.

Agenda
Partitioning Choices in DB2 9, 10 and beyond Universal Partition By Range (PBR) Universal Partition By Growth (PBG) Potential Issues and Recommendations

2014Themis,Inc.Allrightsreserved.

Tablespace Types p yp
(& before) Simple Segmented Partitioned (& after) Simple (deprecated) Segmented Classic Partitioned Universal Partition by Range Partition by Growth

2014Themis,Inc.Allrightsreserved.

Partitioning g Choices
(& before)
Index Controlled Range Partitioning Index Controlled Range Partitioning Table Controlled Range Partitioning

(& after)
Index Controlled Range Partitioning Table Controlled R Range P Partitioning titi i Universal Partition by y Range g ( (PBR) ) Universal Partition by Growth (PBG)

2014Themis,Inc.Allrightsreserved.

Index Controlled Partitioning DDL


CREATE TABLESPACE IXCPTS IN THEMISDB DB2 10 d defaults f lt th the SEGSIZE NUMPARTS 9 to 32. You can use SEGSIZE 0 USING STOGROUP TEACHERS to get a classic partitioned PRIQTY 720 SECQTY 720 tablespace. tab espace PCTFREE 10 FREEPAGE 0 BUFFERPOOL BP0; CREATE TABLE PEOPLE (PERSON_ID (PERSON ID INTEGER NOT NULL ,LAST_NAME CHAR(20) NOT NULL ,FIRST_NAME CHAR(20) NOT NULL ,ZIP_CODE CHAR(5) NOT NULL ,BIRTH_DTE DATE NOT NULL ) IN THEMISDB.IXCPTS;
2014Themis,Inc.Allrightsreserved.

Index Controlled Partitioning DDL


CREATE INDEX PEOPLEX1 ON PEOPLE(PERSON_ID) PEOPLE(PERSON ID) CLUSTER (PART 1 VALUES (1000000) ,PART PART 2 VALUES (2000000) ,PART 9 VALUES (9000000) ) USING STOGROUP TEACHERS PRIQTY 720 SECQTY 720 PCTFREE 5 FREEPAGE 0 BUFFERPOOL BP0;

2014Themis,Inc.Allrightsreserved.

Table Controlled Partitioning DDL


CREATE TABLESPACE TBCPTS IN THEMISDB NUMPARTS 9 USING STOGROUP TEACHERS PRIQTY 720 SECQTY 720 PCTFREE 10 FREEPAGE 0 BUFFERPOOL BP0; CREATE TABLE PEOPLE (PERSON_ID INTEGER NOT NULL ,LAST NAME CHAR(20) NOT NULL ,LAST_NAME ,FIRST_NAME CHAR(20) NOT NULL ,ZIP_CODE CHAR(5) NOT NULL BIRTH DTE DATE NOT NULL) ,BIRTH_DTE PARTITION BY (PERSON_ID) (PARTITION 1 ENDING AT (1000000) ,PARTITION 2 ENDING AT (2000000) ,PARTITION 9 ENDING AT (9000000) ) IN THEMISDB.TBCPTS;

2014Themis,Inc.Allrightsreserved.

Table Controlled Partitioning DDL


CREATE INDEX PEOPLEX1 ON PEOPLE(PERSON_ID) CLUSTER PARTITIONED USING STOGROUP TEACHERS PRIQTY 720 SECQTY 720 PCTFREE 5 FREEPAGE 0 BUFFERPOOL BP0;

2014Themis,Inc.Allrightsreserved.

Universal Tablespace PBR


CREATE TABLESPACE UNIPBRTS IN THEMISDB CREATE TABLE PEOPLE NUMPARTS 9 (PERSON_ID INTEGER NOT NULL USING STOGROUP TEACHERS ,LAST NAME CHAR(20) NOT NULL ,LAST_NAME PRIQTY 720 SECQTY 720 ,FIRST_NAME CHAR(20) NOT NULL PCTFREE 10 FREEPAGE 0 ,ZIP_CODE CHAR(5) NOT NULL BUFFERPOOL BP0 BIRTH DTE DATE NOT NULL) ,BIRTH_DTE SEGSIZE 32; PARTITION BY (PERSON_ID) (PARTITION 1 ENDING AT (1000000) ,PARTITION 2 ENDING AT (2000000) (& after) ,PARTITION 9 ENDING AT (9000000) ) IN THEMISDB.UNIPBRTS;
2014Themis,Inc.Allrightsreserved.

Universal Tablespace PBG


CREATE TABLESPACE UNIPBGTS IN THEMISDB CREATE TABLE PEOPLE MAXPARTITIONS 10 (PERSON_ID INTEGER NOT NULL DSSIZE 4G ,LAST NAME CHAR(20) NOT NULL ,LAST_NAME USING STOGROUP TEACHERS ,FIRST_NAME CHAR(20) NOT NULL PRIQTY 720 SECQTY 720 ,ZIP_CODE CHAR(5) NOT NULL PCTFREE 10 FREEPAGE 0 BIRTH DTE DATE NOT NULL) ,BIRTH_DTE BUFFERPOOL BP0 IN THEMISDB.UNIPBGTS; SEGSIZE 64;

(& after)

2014Themis,Inc.Allrightsreserved.

PBG Considerations
Small tables that remain in 1 partition should cause no issues. If the tablespace grows to multiple partitions a few things happen: All indexes behave as NPSIs. IBM Utilities treat these as NPSIs. You cannot consolidate to fewer partitions if the table shrinks until DB2 11 (see new zParm REORG O G_DROP O _PBG G_PARTS). S) You cannot explicitly add a partition. You must reach the DSSIZE for all previously allocated parts parts.
2014Themis,Inc.Allrightsreserved.

Utility Considerations
Partition level reorgs are a problem because: Size if the partition expands beyond the DSSIZE While the clustering index is respected, new rows may go into ANY partition making re re-clustering clustering at reorg impossible if you only reorganize partitions. All the headaches of managing NPSIs on large partitioned tablespaces. LOAD REPLACE can only work at the tablepace level.

2014Themis,Inc.Allrightsreserved.

Tablespace Recommendations
One table per tablespace. Consider C id U Universal i lt tablespaces bl f for any new objects. bj t DB2 10 allows conversion from single table simple & segmented tablespaces to PBG with an online reorg. DB2 10 also allows conversion from classic classic partitioning to Universal PBR but the entire tablespace must be reorganized in one step. Other Online Schema changes must also be accomplished at the tablespace level (not partitions). See Craig Mullins presentation on schema changes.
2014Themis,Inc.Allrightsreserved.

Big g Data Case Study y


366 Partition PBR 4G DS 1 NPI 6 DPSIs 4.7 Billion Rows 4TB of data

2014Themis,Inc.Allrightsreserved.

Big g Data Case Study y


DBAs had a maintenance schedule to manage g this large g object with DB2 Utilities Reorg 4 partitions at a time during each maintenance window 4 hour process (manageable) Approached A h d th the 4G li limit it on many partitions titi Resolution Online Schema Change to DSSIZE 32G BUT!!!... BUT!!!

2014Themis,Inc.Allrightsreserved.

Big g Data Case Study y


Online Schema Change g required q a reorg g of the entire 4T object Required a purchase of an additional 6T of SORT DASD Estimated to run for 4 days!

2014Themis,Inc.Allrightsreserved.

Big g Data Case Study y


Solution CDB/Auto-Online Reorg Run time 11 hours No down time No SORT Work Space Completion p of Online Schema Change! g Notes Regular maintenance schedule reduced to 35 minutes (from 4 hrs) using CDB/Auto-Online CDB/Auto Online Reorg CDB has the technology to treat a PBG like a PBR during a reorg and run partitions in parallel

2014Themis,Inc.Allrightsreserved.