autovacuum_worker_slots
一个 GUC 参数,用于确定 autovacuum_max_workers 的有效最大值
autovacuum_worker_slots
是一个 配置文件参数,用于指定为 autovacuum 工作进程预留的后端槽位数量。
autovacuum_worker_slots
在 PostgreSQL 18 中添加。
默认
autovacuum_worker_slots
的默认值为:16。
然而,如果内核设置合适,initdb
可能会在 postgresql.conf
中设置一个较低的值。
用法
autovacuum_worker_slots
有效地为 autovacuum_max_workers
设置了上限,(从 PostgreSQL 18 开始)可以在不重启服务器的情况下更改。
如果 autovacuum_max_workers
设置得高于 autovacuum_worker_slots
,则会发出 WARNING
警告,并且服务器启动的 autovacuum 工作进程数量不会超过 autovacuum_worker_slots
中指定的数量。
按 PostgreSQL 版本详细信息
autovacuum_worker_slots (PostgreSQL 19)
设置 | 16 |
单位 | |
类别 | 清理 / 自动清理 |
简短描述 | 设置分配给 autovacuum 工作进程的后端槽位数量。 |
扩展描述 | |
上下文 | postmaster |
变量类型 | 整数 |
来源 | 配置文件 |
最小值 | 1 |
最大值 | 262143 |
枚举值 | |
启动值 | 16 |
重置值 | 16 |
源文件 | /home/barwick/devel/postgres/data/19/postgresql.conf |
源行 | 683 |
需要重启 | false |
autovacuum_worker_slots (PostgreSQL 18)
设置 | 16 |
单位 | |
类别 | 清理 / 自动清理 |
简短描述 | 设置分配给 autovacuum 工作进程的后端槽位数量。 |
扩展描述 | |
上下文 | postmaster |
变量类型 | 整数 |
来源 | 配置文件 |
最小值 | 1 |
最大值 | 262143 |
枚举值 | |
启动值 | 16 |
重置值 | 16 |
源文件 | /home/barwick/devel/postgres/data/18/postgresql.conf |
源行 | 683 |
需要重启 | false |
变更历史
- PostgreSQL 18
- 添加于 (commit c758119e)
示例
示例:显示将 autovacuum_max_workers
设置为高于 autovacuum_worker_slots
的值所产生的影响
postgres=# SHOW autovacuum_worker_slots; autovacuum_worker_slots ------------------------- 16 (1 row) postgres=# SHOW autovacuum_max_workers; autovacuum_max_workers ------------------------ 3 (1 row) postgres=# ALTER SYSTEM SET autovacuum_max_workers = 32; ALTER SYSTEM postgres=# SELECT pg_reload_conf(); pg_reload_conf ---------------- t (1 row) postgres=# SHOW autovacuum_max_workers; autovacuum_max_workers ------------------------ 32 (1 row)
但是,尽管对 autovacuum_max_workers
的更改似乎成功了,但在 PostgreSQL 日志中会出现类似以下的 WARNING
警告:
[2025-01-07 08:16:07 JST] WARNING: 22023: "autovacuum_max_workers" (32) should be less than or equal to "autovacuum_worker_slots" (16) [2025-01-07 08:16:07 JST] DETAIL: The server will only start up to "autovacuum_worker_slots" (16) autovacuum workers at a given time.
参考资料
- PostgreSQL 文档: autovacuum_worker_slots
有用链接
- PostgreSQL 18:动态更改 autovacuum 工作进程的最大数量 - 2025 年 1 月 Daniel Westermann / dbi services 的博客文章