A major compaction compacts all dynamic and static data, which is a time-consuming operation. Based on best practices, a major compaction is performed only once within a day and during off-peak hours. This topic provides the instructions on performing major compactions.
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.
You can initiate major compactions in OceanBase Cloud using the following two methods:
Scheduled trigger: 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 trigger: You can initiate the compaction based on actual business requirements at any time.
Note
Major compactions 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.
Prerequisites
Before initiating a major compaction, ensure that the tenant status under the cluster instance is "Running". Major compactions can only be initiated when the tenant status is "Running".
Procedure
Log in to the OceanBase Cloud console. In the left-side navigation pane, click Instances.
Click the name of the target cluster instance to navigate to the Overview page of the instance.
On the overview page, select Operation > Initiate a merge under Data merging.
Note
- For cluster instances of V4.x, OceanBase Cloud supports initiating major compactions at both the cluster instance level and tenant level.
- You can initiate major compactions for all tenants under the target cluster instance on the **Overview** page of the instance. You can also initiate major compactions for the target tenant on the **Overview** page of the tenant.

Click Merge data in the pop-up dialog to confirm the operation.
Note
- If there are ongoing backup tasks, major compactions will cause delays in their execution.
- Major compactions 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 cluster instance simultaneously.