This topic describes the classification, status, and compression algorithm of major compactions.
Major compaction (Major Freeze) merges static and dynamic data. It may take a long time. When the incremental data produced by minor compactions accumulates to a certain extent, OceanBase Database performs a major freeze to merge the data to a major version. The difference between a major compaction and a minor compaction lies in that a major compaction merges a tenant's data with its static data in one snapshot. The resulting data is stored as a tenant-level snapshot.
Major compaction classification
Major compactions are classified as follows based on the amount of data being merged.
Full major compaction: OceanBase Database reads all static data and merges it with the dynamic data to generate static data. It is time-consuming and consumes a large amount of I/O resources and CPU resources.
Incremental major compaction: Only the modified macroblocks are merged. The unmodified macroblocks are reused.
Compared with full major compactions, incremental major compactions reduce the workload of major compactions. This is the default major compaction algorithm in OceanBase Database.
Progressive major compaction: In each major compaction, only part of the data is merged. After several major compactions, the entire data set is rewritten.
For more information about major compactions, see Major compaction.
For more information about how to modify major compaction configurations, see Modify a major compaction configuration.
Major compaction status
You can query the status column of the DBA_OB_ZONE_MAJOR_COMPACTION view to check the status of major compactions.
The status of a major compaction can be one of the following values:
IDLE: Indicates that no major compaction is being performed.COMPACTING: Indicates that the major compaction is being performed.VERIFYING: Indicates that the checksum of the compaction result is being verified.
Compression algorithm of major compaction
OceanBase Database does not periodically flush data to disks but performs a major compaction to centrally flush data to disks. Therefore, OceanBase Database can use a compression algorithm when writing data to disks to improve disk space utilization. For example, you can choose a compression algorithm with a high compression ratio that consumes more CPU resources or a general compression algorithm.
You can set the default_compress_func parameter to specify a compression algorithm. The default value is zstd_1.3.8. The parameter can also be set to none, lz4_1.0, snappy_1.0, or zstd_1.0.
Note
A higher compression ratio consumes more CPU resources but saves more disk space. For example, ZSTD compresses data to take up more space than LZ4. However, ZSTD consumes more CPU resources and the response time for I/O queries is greater.
You can also specify a compression algorithm for a table when you create the table.
For the syntax of specifying the compression algorithm when creating a table, see CREATE TABLE (MySQL mode) and CREATE TABLE (Oracle mode).
Major compaction triggering methods
OceanBase Database supports major compaction triggering through the following four methods.
