Updated on 2025-10-10 GMT+08:00

Automatic Cleanup

The automatic cleanup process in the system automatically runs the VACUUM and ANALYZE statements to reclaim the record space marked as deleted and update statistics in the table.

autovacuum_compaction_rows_limit

Parameter description: Specifies the small CU threshold. A CU whose number of live tuples is less than the value of this parameter is considered as a small CU. This parameter has been discarded in 9.1.1.100 and later versions.

Type: USERSET

Value range: an integer ranging from –1 to 5000

Default value: 2500

  • If the version is earlier than 9.1.0.100, value –1 indicates that the 0 CU switch is disabled. Do not set this parameter in the current version. Otherwise, duplicate primary key data may occur.
  • In version 9.1.0.100, the default value of this parameter is 0.
  • In 9.1.0.200 and later versions, the default value of this parameter is 2500.

autoanalyze_mode

Parameter description: Specifies the autoanalyze mode. This parameter is supported by clusters of version 8.2.0 or later.

Type: USERSET

Value range: enumerated values

  • normal indicates common autoanalyze.
  • light indicates lightweight autoanalyze.

Default value:

  • If the current cluster is upgraded from an earlier version to 8.2.0, the default value is normal to ensure forward compatibility.
  • If the cluster version 8.2.0 is newly installed, the default value is light.

analyze_stats_mode

Parameter description: Specifies the mode for ANALYZE to calculate statistics.

Type: USERSET

Value range: enumerated values

  • memory indicates that the memory is forcibly used to calculate statistics. Multi-column statistics are not calculated.
  • sample_table indicates that temporary sampling tables are forcibly used to calculate statistics. Temporary tables do not support this mode.
  • dynamic indicates that the statistics calculation mode is determined based on the size of maintenance_work_mem. If maintenance_work_mem can store samples, the memory mode is used. Otherwise, the temporary sampling table mode is used.

Default value:

  • If the current cluster is upgraded from an earlier version to 8.2.0.100, the default value is memory to ensure forward compatibility.
  • If the cluster version 8.2.0.100 is newly installed, the default value is dynamic.

analyze_sample_mode

Parameter description: Specifies the sampling model used by ANALYZE.

Type: USERSET

Value range: an integer ranging from 0 to 2

  • 0 indicates the default reservoir sampling.
  • 1 indicates the optimized reservoir sampling.
  • 2 indicates range sampling.

Default value: 0

autovacuum_max_workers

Parameter description: Specifies the maximum number of threads that can run at the same time to automatically clear row-store tables.

Type: SIGHUP

Value range: an integer ranging from 0 to 128. 0 indicates that autovacuum for clearing row-store tables is disabled.

Default value: 2

This parameter works with autovacuum. The rules for clearing system catalogs and user row-store tables are as follows:

  • When autovacuum_max_workers is set to 0, autovacuum is disabled and no row-store tables are cleared.
  • When autovacuum_max_workers is set to a value greater than 0 and autovacuum is set to off, only system tables are cleared.
  • When autovacuum_max_workers is set to a value greater than 0 and autovacuum is set to on, all row-store tables will be cleared.

autovacuum_max_workers_hstore

Parameter description: Specifies the maximum number of threads that can run at the same time to automatically clear merge hstore delta tables. This parameter is not controlled by the autovacuum parameter.

Type: SIGHUP

Value range: an integer ranging from 0 to 128. The value 0 indicates that the function is disabled.

Default value: 3

autovacuum_naptime

Parameter description: Specifies the interval between two automatic cleanup operations.

Type: SIGHUP

Value range: an integer ranging from 1 to 2147483. The unit is second.

Default value: 20s

autovacuum_vacuum_cost_delay

Parameter description: Specifies the value of the cost delay used in the autovacuum operation.

Type: SIGHUP

Value range: an integer ranging from –1 to 100. The unit is ms. –1 indicates that the normal vacuum cost delay is used.

Default value: 2ms

check_crossvw_write

Parameter description: Specifies whether to enable cross-VW write detection. This parameter is supported only by clusters of version 9.1.0.100 or later.

Type: USERSET

Value range: an integer, -1 or 1.

  • The value –1 indicates that it is compatible with the capabilities of version 9.0.3. For the v3 table vacuum, it only clears non-last files for all epochs.
  • The value 1 indicates checking whether it is a cross-VW write scenario. For the v3 table vacuum, if it is determined to be a non-cross-VW write scenario, it clears non-last files for all epochs, clears the last file for the current epoch, and clears the last file for epochs that are less than the current epoch. If it is determined to be a cross-VW write scenario, CNs will obtain epoch information from all DNs and package it into an epochList to be sent to the metadata VW. The v3 table vacuum will clear non-last files for all epochs and clear the last file for epochs that are less than max{epochList} and not in epochList.

Default value: 1

enable_pg_stat_object

Parameter description: Specifies whether AUTO VACUUM updates the PG_STAT_OBJECT system catalog. This parameter is supported only by clusters of version 8.2.1 or later.

Type: USERSET

Value range: Boolean

  • on indicates that the PG_STAT_OBJECT system catalog is updated during AUTO VACUUM.
  • off indicates that the PG_STAT_OBJECT system catalog is not updated during AUTO VACUUM.

Default value: on