## 20.10. Automatic Vacuuming [](<>) These settings control the behavior of the*autovacuum*feature. Refer to[Section 25.1.6](routine-vacuuming.html#AUTOVACUUM)for more information. Note that many of these settings can be overridden on a per-table basis; see[Storage Parameters](sql-createtable.html#SQL-CREATETABLE-STORAGE-PARAMETERS). `autovacuum`(`boolean`)[](<>) Controls whether the server should run the autovacuum launcher daemon. This is on by default; however,[track_counts](runtime-config-statistics.html#GUC-TRACK-COUNTS)must also be enabled for autovacuum to work. This parameter can only be set in the`postgresql.conf`file or on the server command line; however, autovacuuming can be disabled for individual tables by changing table storage parameters. Note that even when this parameter is disabled, the system will launch autovacuum processes if necessary to prevent transaction ID wraparound. See[Section 25.1.5](routine-vacuuming.html#VACUUM-FOR-WRAPAROUND)for more information. `autovacuum_max_workers`(`integer`)[](<>) Specifies the maximum number of autovacuum processes (other than the autovacuum launcher) that may be running at any one time. The default is three. This parameter can only be set at server start. `autovacuum_naptime`(`整数`)[](<>) 指定在任何给定数据库上运行 autovacuum 之间的最小延迟。在每一轮中,守护进程检查数据库和问题`真空`和`分析`该数据库中的表所需的命令。如果指定此值没有单位,则以秒为单位。默认值为一分钟(`1分钟`)。该参数只能在`postgresql.conf`文件或在服务器命令行上。 `autovacuum_vacuum_threshold`(`整数`)[](<>) 指定触发一个更新或删除元组的最小数量`真空`在任何一张桌子上。默认值为 50 个元组。该参数只能在`postgresql.conf`文件或服务器命令行;但是可以通过更改表存储参数来覆盖单个表的设置。 `autovacuum_vacuum_insert_threshold`(`整数`)[](<>) 指定触发 a 所需的插入元组数`真空`在任何一张桌子上。默认值为 1000 个元组。如果指定了 -1,autovacuum 将不会触发`真空`根据插入次数对任何表进行操作。该参数只能在`postgresql.conf`文件或服务器命令行;但是可以通过更改表存储参数来覆盖单个表的设置。 `autovacuum_analyze_threshold`(`整数`)[](<>) 指定触发一个`分析`在任何一张桌子上。默认值为 50 个元组。该参数只能在`postgresql.conf`文件或服务器命令行;但是可以通过更改表存储参数来覆盖单个表的设置。 `autovacuum_vacuum_scale_factor`(`浮点`)[](<>) 指定要添加到的表大小的一部分`autovacuum_vacuum_threshold`在决定是否触发`真空`.默认值为 0.2(表大小的 20%)。该参数只能在`postgresql.conf`文件或服务器命令行;但是可以通过更改表存储参数来覆盖单个表的设置。 `autovacuum_vacuum_insert_scale_factor`(`浮点`)[](<>) 指定要添加到的表大小的一部分`autovacuum_vacuum_insert_threshold`在决定是否触发`真空`.默认值为 0.2(表大小的 20%)。该参数只能在`postgresql.conf`文件或服务器命令行;但是可以通过更改表存储参数来覆盖单个表的设置。 `autovacuum_analyze_scale_factor`(`浮点`)[](<>) 指定要添加到的表大小的一部分`autovacuum_analyze_threshold`在决定是否触发`分析`.默认值为 0.1(表大小的 10%)。该参数只能在`postgresql.conf`文件或服务器命令行;但是可以通过更改表存储参数来覆盖单个表的设置。 `autovacuum_freeze_max_age`(`整数`)[](<>) 指定表的最大年龄(在事务中)`pg_class`.`再冷冻西德`领域可以达到之前`真空`强制操作以防止表内的事务 ID 回绕。请注意,即使禁用了 autovacuum,系统也会启动 autovacuum 进程以防止回绕。 Vacuum 还允许从`pg_xact`子目录,这也是为什么默认是2亿笔交易比较低的原因。该参数只能在服务器启动时设置,但可以通过更改表存储参数来减少单个表的设置。有关更多信息,请参阅[第 25.1.5 节](routine-vacuuming.html#VACUUM-FOR-WRAPAROUND). `autovacuum_multixact_freeze_max_age`(`整数`)[](<>) 指定表的最大年龄(在 multixacts 中)`pg_class`.`relminxid`领域可以达到之前`真空`强制操作以防止表内的 multixact ID 回绕。请注意,即使禁用了 autovacuum,系统也会启动 autovacuum 进程以防止回绕。 清理 multixacts 还允许从`pg_multixact/成员`和`pg_multixact/offsets`子目录,这就是为什么默认是一个相对较低的 4 亿 multixacts。该参数只能在服务器启动时设置,但可以通过更改表存储参数来减少单个表的设置。有关更多信息,请参阅[第 25.1.5.1 节](routine-vacuuming.html#VACUUM-FOR-MULTIXACT-WRAPAROUND). `autovacuum_vacuum_cost_delay`(`浮点`)[](<>) 指定将在自动中使用的成本延迟值`真空`操作。如果指定了 -1,则常规[真空\_成本\_延迟](runtime-config-resource.html#GUC-VACUUM-COST-DELAY)值将被使用。如果指定此值没有单位,则以毫秒为单位。默认值为 2 毫秒。该参数只能在`postgresql.conf`文件或服务器命令行;但是可以通过更改表存储参数来覆盖单个表的设置。 `autovacuum_vacuum_cost_limit`(`整数`)[](<>) 指定将在自动中使用的成本限制值`真空`操作。如果指定了 -1(这是默认值),则常规[真空\_成本\_限制](runtime-config-resource.html#GUC-VACUUM-COST-LIMIT)值将被使用。请注意,该值会按比例分配给正在运行的 autovacuum 工作人员(如果有多个工作人员),因此每个工作人员的限制总和不会超过此变量的值。该参数只能在`postgresql.conf`文件或服务器命令行;但是可以通过更改表存储参数来覆盖单个表的设置。