Develop
Postgres Notes
Changing runtime parameters in Postgres
There are several ways to change runtime parameters in Postgres.
-
Using the
SETcommandThe
SETcommand 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 SYSTEMcommandThis command is used to change the value of a configuration parameter in the
postgresql.auto.conffile. This file is read at server start-up and after the mainpostgresql.conffile. Changes made withALTER SYSTEMare applied globally and persist across server restarts.Example:
sqlCopyALTER SYSTEM SET parameter_name TO 'value'; -
Modifying the
postgresql.conffile directlyYou can directly edit the
postgresql.conffile 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();