Scalable Database Server, HiRDB Version 8 Description
Partitioning a table by a combination of partitioning methods using two table columns as partitioning keys is called matrix partitioning. The first column used as a partitioning key is called the first dimension partitioning column, and the second column used as a partitioning key is called the second dimension partitioning column. Matrix partitioning involves key range partitioning with boundary values specified for the first dimension partitioning column and then partitioning the resulting data further by the second dimension partitioning column. The following partitioning methods can be specified for the second dimension partitioning column:
A table that has been matrix-partitioned is called a matrix-partitioned table. You can also perform matrix partitioning on indexes that have been mapped to a matrix-partitioned table. Note that you must have HiRDB Advanced Partitioning Option to perform matrix partitioning on a table.
The following describes the benefits that are provided by using multiple columns as partitioning keys to split a table:
We recommend using key range partitioning with boundary values specified for both partitioning columns when the following conditions are met:
When the following conditions are met, we recommend that you combine key range partitioning with boundary values specified and hash partitioning:
To define matrix partitioning, specify the following in the PARTITIONED BY MULTIDIM operand of the CREATE TABLE definition SQL:
In this example, boundary values are specified for the registration date (RDATE) and the store number (SNUM) in a customer data table. The table is then matrix partitioned such that the user data is stored by registration date and store number in the user RDAREAs USR01 to USR06. In this example, the number of user RDAREAs needed to store this data is (the number of boundary values for RDATE +1) (the number of boundary values for SNUM + 1), so the number of user RDAREAs needed is 3 2 = 6.
RDATE | SNUM | |
---|---|---|
100 or less | 101 or greater | |
2000 and earlier | USR01 | USR02 |
2001 | USR03 | USR04 |
2002 and later | USR05 | USR06 |
The following shows the SQL code used to matrix partition the table:
CREATE FIX TABLE CTBL (RDATE DATE, SNUM INT, CNAME NCHAR(10)) PARTITIONED BY MULTIDIM( RDATE (('2000-12-31'),('2001-12-31')), . . .1. STORE_NO ((100)) . . .2. )IN ((USR01,USR02),(USR03,USR04),(USR05,USR06))
Figure 3-15 shows an example of matrix partitioning.
Figure 3-15 Example of matrix partitioning (combining with key range partitioning with boundary values specified)
This example uses FIX hash partitioning for the second dimension partitioning column.
In this example, boundary values are specified for the registration dates in a customer table, and then a hash function is used to separate the data by store number and region code into three segments. This results in a table that is matrix partitioned such that each segment of customer data is stored in one of the user RDAREAs (USR01 to USR09) shown below. The number of user RDAREAs needed to store the resulting data is (number of boundary values + 1) (desired partitions to be obtained by hash function). In this example, the number is 3 3 = 9.
Registration date | Store number and region code (divided into 3 partitions by hash function) | ||
---|---|---|---|
2002 and earlier | USR01 | USR02 | USR03 |
2003 | USR04 | USR05 | USR06 |
2004 and later | USR07 | USR08 | USR09 |
The following code shows the SQL statement used to define the table to be matrix partitioned:
CREATE FIX TABLE customer-table (registration-date DATE, store-number INT, region-code INT, customer-name NCHAR(10)) PARTITIONED BY MULTIDIM (registration-date (('2002-12-31'),('2003-12-31')), ...1. FIX HASH HASH6 BY store-number, region-code ...2. )IN ((USR01,USR02,USR03), (USR04,USR05,USR06), (USR07,USR08,USR09))
Figure 3-16 shows an example of matrix partitioning.
Figure 3-16 Example of matrix partitioning (combination of key range partitioning with boundary values specified and hash partitioning)
All Rights Reserved. Copyright (C) 2007, Hitachi, Ltd.