Starting from OceanBase Database V5.0.1, random distribution tables were introduced based on the random partition strategy. A random distribution table leverages the random partition mechanism to automatically scatter and route data to different nodes in the cluster during writes, thereby achieving cross-node load balancing and efficient scaling.
In terms of underlying implementation, a random distribution table is essentially a RANGE partitioned table that uses an internally generated INT64 column as the partitioning key. During writes, the system routes data to different active partitions based on a sequence number called Tablet Seq, ensuring data is evenly distributed across multiple OBServer nodes. This prevents hotspots and improves write performance and resource utilization.
Features
- No need to specify a partitioning key (for tables without a primary key): The system automatically generates a hidden auto-increment primary key column (
__pk_increment) for partition routing. - Data is randomly and evenly distributed: During
INSERToperations, the system randomly selects a target partition from the active partitions. - Automatic partition management: When sequence values are exhausted, new partitions are automatically created, and the table dynamically scales based on the number of available log streams (
LS) for the tenant. - Transparent to users: In compatibility mode,
SHOW CREATE TABLEoutputs standard MySQL DDL, hiding partition details.
Application scenarios
- Append-only write scenarios such as logs or transactional tables where query partition routing is not required.
- Large-scale data import scenarios that require horizontal scaling to increase write throughput.
- Scenarios where partition pruning based on specific columns is not needed.
Limitations
- Tables with local unique indexes are not supported.
- Partition operations on random distribution tables are not supported:
DROP/SPLIT/EXCHANGE/TRUNCATE PARTITION. - Converting a non-random distribution table to a random distribution table is not supported.
- Random distribution tables cannot be added to table groups.
DML operations on random distribution tables
INSERToperations on random distribution tables are identical to those on regular tables; the system automatically handles partition routing.SELECT/UPDATE/DELETEoperations on random distribution tables are identical to those on regular tables.REPLACEoperations on random distribution tables require the table to have a unique key constraint (must be aGLOBALunique index).
Maintenance considerations
- Slow DDL operations such as
DROP DATABASE: These may block foreground writes because new partitions cannot be added promptly when active partitions are full. - Full direct load (
APPEND): The partitioning scheme is based on the schema at the start of the statement and cannot detect newly added partitions during the import process. Insufficient partitions will cause a direct error.
