Purpose
This statement is used to initiate a major or minor compaction in a user tenant. Manual compaction supports tenant-level, table-level, and partition-level operations. Minor compaction 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
| Parameter | Description |
|---|---|
| MAJOR FREEZE | Initiates a major compaction.
NoteA user tenant can only initiate a major compaction for itself. |
| MINOR FREEZE | Initiates a minor compaction.
NoteA user tenant can only initiate a minor compaction for itself. |
| {SUSPEND | RESUME} MERGE | Suspends or resumes a major compaction.
NoteA user tenant can only suspend or resume a major compaction for itself. |
| CLEAR MERGE ERROR | Clears the error flag for a major compaction.
NoteA user tenant can only clear the error flag for a major compaction for itself. |
| TABLE_ID | Specifies a table for major compaction. |
| TABLET_ID | Specifies a partition for minor compaction or major compaction. |
Examples
Examples related to major compaction
Initiates a major compaction for the user tenant.
obclient> ALTER SYSTEM MAJOR FREEZE; Query OK, 0 rows affectedInitiates a table-level major compaction for the user tenant.
Query the
table_idof the table tbl2 to be compacted.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 setExecute the following command to initiate a table-level major compaction.
obclient(root@mysql001)[oceanbase]> ALTER SYSTEM MAJOR FREEZE TABLE_ID = 500002;
Initiates a partition-level major compaction for the user tenant.
Query the
tablet_idof the partition to be compacted.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 setExecute the following command to initiate a partition-level major compaction.
obclient(root@mysql001)[oceanbase]> ALTER SYSTEM MAJOR FREEZE TABLET_ID = 200007;
Examples of suspending or resuming a major compaction
Suspends a major compaction for the user tenant.
obclient> ALTER SYSTEM SUSPEND MERGE; Query OK, 0 rows affectedResumes a major compaction for the user tenant.
obclient> ALTER SYSTEM RESUME MERGE; Query OK, 0 rows affected
Examples of clearing the error flag for a major compaction
Clears the error flag for a major compaction for the user tenant.
obclient> ALTER SYSTEM CLEAR MERGE ERROR; Query OK, 0 rows affected
Examples related to minor compaction
Initiates a minor compaction for the user tenant.
obclient> ALTER SYSTEM MINOR FREEZE; Query OK, 0 rows affectedInitiates a partition-level minor compaction for the user tenant.
obclient> ALTER SYSTEM MINOR FREEZE TABLET_ID = 5; Query OK, 0 rows affected
