OceanBase Database allows you to set table groups to configure data distribution.
What is a table group?
A table group is a logical concept that describes a collection of tables. All tables in a table group must have the same locality, primary zone, and partitioning method. The locality specifies the types, number, and locations of replicas. The primary zone specifies the location of the leader and zone priorities. All tables in a table group have the same number of partitions.
What is a partition group?
Assume that table group TG0 contains k tables: T1, T2, ..., and Tk. Assume that each table has m partitions:
Partitions of
T1: P11, P12, P13, P14, ..., and P1mPartitions of
T2: P21, P22, P23, P24, ..., and P2mPartitions of
T3: P31, P32, P33, P34, ..., and P3m...
Partitions of
Tk: Pk1, Pk2, Pk3, Pk4, ..., and Pkm
A collection of partitions with the same offset is called a partition group. In this case, TG0 contains m partition groups: pg1, pg2, pg3, ..., and pgm. Each partition group contains k partitions:
Partitions in
pg1: P11, P21, P31, P41, ..., and Pk1Partitions in
pg2: P12, P22, P32, P42, ..., and Pk2Partitions in
pg3: P13, P23, P33, P43, ..., and Pk3...
Partitions in
pgm: P1m, P2m, P3m, P4m, ..., and Pkm
Usage of partition groups
In the preceding example, table group TG0 contains m partition groups: pg1, pg2, pg3, ..., and pgm. In OceanBase Database, it is assumed that multiple partitions in a partition group are likely to be modified in one transaction. RootService schedules partitions in a partition group to the same OBServer if possible so that modifications of one transaction occur on one OBServer. This reduces the probability of distributed transactions. Example:
Partitions P11, P21, P31, P41, ..., and Pk1 in
pg1are scheduled to one OBServer if possible.Partitions P12, P22, P32, P42, ..., and Pk2 in
pg2are scheduled to one OBServer if possible.Partitions P13, P23, P33, P43, ..., and Pk3 in
pg3are scheduled to one OBServer if possible....
Partitions P1m, P2m, P3m, P4m, ..., and Pkm in
pgmare scheduled to one OBServer if possible.