原文地址:
https://www.depesz.com/2025/01/24/waiting-for-postgresql-18-allow-changing-autovacuum_max_workers-without-restarting/
2025 年 1 月 6 日,Nathan Bossart提交了补丁:
Allow changing autovacuum_max_workers without restarting.允许更改autovacuum_max_worker不需要重启。This commit introduces a new parameter namedautovacuum_worker_slots that controls how many autovacuum workerslots to reserve during server startup. Modifying this newparameter's value does require a server restart, but it shouldtypically be set to the upper bound of what you might realisticallyneed to set autovacuum_max_workers. With that new parameter inplace, autovacuum_max_workers can now be changed with a SIGHUP(e.g., pg_ctl reload).If autovacuum_max_workers is set higher thanautovacuum_worker_slots, a WARNING is emitted, and the server willonly start up to autovacuum_worker_slots workers at a given time.If autovacuum_max_workers is set to a value less than the number ofcurrently-running autovacuum workers, the existing workers willcontinue running, but no new workers will be started until thenumber of running autovacuum workers drops belowautovacuum_max_workers.Reviewed-by: Sami Imseih, Justin Pryzby, Robert Haas, Andres Freund, Yogesh SharmaDiscussion: https://postgr.es/m/20240410212344.GA1824549%40nathanxps13
这很有趣。
您可能知道,我是自动清理 (auto vacuum) 的粉丝,并且我个人认为人们通常不会正确配置他们的auto vacuum。
其中一个方案是能够配置 auto vacuum,使其在一天中的特定时间段内更高效地工作。
由于这一变化,我们可以:
将 autovacuum_worker_slots 设置为 50 之类的值
将 autovacuum_max_workers 设置为正常值 3-10
然后,例如在晚上或周末,将autovacuum_max_workers提升到更高的值,以使autovacuum完成更多需要的工作(如果需要)。
那么,让我们看看它实际上是如何运作的:
=$ show autovacuum_worker_slots ;autovacuum_worker_slots─────────────────────────50(1 row)=$ show autovacuum_max_workers ;autovacuum_max_workers────────────────────────3(1 row)
=$ alter system set autovacuum_max_workers = 10;ALTER SYSTEM=$ select pg_reload_conf();pg_reload_conf────────────────t(1 row)
=$ show autovacuum_max_workers ;autovacuum_max_workers────────────────────────10(1 row)
=$ alter system reset autovacuum_max_workers;ALTER SYSTEM=$ select pg_reload_conf();pg_reload_conf────────────────t(1 row)=$ show autovacuum_max_workers ;autovacuum_max_workers────────────────────────3(1 row)
文章转载自飞象数据,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




