This topic describes the automatic partition splitting strategy of OBKV-HBase and how to use this feature in OceanBase AI Database. The automatic partition splitting feature automatically splits partitions based on the configured partition threshold, so that you can fully leverage the distributed capabilities of OceanBase AI Database with minimal partition planning effort.
Limitations
Currently, only automatic RANGE/RANGE COLUMNS partitioning is supported. This inherits one of the advantages of RANGE partitioning, making it suitable for range scan scenarios. Additionally, it has the capability to automatically split based on data volume, distributing data evenly, which is not available in regular RANGE partitioning.
Usage instructions and examples
Table identification markers
The OBKV-HBase partition splitting feature relies on the kv_attributes parameter to identify whether a specified table is an OBKV-HBase table. Therefore, you are strongly advised to configure kv_attributes when you create a table, so that the system can accurately identify the OBKV table type. For more information, see OBKV-HBase data model.
Quick start
To use the automatic partitioning feature, first pay attention to two parameters:
Parameter |
Description |
|---|---|
enable_auto_split |
Controls whether to enable automatic partitioning for the tenant. Default value: FALSE. |
auto_split_tablet_size |
The threshold for triggering a split after automatic partitioning is enabled for a tenant. Default value: 128MB. |
To enable automatic partitioning, use the following command:
ALTER SYSTEM SET enable_auto_split = true TENANT='tenant';
If automatic partitioning is enabled for a table during table creation or modification but no partition threshold is specified, the default value 128MB of the auto_split_tablet_size parameter is used as the automatic partitioning threshold for the table. Partition splitting is triggered when the disk usage of a partition exceeds the configured size. To manually set the automatic partitioning threshold, run the following command:
-- Set the auto-partition threshold to 256 MB.
ALTER SYSTEM SET auto_split_tablet_size = '256MB';
Advanced usage
You can quickly enable the automatic partition splitting feature of OBKV-HBase by using parameters, but the feature then applies to all services in the tenant. If you need more fine-grained control over automatic partition splitting for specific business tables, see the following scenarios:
- A new business that will use OBKV-HBase.
In this scenario, enable automatic partitioning for the new table of the business. Here is an example:
-- Create a non-partitioned table with automatic partitioning (using the default 128 MB as the split threshold).
CREATE TABLE auto_pt2 (c1 int, c2 int, primary key(c1))
PARTITION BY RANGE ();
-- Create a non-partitioned table with automatic partitioning (split threshold: 1024 MB, user-configurable).
CREATE TABLE auto_pt3 (c1 int, c2 int, primary key(c1))
PARTITION BY RANGE () SIZE('1024MB');
- An existing OBKV-HBase cluster of an earlier version that needs to be upgraded to a version that supports automatic partitioning.
In this scenario, enable automatic partitioning for existing tables by modifying their partitioning attributes. Here is an example:
-- Business table t1 is to be upgraded from an earlier version to a newer version. Automatic partitioning was not enabled when the table was created in the earlier version.
CREATE TABLE t1 (C1 INT, C2 INT, PRIMARY KEY(C1))
PARTITION BY RANGE(C1) SIZE('10GB')
(PARTITION p0 VALUES LESS THAN(100),
PARTITION p1 VALUES LESS THAN(200),
PARTITION p_max VALUES LESS THAN (MAXVALUE)
);
-- Modify the partitioning attribute of table t1 to enable automatic partitioning in the new version.
ALTER TABLE t1 PARTITION BY RANGE() SIZE('128MB');
- A business for which manual partitioning is recommended.
The current automatic partition splitting feature only supports even data distribution. As a result, some partitions may contain less data while others are under high load. In this case, you can use manual partitioning to set split thresholds and evenly distribute the data of high-load partitions across different partitions. Here is an example:
-- Assume you have a table named t1 with automatic partitioning disabled.
CREATE TABLE t1 (c1 int, c2 int, c3 int, primary key(c1))
PARTITION BY RANGE(c1)
(PARTITION p0 VALUES LESS THAN(50),
PARTITION p1 VALUES LESS THAN(100),
PARTITION p_max VALUES LESS THAN (MAXVALUE)
);
-- Assume that the 0-50 partition is under high load. In this case, you can split it into multiple partitions.
ALTER TABLE t1 REORGANIZE PARTITION p0 INTO (
PARTITION p0_1 VALUES LESS THAN (30),
PARTITION p0_2 VALUES LESS THAN (50)
);