A table group is an attribute of a table that affects the distribution of partitions of multiple tables on OBServers.
Different partitions in a table can be distributed on different nodes. When you join two tables to run a query, OceanBase requests data across nodes. The execution time depends on the request latency between the nodes. To optimize SQL queries, we recommend that you place tables that are related in business into the same table group. OceanBase places all table partitions that share the same partition number in the same table group into a partition group. OceanBase allocates the partitions in the same partition group to the same node if possible to avoid cross-node requests.
When you create a table group, you must first plan the use of the table group. For non-partitioned tables, you do not need to partition the table group. For partitioned tables, you need to specify the partitioning strategy for the table group. The partitioning strategy must be the same as that of the partitioned tables.
Example: Creating a table group
obclient> create tablegroup tpcc_group partition by hash partitions 6;
Query OK, 0 rows affected (0.03 sec)