Updated on 2023-10-23 GMT+08:00
ALTER SYSTEM SET

ALTER SYSTEM SET

Function

The ALTER SYSTEM SET command is used to set GUC parameters of the POSTMASTER, SIGHUP, and BACKEND levels. This command writes parameters into the configuration file. The time to take effect varies according to the level.

Precautions

  • Only users with administrator permissions can run this command.
  • The effective time of GUC parameters at different levels is as follows:
    • The GUC parameters at the POSTMASTER level take effect only after the system is restarted.
    • The GUC parameters at the BACKEND level take effect only after the session is reconnected.
    • The GUC parameters at the SIGHUP level take effect immediately. (Actually, there is a slight delay to wait for the thread reloading the parameter.)
  • You can set the audit_set_parameter parameter to specify whether the operation is audited.
  • The operation can be synchronized to the standby server.

Syntax

ALTER SYSTEM SET parameter TO value;

Parameter Description

  • parameter

    GUC parameter

  • value

    GUC parameter value

Examples

-- Set a SIGHUP-level parameter audit_enabled.
postgres=#  alter system set audit_enabled to off;
ALTER SYSTEM SET
postgres=#  show audit_enabled;
 audit_enabled
---------------
 off
(1 row)

-- The setting of the POSTMASTER-level parameter enable_thread_pool takes effect after the system is restarted.
postgres=# alter system set enable_thread_pool to on;
NOTICE:  please restart the database for the POSTMASTER level parameter to take effect.
ALTER SYSTEM SET