This topic describes how to initiate a major compaction.
Background information
The storage engine of OceanBase Database is based on the LSM-tree architecture. Data is divided into static baseline data (stored in an SSTable) and dynamic incremental data (stored in a MemTable). An SSTable is read-only and stored on the disk. Once an SSTable is generated, it will not be modified. A MemTable can be read and written and is stored in the memory. Data related to DML operations, such as inserting, updating, and deleting, is firstly written into the MemTable. After the size of the MemTable reaches a specific threshold, its data is compacted with the baseline data and stored in the SSTable on the disk. For more information, refer to Storage architecture overview.
When the memory occupied by the MemTable exceeds a specific threshold, data in the MemTable is flushed to the SSTable to release the memory space. This process is called a minor compaction. For more information, refer to Minor compaction.
A minor compaction generates a new SSTable. When the number of minor compactions exceeds a specific threshold, or during off-peak hours, the system merges the baseline SSTable with the incremental SSTables generated by minor compactions into one SSTable. This process is called a major compaction. For more information, refer to Major compaction.
Scenarios
Automatic major compaction: No manual scheduling is required. Depending on the actual business workload, you can opt to let the system automatically perform the compaction during off-peak hours.
Manual major compaction: You can initiate the compaction based on actual business requirements at any time.
Note
A major compaction may lead to a decline in business performance. To ensure the stability of your business operations, it is recommended to perform this operation during off-peak hours.
Notes
For instances of V4.x, OceanBase Cloud supports initiating a major compaction at both the instance level and the tenant level. You can initiate a major compaction for all tenants under the target instance on the Overview page of the instance, or initiate a major compaction for the target tenant on the Overview page of the tenant.
Prerequisites
Before initiating a major compaction, ensure that the tenant status under the instance is "Running". A major compaction can only be initiated when the tenant status is "Running".
Initiate a major compaction at the instance level
Log in to the OceanBase Cloud console.
In the left-side navigation pane, click Instances.
Click the name of the target instance to navigate to the Overview page of the instance.
On the overview page, select Actions > Initiate Compaction under Major Compaction.
Note
- For instances of V4.x, OceanBase Cloud supports initiating a major compaction at both the instance level and the tenant level.
- You can initiate a major compaction for all tenants under the target instance on the **Overview** page of the instance, or initiate a major compaction for the target tenant on the **Overview** page of the tenant.
Click Compact Data in the pop-up dialog to confirm the operation.
Note
- If there are ongoing backup tasks, a major compaction will cause delays in their execution.
- A major compaction may have a certain impact on database performance. It is recommended to avoid performing this operation during peak hours.
- This operation will compact data for all tenants under this instance simultaneously.
After a major compaction is initiated, you can suspend or resume the major compaction on the Overview page of the instance if needed.
Initiate a major compaction at the tenant level
Log in to the OceanBase Cloud console.
In the left-side navigation pane, click Instances.
Click the name of the target instance to navigate to the Overview page of the instance.
In the left-side navigation pane, click Tenants.
Click the name of the target tenant to navigate to the Overview page of the tenant.
On the overview page, select Actions > Initiate Compaction under Major Compaction.
In the dialog box that appears, click Compact Data to initiate a major compaction for the target tenant.
After a major compaction is initiated, you can suspend or resume the major compaction as needed.
To suspend an ongoing major compaction, click Suspend, and confirm the operation in the dialog box that appears.
To resume a suspended major compaction, click Resume, and confirm the operation in the dialog box that appears.