You can specify a point in time to trigger daily major compactions.
Prerequisites
Before a major compaction is triggered, make sure that global major compaction is enabled. Global major compaction is controlled by the cluster-level parameter enable_major_freeze. The default value is True, which specifies to enable global major compaction.
If global major compaction is disabled for the current cluster, perform the following steps to enable this feature:
Log in to the
systenant of the cluster as therootuser.Verify that global major compaction is enabled.
obclient> SHOW PARAMETERS LIKE 'enable_major_freeze';If global major compaction is not enabled, execute the following statement to enable the feature:
obclient> ALTER SYSTEM SET enable_major_freeze='True';For more information about the
enable_major_freezeparameter, see enable_major_freeze.
Conditions for triggering a scheduled major compaction
When the system time on a day reaches the specified point in time, a major compaction is automatically triggered. You can set the major_freeze_duty_time parameter to specify the point in time that triggers daily major compactions or modify the point in time in the OceanBase Cloud Platform (OCP) console. By default, a major compaction is triggered at 02:00 on each day.
For more information about the major_freeze_duty_time parameter and other major compaction parameters, see Modify major compaction settings.
Use an SQL statement to specify the point in time at which daily major compactions are triggered
Log in to the
systenant of the cluster as therootuser.Modify the point in time at which daily major compactions are triggered.
Modify the point in time at which the daily major compaction of the current tenant is triggered
obclient> ALTER SYSTEM SET major_freeze_duty_time='01:00';Modify the point in time at which daily major compactions of all user tenants are triggered
If a large number of tenants exist in the system, the CPU utilization may surge at the point in time when daily major compactions of all user tenants are triggered. To address this issue, we recommend that you set different points in time at which daily major compactions are triggered for different user tenants.
obclient> ALTER SYSTEM SET major_freeze_duty_time='01:00' TENANT = all_user;Alternatively, you can execute the following statement:
obclient> ALTER SYSTEM SET major_freeze_duty_time='01:00' TENANT = all;Note
In OceanBase Database V4.2.1 and later,
TENANT = all_userandTENANT = allexpress the same semantics. If you want an operation to take effect on all user tenants, we recommend that you useTENANT = all_user.TENANT = allwill be deprecated.Modify the point in time at which daily major compactions are triggered for all meta tenants
If a large number of tenants exist in the system, the CPU utilization may surge at the point in time when daily major compactions of all meta tenants are triggered. To address this issue, we recommend that you set different points in time at which daily major compactions are triggered for different meta tenants.
obclient> ALTER SYSTEM SET major_freeze_duty_time='01:00' TENANT = all_meta;Modify the point in time at which the daily major compaction is triggered for a specified tenant
You can specify only one tenant in the following statement. To modify the time for multiple tenants, execute the statement separately for each tenant.
obclient> ALTER SYSTEM SET major_freeze_duty_time='01:00' TENANT = tenant1;