This topic describes how to perform 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 SSTables) and dynamic incremental data (stored in MemTables). SSTables are read-only, stored on disk, and remain unchanged once generated. MemTables support both read and write operations and are stored in memory. DML operations such as INSERT, UPDATE, and DELETE are first written to a MemTable. When a MemTable reaches a certain size, it is flushed to disk as an SSTable. For more information, see Storage architecture overview.
When the size of a MemTable exceeds a certain threshold, the data in the MemTable is flushed to an SSTable to free up memory. This process is called a minor compaction. For more information, see Minor compaction.
A minor compaction generates a new SSTable. When the number of minor compactions exceeds a certain threshold, or during daily off-peak business hours, the system merges the baseline SSTable with the incremental SSTables generated by subsequent minor compactions into a single SSTable. This process is called a major compaction. For more information, see Major compaction.
Scenarios
Scheduled major compaction: No manual scheduling is required. Based on your actual business workload, you can configure the system to automatically initiate a major compaction during off-peak hours.
Manual major compaction: You can initiate a major compaction at any time based on your actual business needs.
Note
A major compaction may degrade business performance. To ensure stable business operations, we recommend that you perform this operation during off-peak hours.
Prerequisites
Before initiating a major compaction, check whether the instance status is Running. Only instances in the Running state can undergo a major compaction.
Initiate a cluster-wide major compaction
Log in to the OceanBase Cloud console.
In the left-side navigation pane, click Instances.
In the instance list, find the target instance, click its name, and go to the instance workspace.
On the instance workspace page, click Actions and select Initiate Major Compaction.

In the dialog box that appears, click Compact Data again to initiate the major compaction for the target instance.

Note
- If any backup tasks are in progress, the major compaction will cause delays.
- A major compaction may impact database performance. It is recommended to perform this operation during off-peak hours.
After initiating a major compaction, if temporary business needs arise, you can pause or resume the compaction task from the tenant console.
