Partitioning data in Db2 tables
All Db2 base tables that are created in universal table spaces use either partition-by growth or partition-by-range data partitioning.
Before you begin
Consider whether you want to create the table space and database for your table or let Db2 create them for you implicitly.
For more information, see Implementing Db2 table spaces.
About this task
Data partitions are useful because they support partition-level utility operations and parallelism capabilities for improved performance.
Utilities and SQL statements can run concurrently on each partition. For example, a utility job can work on part of the data while allowing other applications to concurrently access data on other partitions. In that way, several concurrent utility jobs can, for example, load all partitions of a table space concurrently. Because you can work on part of your data, some of your operations on the data might require less time. Also, you can use separate jobs for mass update, delete, or insert operations instead of using one large job; each smaller job can work on a different partition. Separating the large job into several smaller jobs that run concurrently can reduce the elapsed time for the whole task.
You can let Db2 manage size-based table partitions based on data growth, or you can specify partitions based on ranges of data values.
- Size-based data partitions
-
Size-based partitions are best when the data in a table is expected to exceed 64 GB, or when a table does not have a suitable partitioning key. Partition-by-growth table spaces can grow up to 128 TB, depending on the buffer pool page size used, and the MAXPARTITIONS and DSSIZE values specified when the table space is created.
If you use size-based partitions, the table resides in partition-by-growth (PBG) table space. For more information, see Creating partition-by-growth table spaces.
- Range-based data partitions
- If you use partitions based on ranges of data values, the table resides in a partition-by-range (PBR) table space. For more information, see Creating partition-by-range table spaces.
If you do not specify how to partition the data when you create a table, Db2 uses size-based partitions and implicitly creates a partition-by-growth table space by default.
When converting or replacing existing tables in deprecated non-UTS table spaces, the type of partitioning to use depends on the existing table space type. For more information, see Converting deprecated table spaces to the UTS types.
Procedure
To control how the data in a table is partitioned, use the following approaches in the CREATE TABLE statement:
What to do next
You might eventually need to add or modify the data partitions. For more information, see Adding partitions and Altering partitions.