A table group is a logical collection concept used to organize a group of tables with strong business relevance. In OceanBase Database, by default, data from different tables is randomly distributed across different storage nodes. By creating a table group, you can explicitly define the physical proximity of this group of tables, thereby optimizing the performance of related queries and facilitating data management.
SHARDING Attribute of Table Groups
In earlier versions (V3.x), table groups had strict partition definitions, which imposed strong restrictions on which tables could join a table group. Starting from V4.2.0, the SHARDING attribute was introduced for table groups, replacing the original partition concept. This attribute determines how partitions corresponding to the tables within the table group are aggregated and distributed across the cluster. These aggregated sets of partitions are called partition groups.
The SHARDING attribute has the following three modes, each corresponding to a different data distribution strategy:
SHARDING = NONE: Indicates that there are no restrictions on the partitioning method for the tables joining the table group, and partitions are not aggregated between tables. In versions prior to V5.0.1 (excluding V4.4.2), theNONEsemantics also included all partitions staying together on the same log stream without dispersion (aggregated on a single node). This semantics was removed in later versions, and the specific distribution scope now depends on theSCOPEattribute.SHARDING = PARTITION: The data of each table in the table group is dispersed by primary partition. For a subpartitioned table, all subpartitions under a primary partition are aggregated together.- Partition requirement: All tables must have the same definition for their primary partitions. For subpartitioned tables, only the primary partition definition is verified. Therefore, primary partitioned tables and subpartitioned tables can coexist as long as they have the same primary partition definition.
- Partition alignment rule: Partitions with the same primary partition value are aggregated together, including: the primary partitions of a primary partitioned table and all subpartitions under the corresponding primary partition of a subpartitioned table.
SHARDING = ADAPTIVE: The data of each table in the table group is dispersed in an adaptive manner. That is, if a table in the table group is a primary partitioned table, it is dispersed by primary partition; if a table in the table group is a subpartitioned table, it is dispersed by the subpartitions under each primary partition.The partition requirements and partition alignment rules for tables in such a table group are as follows:
- Partition requirement: All tables in the table group must be either all primary partitioned tables or all subpartitioned tables. If they are primary 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 primary partitioned tables, partitions with the same primary partition value are aggregated together; if all tables in the table group are subpartitioned tables, partitions with the same primary partition value and subpartition value are aggregated together.
SUBPARTITION: Indicates that the tables joining the table group must be subpartitioned tables, and the primary and subpartitioning methods must be the same across different tables, including the partitioning key type, partitioning function, number of partitions, partition boundary values, etc. It also includes the following characteristics:Partition dispersion method: Subpartitions under a primary partition are dispersed.
Partition alignment method:
- Subpartition alignment across primary partitions: Subpartitions with the same partitioning key value under different primary partitions are bound to the same log stream.
- Global index alignment: Specifically, the subpartitions of a primary table and the primary partitions of a global index table are implicitly bound to the same log stream using the same partitioning key value, and this binding only occurs when the global index's partitioning method is identical to the primary table's subpartitioning method.
Note
For V5.x versions, support for the
SHARDING = 'SUBPARTITION'attribute of table groups starts from V5.0.1.
SCOPE Attribute of Table Groups
For V5.x versions, starting from V5.0.1, OceanBase Database introduces the SCOPE attribute for table groups, which defines the distribution scope of the Partition Groups formed after being aggregated by SHARDING within the cluster.
The SCOPE attribute has the following three possible values:
SERVER: Indicates that the Leaders of all Partition Groups are aggregated on the same node. This value provides the strongest data locality but may affect cluster load balancing.ZONE: Indicates that the Leaders of all Partition Groups are distributed within the same Zone and are dispersed across nodes within that Zone. This value balances data locality and load balancing within the Zone.CLUSTER: Indicates that the Leaders of all Partition Groups are dispersed across nodes within the cluster. This value maximizes the cluster's load balancing capability but may increase cross-node access.
Usage Scenarios for SCOPE = ZONE
- Cross-zone latency sensitivity: The leaders of related partitions need to be aggregated to the same zone to reduce cross-zone access latency.
- Load balancing within a zone: Within the same zone, the leaders of different partitions need to be distributed across different servers to avoid excessive load on a single server.
- Global index consistency: Ensuring that the leader of the primary table and the global index resides in the same zone guarantees local data access.
SCOPE Attribute of a Table Group
For OceanBase Database V5.x, starting from V5.0.1, the SCOPE attribute is introduced for table groups. It defines the distribution scope of partition groups formed after aggregation by SHARDING within the cluster.
The SCOPE attribute has the following three possible values:
SERVER: Indicates that the leaders of all partition groups are aggregated on the same node. This value provides the strongest data locality but may affect cluster load balancing.ZONE: Indicates that the leaders of all partition groups are distributed within the same zone and are scattered across different nodes within the zone. This value balances data locality and load balancing within the zone.CLUSTER: Indicates that the leaders of all partition groups are scattered across different nodes in the cluster. This value maximizes the cluster's load balancing capability but may increase cross-node access.
Usage Scenarios of SCOPE = ZONE
- Cross-zone latency sensitivity: Aggregates the leaders of related partitions to the same zone to reduce cross-zone access latency.
- Load balancing within a zone: Within the same zone, distributes the leaders of different partitions to different servers to avoid excessive load on a single server.
- Global index consistency: Ensures the leaders of primary tables and global indexes are in the same zone, guaranteeing data access locality.
