如何将所有 autovacuum 设置恢复到他们的 postgres 默认值

How to restore all autovacuum settings to their postgres default

我对 postgres autovacuum 设置做了很多更改,例如更改 cost_delay 和午睡时间设置。我不确定我的所有更改是什么---并且想将 autovacuum 设置重置为默认设置。

是否有我可以执行的命令来将它们恢复为默认值?

您必须重置您更改的每个设置。如果您不记得更改了哪些设置,可以查询 pg_settings 所有非默认值:

select name, 
       setting as current_value,
       reset_val, 
       boot_val as original_default, 
       sourcefile, 
       sourceline
from pg_settings
where source <> 'default'
  and name like '%autovacuum%';

reset_val 是设置将恢复到的值,如果您 运行 reset <name>; - 这适用于您在当前会话中所做的更改(使用 set <name> = ...;

我所说的 original_default 是在根本未指定参数的情况下应用的设置值。

sourcefilesourceline 将帮助您找到 您在哪里 更改了这些值。如果那是例如postgresql.auto.conf 然后使用 alter system 更改设置,应使用 alter system.

重置

如果它是一个不同的配置文件(例如`postgresql.conf),您将需要编辑更改的文件。