Develop
Postgres Notes
Changing runtime parameters in Postgres
There are several ways to change runtime parameters in Postgres.
-
Using the
SET
commandThe
SET
command changes the value of a configuration parameter for the duration of the current session or transaction. These changes do not persist after the session or transaction ends.For example:
sqlCopySET parameter_name = 'value';
-
Using the
ALTER SYSTEM
commandThis command is used to change the value of a configuration parameter in the
postgresql.auto.conf
file. This file is read at server start-up and after the mainpostgresql.conf
file. Changes made withALTER SYSTEM
are applied globally and persist across server restarts.Example:
sqlCopyALTER SYSTEM SET parameter_name TO 'value';
-
Modifying the
postgresql.conf
file directlyYou can directly edit the
postgresql.conf
file to change the default values of parameters. After editing, you usually need to reload the PostgreSQL server for the changes to take effect (a full restart is not always necessary, depending on the parameter).To reload the configuration, after modifying
postgres.conf
, use:sqlCopySELECT pg_reload_conf();