A table group is a logical concept that represents a collection of tables. By default, data in different tables is randomly distributed with no direct relationship among them. By defining a table group, you can control the physical proximity of a group of tables in storage.
A table group only requires defining the SHARDING attribute, allowing you to flexibly add tables with different partitioning methods. If you want to restrict other tables from joining a table group, you can modify the table group's attributes. This makes table group management more flexible.
Based on the value of the SHARDING attribute, table groups can be mainly divided into the following two categories:
Table groups with
SHARDING = NONE: All partitions of all tables in such a table group are aggregated on the same machine, and the partition type of tables within the group is not restricted.Table groups where
SHARDINGis notNONE: The data of each table in such a table group is scattered across multiple machines. To ensure the same data distribution across all tables, all tables in the table group must have consistent partition definitions, including partition type, number of partitions, and partition values. The system schedules partitions with the same partition attributes to aggregate (align) on the same machine, thereby enabling Partition Wise Join.Table groups where
SHARDINGis notNONEare further divided into the following three types:Table groups with
SHARDING = PARTITION: The data of each table in the table group is scattered by its partition. For a subpartitioned table, all subpartitions under a partition are aggregated together.Partition requirement: All tables must have the same primary partition definition. For a subpartitioned table, only the primary partition definition is verified. Therefore, partitioned tables and subpartitioned tables can coexist as long as their primary partition definitions are the same.
Partition alignment rule: Partitions with the same primary partition value are aggregated together, including the primary partitions of a partitioned table and all subpartitions under the corresponding primary partition of a subpartitioned table.
Table groups with
SHARDING = ADAPTIVE: The data of each table in the table group is scattered in an adaptive manner. That is, if a table in the table group is a partitioned table, its data is scattered by partition; if a table in the table group is a subpartitioned table, its data is scattered by the subpartitions under each partition.The partition requirement and partition alignment rule for tables in such a table group are as follows:
Partition requirement: All tables in the table group must be either all partitioned tables or all subpartitioned tables. If they are partitioned tables, they must have the same primary partition definition. If they are subpartitioned tables, they must have the same primary partition and subpartition definitions.
Partition alignment rule: If all tables in the table group are partitioned tables, partitions with the same primary partition value are aggregated together. If all tables in the table group are subpartitioned tables, subpartitions with the same primary partition value and subpartition value are aggregated together.
Table groups with
SHARDING = SUBPARTITION: Tables added to the table group must be subpartitioned tables, and the data of each table in the table group is scattered by the subpartitions under the partition.Partition requirement: The partitioning method and subpartitioning method must be the same for different tables, including the partitioning key type, partitioning function, number of partitions, and partition boundary values.
Partition alignment rule:
Subpartition alignment across partitions: Subpartitions with the same partitioning key value under different partitions are bound to the same log stream.
Global index alignment: The subpartitions of the primary table and the partitions of the global index table are bound to the same log stream using the same partitioning key value, and the binding is implicit. Binding occurs only when the global index's partitioning method is exactly the same as the primary table's subpartitioning method.