The storage engine of OceanBase Database uses the LSM-Tree architecture. In this architecture, data is divided into two parts: MemTables and SSTables. When the memory occupied by the MemTable reaches a specified threshold, data in the MemTable is flushed to the disk to free up the memory space. This process is called a minor compaction . Before a minor compaction, a minor freeze is implemented to ensure that no new data is written to the MemTable. The minor compaction prevents new data from being written to the current active MemTable and generates a new active MemTable.
When OceanBase Database performs minor compaction on the frozen MemTable, it scans rows in the MemTable and then stores them in the SSTable. If a row of data is repeatedly modified by multiple different transactions, multiple data rows of different versions may be stored in the SSTable.
When the data size of a MemTable meets the specified threshold, OceanBase Database performs a minor compaction. Each partition can independently freeze its active MemTable and store the data to the disk. The SSTable that stores the frozen data can be compacted with only incremental data of the same major version, instead of the global static data. This design accelerates the minor compaction speed because the incremental data is much smaller than the global static data.
A minor compaction can be automatically or manually triggered.