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.
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
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.
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.
After a major compaction is initiated, you can suspend or resume the major compaction on the Overview page of the instance if needed.