A partition group (PG) belongs to the top layer in the storage structure of OceanBase Database. PG is often used as an abbreviation for partition group. PG is a concept abstracted to achieve extreme performance. In a user transaction, multiple different tables may be accessed. In the distributed architecture of OceanBase Database, these tables are often stored on different servers, which results in distributed transactions. Distributed transactions rely on two-phase commits, which increases overheads. If these tables are stored on a single server, the transaction can be optimized in one phase to achieve higher performance. However, in most cases, you cannot determine table locations. In many Internet applications, tables are partitioned by user ID based on the same partitioning rule. OceanBase Database provides a syntax for you to group tables into a table group. Partitions within the table group constitute a partition group. OceanBase Database ensures that multiple partitions in a partition group are bound to each other. In this way, operations on a partition group are optimized into a standalone transaction to achieve higher performance.
A partition group may contain multiple partitions. Note that the partitioning keys and partitioning rules of these partitions must be identical. A partition group is the minimum unit for leader election and migration/replication in OceanBase Database. A partition is a partition of a table, and its definition is basically the same as in Oracle and MySQL. Tables can be partitioned in many ways, such as hash partitioning, range partitioning, list partitioning, and even subpartitioning. However, the storage layer does not distinguish between these partitioning rules and treats all partitions the same.
OceanBase Database supports creating local indexes for user tables. A local index is bound to and stored in the same partition as the primary table. The primary table and each index are stored in their own Table Store. Each Table Store contains multiple SSTables and MemTables. MemTables are stored in memory and hold dynamic data for read and write operations. SSTables are stored on disk and hold static data in read-only form.
