OceanBase Database supports the adaptive major compaction feature since V4.2.0. After this feature is enabled, the system collects statistics on user queries and writes in real time, identifies possible slow query scenarios based on the collected information, and adaptively schedules major compaction tasks to resolve the issue of slow queries in related scenarios, without interrupting user operations. The aforementioned statistics collection and scheduling of major compaction tasks are performed at the partition level.
You can enable adaptive major compaction for the following purposes:
Avoid some buffer table issues.
Improve the query performance in data import and export scenarios.
Identify and avoid some slow query scenarios.
Trigger rules
When the partition leader meets specified conditions, the system adaptively schedules a major compaction task for this partition and the followers. The rules for triggering an adaptive major compaction are as follows:
The system analyzes the partition statistics collected within a specific period to obtain the number of queries and that of minor compactions for the partition and the proportion of inserted rows in incremental data, to determine whether the current scenario is a data import/export scenario. If yes, the system triggers an adaptive major compaction for the partition.
The system analyzes the partition statistics collected within a specific period to obtain the number of minor compactions for the partition and the proportion of updated and deleted rows in incremental data, to determine whether the current scenario is a data import/export scenario. If yes, the system triggers an adaptive major compaction for the partition.
The system calculates the total number of rows in incremental data of the partition to determine whether the current scenario is a continuous write scenario. If yes, the system triggers an adaptive major compaction for the partition.
The system checks the ratio of the amount of data scanned in queries to the amount of valid data to determine whether queries to this partition are slow queries. If yes, the system triggers an adaptive major compaction for the partition.
Considerations
Adaptive major compaction can effectively reduce slow queries. If your business requires high query performance and has scenarios supported by adaptive major compaction, we recommend that you do not disable this feature.
In OceanBase Database, parameters whose names start with an underscore (_) are hidden parameters. Hidden parameters are used by developers only for troubleshooting or emergency O&M. If you want to disable the adaptive major compaction feature, contact OceanBase Technical Support for help.
Enable or disable adaptive major compaction
The adaptive major compaction feature is controlled by the tenant-level hidden parameter _enable_adaptive_compaction, and is enabled by default.
With this feature enabled, the execution of scheduled tasks consumes some system resources. If you do not want to perform adaptive major compactions, you can change the value of _enable_adaptive_compaction to False to disable the feature. After the feature is disabled, the system no longer automatically schedules adaptive major compaction tasks for partitions.
Log on to the
systenant of the cluster as therootuser.Query the value of the tenant-level hidden parameter
_enable_adaptive_compaction.obclient [oceanbase]> SELECT * FROM oceanbase.GV$OB_PARAMETERS WHERE NAME LIKE '_enable_adaptive_compaction';The query result is as follows:
+----------------+----------+-------+--------+-----------+-----------------------------+-----------+-------+---------------------------------------------------------------------------------+---------+-------------------+---------------+-----------+ | SVR_IP | SVR_PORT | ZONE | SCOPE | TENANT_ID | NAME | DATA_TYPE | VALUE | INFO | SECTION | EDIT_LEVEL | DEFAULT_VALUE | ISDEFAULT | +----------------+----------+-------+--------+-----------+-----------------------------+-----------+-------+---------------------------------------------------------------------------------+---------+-------------------+---------------+-----------+ | 172.xx.xxx.xxx | 2882 | zone1 | TENANT | 1 | _enable_adaptive_compaction | NULL | True | specifies whether allow adaptive compaction schedule and information collection | TENANT | DYNAMIC_EFFECTIVE | True | YES | | 172.xx.xxx.xxx | 2882 | zone1 | TENANT | 1001 | _enable_adaptive_compaction | NULL | True | specifies whether allow adaptive compaction schedule and information collection | TENANT | DYNAMIC_EFFECTIVE | True | YES | | 172.xx.xxx.xxx | 2882 | zone1 | TENANT | 1002 | _enable_adaptive_compaction | NULL | True | specifies whether allow adaptive compaction schedule and information collection | TENANT | DYNAMIC_EFFECTIVE | True | YES | | 172.xx.xxx.xxx | 2882 | zone1 | TENANT | 1003 | _enable_adaptive_compaction | NULL | True | specifies whether allow adaptive compaction schedule and information collection | TENANT | DYNAMIC_EFFECTIVE | True | YES | | 172.xx.xxx.xxx | 2882 | zone1 | TENANT | 1004 | _enable_adaptive_compaction | NULL | True | specifies whether allow adaptive compaction schedule and information collection | TENANT | DYNAMIC_EFFECTIVE | True | YES | +----------------+----------+-------+--------+-----------+-----------------------------+-----------+-------+---------------------------------------------------------------------------------+---------+-------------------+---------------+-----------+ 5 rows in setChange the value of the tenant-level hidden parameter
_enable_adaptive_compactionto disable or enable the adaptive major compaction feature.obclient [oceanbase]> ALTER SYSTEM SET _enable_adaptive_compaction = False TENANT = tenant_name;obclient [oceanbase]> ALTER SYSTEM SET _enable_adaptive_compaction = True TENANT = tenant_name;