Starting from OceanBase Database V4.1.0, the adaptive major compaction feature is supported. When this feature is enabled, the system will collect and statistics on user queries and writes in real time, identify scenarios that may lead to slow queries based on the information, and schedule major compactions adaptively to resolve related issues without affecting user perception. During the period when the adaptive major compaction feature is enabled, the system statistics and schedules major compactions on a partition basis.
This feature can help address the following issues:
Avoiding the occurrence of some issues related to buffer tables.
Optimizing query performance in derivative scenarios.
Identifying and avoiding some slow query scenarios.
Triggering rules
The system automatically schedules an adaptive major compaction for a partition and its follower replicas when the partition leader meets the specified conditions. The triggering rules are as follows:
The system analyzes the statistics of a partition over a period of time to determine the number of queries and minor compactions in the partition and the proportion of insert rows in incremental data. If the partition is in a derivative scenario, an adaptive major compaction is triggered for the partition.
The system analyzes the statistics of a partition over a period of time to determine the number of minor compactions in the partition and the proportion of update and delete rows in incremental data. If the partition is in a derivative scenario, an adaptive major compaction is triggered for the partition.
The system counts the total number of rows in incremental data of a partition to determine whether the partition is in a continuous write scenario. If the partition is in a continuous write scenario, an adaptive major compaction is triggered for the partition.
The system queries the data scan volume and the ratio of effective data to determine whether a query on the partition is a slow query. If a slow query is detected, an adaptive major compaction is triggered for the partition.
Considerations
The adaptive major compaction feature can effectively reduce the occurrence of slow queries. If your business has high requirements for query performance and operates in an scenario supported by the adaptive major compaction feature, we recommend that you do not disable this feature.
In OceanBase Database, a configuration item whose name starts with "_" is a hidden configuration item for developers to use during troubleshooting or emergency O&M. If you want to disable the adaptive major compaction feature, contact the technical support team for assistance.
How to enable or disable the adaptive major compaction feature
The adaptive major compaction feature is controlled by the tenant-level hidden configuration item _enable_adaptive_compaction, which is enabled by default.
As the execution of adaptive major compactions occupies some system resources, you can disable the adaptive major compaction feature by setting the tenant-level hidden configuration item _enable_adaptive_compaction to False. After it is disabled, the system will no longer schedule adaptive major compactions.
Log in to the
systenant of the cluster as therootuser.Query the value of the tenant-level hidden configuration item
_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 setModify the value of the tenant-level hidden configuration item
_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;