You can execute the ALTER SYSTEM MINOR FREEZE statement in the sys tenant or a user tenant to manually initiate a minor compaction at the tenant, zone, server, log stream, or partition level.
Trigger a minor compaction as the system tenant
The system tenant can initiate minor compactions at the tenant, zone, server, log stream, and tablet levels.
Log in to the
systenant of the cluster as therootuser.Select the appropriate minor compaction operation based on your business needs.
Initiate a tenant-level minor compaction
You can initiate a minor compaction for one or more tenants by using the following SQL syntax:
obclient> ALTER SYSTEM MINOR FREEZE TENANT [=] all_user | all | all_meta | tenant_name [, tenant_name ...];Example:
The system tenant triggers a minor compaction for itself.
obclient> ALTER SYSTEM MINOR FREEZE;The system tenant triggers a minor compaction for all user tenants.
obclient> ALTER SYSTEM MINOR FREEZE TENANT = all_user;or
obclient> ALTER SYSTEM MINOR FREEZE TENANT = all;Note
TENANT = all_userhas the same semantics asTENANT = all. When you need the operation to apply to all user tenants, we recommend that you useTENANT = all_user. The latterTENANT = allwill be deprecated in the future.The system tenant triggers a minor compaction for all Meta tenants.
obclient> ALTER SYSTEM MINOR FREEZE TENANT = all_meta;The system tenant triggers a minor compaction for a specified tenant.
obclient> ALTER SYSTEM MINOR FREEZE TENANT = tenant1;
Initiate a zone-level minor compaction
You can initiate a minor compaction for a specified zone. You can specify only one zone at a time. The SQL syntax is as follows:
obclient> ALTER SYSTEM MINOR FREEZE ZONE [=] zone_name;Example:
obclient> ALTER SYSTEM MINOR FREEZE ZONE = zone1;Initiate a minor compaction at the server level
You can perform a minor compaction on one or more specified OBServer nodes. The SQL statement is as follows.
obclient> ALTER SYSTEM MINOR FREEZE SERVER = ('ip:port' [, 'ip:port'...]);Example:
obclient> ALTER SYSTEM MINOR FREEZE SERVER = ('xx.xx.xx.xx:2882','xx.xx.xx.xx:2882');Initiate a minor compaction at the log stream level
You can perform a minor compaction on a specified log stream of a specified tenant. The SQL statement is as follows.
ALTER SYSTEM MINOR FREEZE TENANT [=] tenant_name LS [=] ls_id;Here,
tenant_nameis the name of the specified tenant;ls_idis the ID of the specified log stream. You can obtain the log stream ID of a tenant by querying theoceanbase.CDB_OB_TABLE_LOCATIONSview.Example:
obclient> ALTER SYSTEM MINOR FREEZE TENANT = t1 LS = 1001;After the statement is executed, the system performs a minor compaction on all tablets of the specified log stream of the specified tenant.
Initiate a minor compaction at the partition level
In OceanBase AI Database, partitions and tablets have a one-to-one correspondence.
You can perform a minor compaction on a specified tablet of a specified tenant. The SQL statement is as follows.
ALTER SYSTEM MINOR FREEZE TENANT [=] tenant_name TABLET_ID = tablet_id;Alternatively, you can perform a minor compaction on a specified tablet in a specified log stream of a specified tenant. The SQL statement is as follows.
ALTER SYSTEM MINOR FREEZE TENANT [=] tenant_name LS [=] ls_id TABLET_ID = tablet_id;Here,
tenant_nameis the name of the specified tenant;ls_idis the ID of the specified log stream;tablet_idis the ID of the specified tablet in the specified log stream. You can obtain the log stream ID and tablet ID of a tenant by querying theCDB_OB_TABLE_LOCATIONSview. For detailed information about the fields in theCDB_OB_TABLE_LOCATIONSview, see oceanbase.CDB_OB_TABLE_LOCATIONS.Example of performing a minor compaction on a specified tablet of a specified tenant:
obclient> ALTER SYSTEM MINOR FREEZE TENANT = tenant1 TABLET_ID = 200001;Example of performing a minor compaction on a specified tablet in a specified log stream of a specified tenant:
obclient> ALTER SYSTEM MINOR FREEZE TENANT = tenant1 LS = 1001 TABLET_ID = 200001;
Initiate a minor compaction in a user tenant
A user tenant can only initiate minor compactions at the tenant or partition level for itself.
Log in to the user tenant of the cluster as the tenant administrator.
Select an appropriate minor compaction operation based on your business requirements.
Minor compaction at the tenant level
obclient> ALTER SYSTEM MINOR FREEZE;Minor compaction at the partition level
In OceanBase AI Database, each partition corresponds one-to-one with a tablet.
You can initiate a minor compaction for a specified tablet within the current tenant using the following statement:
ALTER SYSTEM MINOR FREEZE TABLET_ID = tablet_id;Here,
tablet_idcan be obtained by querying theDBA_OB_TABLE_LOCATIONSview. For detailed descriptions of the fields in theDBA_OB_TABLE_LOCATIONSview, see DBA_OB_TABLE_LOCATIONS.Example:
obclient> ALTER SYSTEM MINOR FREEZE TABLET_ID = 200001;
What to do next
After initiating a minor compaction, you can view its progress. For more information, see View minor compaction information.