CREATE TABLE orders ( o_orderkey INTEGER NOT NULL, o_custkey1 INTEGER, o_custkey2 INTEGER) PRIMARY INDEX (o_orderkey) PARTITION BY (RANGE_N(o_custkey1 BETWEEN 0 AND 50 EACH 10), /* p1 */ RANGE_N(o_custkey2 BETWEEN 0 AND 100 EACH 10)) /* p2 */;
This definition implies the following information about the row partitioning of orders.
- Number of row partitions in the first level, or highest, level = 6
- Number of row partitions in second, or lowest, level = 11
- Total number of combined partitions = 66
- Combined partitioning expression = (p1 - 1) * d2 + p2 = (p1 - 1) * 11 + p2
Now if o_custkey1 is 15 and o_custkey2 is 55, the following additional information is implied:
- Row partition number for level 1 = 2.
- Row partition number for level 2 = 6.
- PARTITION#L3 through PARTITION#L62 are all 0.
- Combined partition number = PARTITION = (2-1)*11 + 6 = 17.
The following case examples demonstrate properties of this partitioning scheme.
SELECT * FROM orders WHERE o_custkey1 = 15;
There may be qualifying rows in the row partitions where the combined row partition numbers = (2 -1)*11 + (1 to 11) = 11 + (1 to 11) = 12 to 22.
SELECT * FROM orders WHERE (o_custkey1 = 15) OR o_custkey1 = 25 AND o_custkey 2 BETWEEN 20 AND 50;
There may be qualifying rows in the row partitions where the combined partition numbers are in (14 to 17, 25 to 28).
SELECT * FROM ORDERS WHERE o_custkey2 BETWEEN 42 AND 47;
There may be qualifying rows in the row partitions where the combined partition numbers are in (5, 16, 27, 38, 49, 60).