Click here to load reader
View
491
Download
1
Embed Size (px)
DESCRIPTION
ibm.com/redbooks
Database Partitioning, Table Partitioning, and MDC for DB2 9
Whei-Jen ChenAlain FisherAman Lalla
Andrew D McLauchlanDoug Agnew
Differentiating database partitioning, table partitioning, and MDC
Examining implementation examples
Discussing best practices
Front cover
Database Partitioning, Table Partitioning, and MDC for DB2 9
August 2007
International Technical Support Organization
SG24-7467-00
Copyright International Business Machines Corporation 2007. All rights reserved.Note to U.S. Government Users Restricted Rights -- Use, duplication or disclosure restricted by GSA ADPSchedule Contract with IBM Corp.
First Edition (August 2007)This edition applies to DB2 Enterprise Server Edition Version 9 for Linux, UNIX, and Windows.
Note: Before using this information and the product it supports, read the information in Notices on page vii.
Contents
Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viiTrademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ixThe team that wrote this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ixAcknowledgement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiBecome a published author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiComments welcome. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Chapter 1. Introduction to partitioning technologies. . . . . . . . . . . . . . . . . . 11.1 Databases and partitioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1.1 Database concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.2 Table partitioning. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2.1 Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.3 Multi-dimensional clustering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.3.1 Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Chapter 2. Benefits and considerations of database partitioning, table partitioning, and MDC. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.1 Database partitioning feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.1.1 The benefits of using database partitioning feature . . . . . . . . . . . . . 162.1.2 Usage considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.2 Table partitioning. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.2.1 Benefits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222.2.2 Usage considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2.3 Multi-dimensional clustering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272.3.1 Benefits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272.3.2 Usage considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.4 Combining usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Chapter 3. Database partitioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353.1 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.1.1 Supported operating systems and hardware . . . . . . . . . . . . . . . . . . 363.1.2 Minimum memory requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.2 Planning considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373.2.1 Deciding on the number of database partitions. . . . . . . . . . . . . . . . . 383.2.2 Logical and physical database partitions . . . . . . . . . . . . . . . . . . . . . 393.2.3 Partition groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393.2.4 Distribution maps and distribution keys. . . . . . . . . . . . . . . . . . . . . . . 40 Copyright IBM Corp. 2007. All rights reserved. iii
3.2.5 Table spaces and containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 413.2.6 Sizing the tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 423.2.7 Buffer pools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433.2.8 Catalog partition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433.2.9 Coordinator partition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443.2.10 Data placement and table join strategies . . . . . . . . . . . . . . . . . . . . 44
3.3 Implementing DPF on UNIX and Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . 453.3.1 Creating instances and databases . . . . . . . . . . . . . . . . . . . . . . . . . . 463.3.2 Defining database partitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473.3.3 Setting up inter-partition communications . . . . . . . . . . . . . . . . . . . . . 483.3.4 Creating database. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 503.3.5 Switching partitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513.3.6 Adding database partitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 523.3.7 Removing database partitions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533.3.8 Creating database partition groups . . . . . . . . . . . . . . . . . . . . . . . . . . 553.3.9 Viewing partition groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 553.3.10 Redistributing partition groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563.3.11 Altering database partition groups . . . . . . . . . . . . . . . . . . . . . . . . . 583.3.12 Dropping a database partition group. . . . . . . . . . . . . . . . . . . . . . . . 613.3.13 Implementing buffer pools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613.3.14 Implementing table spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633.3.15 Implementing tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
3.4 Implementing DPF on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713.4.1 Installing DB2 Enterprise 9 on Windows . . . . . . . . . . . . . . . . . . . . . . 713.4.2 Working with partitioned databases . . . . . . . . . . . . . . . . . . . . . . . . . 793.4.3 DB2 Remote Command Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
3.5 Administration and management. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 813.5.1 DB2 utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 813.5.2 Monitoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 943.5.3 Rebalancer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
3.6 Using Materialized Query Tables to speed up performance in a DPF environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
3.6.1 An overview of MQTs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1193.6.2 When to consider a MQT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1193.6.3 When to use the MQT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1203.6.4 Intra-database replicated tables and partitioning . . . . . . . . . . . . . . 121
3.7 Best practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1223.7.1 Selecting the number of partitions. . . . . . . . . . . . . . . . . . . . . . . . . . 1223.7.2 Distribution key selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1233.7.3 Collocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124iv Database Partitioning, Table Partitioning, and MDC for DB2 9
Chapter 4. Table partitioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1254.1 Planning considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
4.1.1 Roll-in and roll-out strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1264.1.2 Range selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1284.1.3 Handling large objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1284.1.4 Indexing partitioned tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
4.2 Implementing table partitioning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1294.2.1 Creating a data partitioned table . . . . . . . . . . . . . . . . . . . . . . . . . . . 1304.2.2 Adding a new partition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1414.2.3 Detaching a partition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1434.2.4 Re-attaching a partition . . . .