Adaptive major compaction is supported in OceanBase Database starting from V4.1.0. After you enable adaptive major compaction, the system will collect and statistics on your queries and writes in real time. Based on this information, the system can identify potential query performance issues and schedule major compactions adaptively to resolve these issues without affecting your business. During the period when adaptive major compaction is enabled, the system collects statistics and schedules major compactions on a partition basis.
Adaptive major compaction 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 followers when the leader of the partition meets the specified conditions. The triggering 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 insert 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 update and delete 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 so, an adaptive major compaction is triggered for the partition.
The system queries the amount of data scanned and the proportion of effective data in the query to determine whether the query is a slow query. If a slow query is detected in the partition, an adaptive major compaction is triggered for the partition.
Considerations
Adaptive major compaction can effectively reduce the occurrence of slow queries. If your business has high requirements for query performance and operates in an scenario supported by adaptive major compaction, 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 adaptive major compaction, contact the technical support team for assistance.
How to enable or disable adaptive major compaction
The _enable_adaptive_compaction tenant-level hidden configuration item controls this feature. The default value is True, which means that the feature is enabled.
You can set the _enable_adaptive_compaction tenant-level hidden configuration item to False to disable adaptive major compaction. After it is disabled, the system will no longer schedule major compactions.
Log in to the
systenant of the cluster as therootuser.Query the value of the
_enable_adaptive_compactiontenant-level hidden configuration item.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
_enable_adaptive_compactiontenant-level hidden configuration item to disable or enable adaptive major compaction.obclient [oceanbase]> ALTER SYSTEM SET _enable_adaptive_compaction = False TENANT = tenant_name;obclient [oceanbase]> ALTER SYSTEM SET _enable_adaptive_compaction = True TENANT = tenant_name;