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 your 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 the related issues without affecting your business. The system will schedule major compactions on a partition basis during the period when this feature is enabled.
This feature can help solve 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.
Trigger rules
The system automatically schedules an adaptive major compaction for a partition and its follower replicas when the leader of the partition meets the specified conditions. The trigger rules are as follows:
The system analyzes the statistics of a partition over a period to determine the number of queries and minor compactions and the proportion of inserted rows in incremental data of the partition. 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 to determine the number of minor compactions and the proportion of updated and deleted rows in incremental data of the partition. 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 yes, an adaptive major compaction is triggered for the partition.
The system determines whether a query for a partition is a slow query by comparing the amount of data scanned in the query with the amount of effective data. If a slow query is detected for the partition, 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, which is provided for developers to use in 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 tenant-level hidden configuration item _enable_adaptive_compaction controls this feature, and the default value is True.
You can set the tenant-level hidden configuration item _enable_adaptive_compaction to False to disable the adaptive major compaction feature. Once disabled, the system will no longer schedule 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;