Purpose
This statement is used by user tenants to initiate their own minor compactions or minor garbage collections. Manual compaction supports tenant-level, table-level, and partition-level operations. Minor garbage collection supports tenant-level and partition-level operations.
Syntax
ALTER SYSTEM merge_action;
merge_action:
MAJOR FREEZE [TABLE_ID = table_id | TABLET_ID = tablet_id]
| MINOR FREEZE [TABLET_ID = tablet_id]
| {SUSPEND | RESUME} MERGE
| CLEAR MERGE ERROR
Parameters
Parameters |
Description |
|---|---|
| MAJOR FREEZE | Initiate a major compaction.
NoteA user tenant can only initiate major compactions for itself. |
| MINOR FREEZE | Initiates a minor compaction.
NoteA user tenant can only initiate its own minor compaction. |
| {SUSPEND \ | RESUME} MERGE | Pause or resume a major compaction.
NoteA user tenant can only pause or resume its own major compactions. |
| CLEAR MERGE ERROR | Clean up the error markers from major compactions.
NoteA user tenant can only clean up its own major compaction error markers. |
| TABLE_ID | Specify table major compaction. |
| TABLET_ID | Specify the partition for minor compaction or major compaction. |
Examples
Examples related to storage layer compaction
The user tenant initiates its own major compaction.
obclient> ALTER SYSTEM MAJOR FREEZE; Query OK, 0 rows affectedUser tenants initiate their own table-level major compactions.
Query the
table_idof the table to be merged, tbl2.obclient(root@mysql001)[oceanbase]> SELECT database_name, table_id, table_name FROM oceanbase.DBA_OB_TABLE_LOCATIONS WHERE table_name = 'tbl2';The query result is as follows:
+---------------+----------+------------+ | database_name | table_id | table_name | +---------------+----------+------------+ | test | 500002 | tbl2 | +---------------+----------+------------+ 1 row in setRun the following command to initiate a table-level major compaction.
obclient(root@mysql001)[oceanbase]> ALTER SYSTEM MAJOR FREEZE TABLE_ID = 500002;
User tenants initiate partition-level major compactions.
Query the
tablet_idcorresponding to the table partition to be merged.obclient(root@mysql001)[oceanbase]> SELECT database_name, table_id, table_name, tablet_id, partition_name, subpartition_name FROM oceanbase.DBA_OB_TABLE_LOCATIONS WHERE table_name = 'tbl2';The query result is as follows:
+---------------+----------+------------+-----------+----------------+-------------------+ | database_name | table_id | table_name | tablet_id | partition_name | subpartition_name | +---------------+----------+------------+-----------+----------------+-------------------+ | test | 500010 | tbl2 | 200007 | p0 | NULL | | test | 500010 | tbl2 | 200008 | p1 | NULL | | test | 500010 | tbl2 | 200009 | p2 | NULL | +---------------+----------+------------+-----------+----------------+-------------------+ 3 rows in setRun the following command to initiate a partition-level major compaction.
obclient(root@mysql001)[oceanbase]> ALTER SYSTEM MAJOR FREEZE TABLET_ID = 200007;
Example of stopping or resuming a major compaction
Stop the major compaction of the user tenant itself.
obclient> ALTER SYSTEM SUSPEND MERGE; Query OK, 0 rows affectedRestore the major compaction of the user tenant itself.
obclient> ALTER SYSTEM RESUME MERGE; Query OK, 0 rows affected
Example of cleaning up major compaction error flags
Clears the error flags for user tenant's own major compactions.
obclient> ALTER SYSTEM CLEAR MERGE ERROR; Query OK, 0 rows affected
Example of storage layer minor compaction
User tenants initiate their own minor compactions.
obclient> ALTER SYSTEM MINOR FREEZE; Query OK, 0 rows affectedUser tenants initiate partition-level minor compactions.
obclient> ALTER SYSTEM MINOR FREEZE TABLET_ID = 5; Query OK, 0 rows affected