Postgres Notes
Changing runtime parameters in Postgres
There are several ways to change runtime parameters in Postgres.
-
Using the
SET
command: TheSET
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:
sql
SET parameter_name = 'value';
-
Using the
ALTER SYSTEM
command: This command is used to change the value of a configuration parameter in thepostgresql.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:sql
ALTER SYSTEM SET parameter_name TO 'value';
-
Modifying the
postgresql.conf
file directly: You can directly edit thepostgresql.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 modifyingpostgres.conf
, use:sql
SELECT pg_reload_conf();
On this page
- Changing runtime parameters in Postgres