A table group is a logical concept. It represents a collection of tables. By default, data is randomly distributed to the tables in a table group. By defining a table group, you can control the physical closeness among a group of tables.
In OceanBase Database V3.x, a table group is a collection of tables with defined partitions. Tables that are added to a table group must have the same partitioning method, which imposes strong restrictions on tables to be added to the group. From V4.2.0, the concept of partitions is no longer applicable to table groups. Instead, tables can be added to a table group by simply defining the SHARDING attribute, allowing you to flexibly add tables with different partitioning methods. If there is a need to restrict other tables from being added to the table group, the properties of the table group can be modified, enabling more flexible management of table groups.
Table groups with the SHARDING attribute can be classified based on the attribute values.
Table groups with
SHARDINGset toNONE: All partitions of all tables in such a table group are aggregated on the same server and the tables can have different partitioning types.Table groups with
SHARDINGnot set toNONE: The data of each table in such a table group is distributed to multiple servers. To ensure consistent table data distribution, all tables in the table group must have the same partition definition, including the partitioning type, partition count, and partition value. The system schedules or aligns partitions with the same partition attribute to the same server to implement partition-wise join.Table groups whose
SHARDINGvalue is notNONEare further classified based on the actual attribute values.Table groups with
SHARDINGset toPARTITION: The data of each table in such a table group is scattered by partition. For a subpartitioned table in the table group, all subpartitions in a partition are aggregated together.Partition requirement: All tables must have the same partition definition. For subpartitioned tables, the partition definition, rather than the subpartition definition, is verified. Therefore, a table group can contain both partitioned and subpartitioned tables only if they have the same partition definition.
Partition alignment rule: Partitions with the same partition value are aggregated together, including partitions of partitioned tables and all subpartitions in the corresponding partitions of subpartitioned tables.
Table groups with
SHARDINGset toADAPTIVE: The data of each table in such a table group is adaptively scattered. In other words, data in partitioned tables is scattered by partition, and data in subpartitioned tables is scattered by subpartition in each partition.Take note of the partition requirement and partition alignment rule for tables in such a table group:
Partition requirement: Tables in such a table group are all partitioned tables or all subpartitioned tables. If they are partitioned tables, they must have the same partition definition. If they are subpartitioned tables, they must have the same partition definition and subpartition definition.
Partition alignment rule: If all tables in such a table group are partitioned tables, partitions with the same partition value are aggregated together. If all tables in such a table group are subpartitioned tables, subpartitions with the same partition value and subpartition value are aggregated together.