Updated on 2024-10-14 GMT+08:00

Resetting Parameters

Background

GaussDB provides multiple methods to set GUC parameters for databases, users, or sessions.

  • Parameter names are case-insensitive.
  • The parameter values can be integers, floating points, strings, Boolean values, or enumerated values.
    • The Boolean values can be on/off, true/false, yes/no, or 1/0, and are case-insensitive.
    • The enumerated value range is specified in the enumvals column of the system catalog pg_settings.
  • For parameters using units, specify their units during the setting. Otherwise, default units are used.
    • The default units are specified in the unit column of pg_settings.
    • The unit of memory can be KB, MB, or GB.
    • The unit of time can be ms, s, min, h, or d.
  • You can set parameters about CNs and DNs at a time, but cannot do the same to other parameters.

For details about parameters in the hosts configuration template, see GUC Parameters.

Setting GUC Parameters

GaussDB provides six types of GUC parameters. For details about parameter types and their setting methods, see Table 1.

Table 1 GUC parameter types

Parameter Type

Description

Setting Method

INTERNAL

Fixed parameter. It is set during database creation and cannot be modified. Users can only view the parameter by running the SHOW command or in the pg_settings view.

None

POSTMASTER

Database server parameter. It can be set when the database is started or in the configuration file.

Method 1 in Table 2.

SIGHUP

Global database parameter. It can be set when the database is started or be modified later.

Method 1 or 2 in Table 2.

BACKEND

Session connection parameter. It is specified during session connection creation and cannot be modified after that. The parameter setting becomes invalid when the session is disconnected. This is an internal parameter and not recommended for users to set it.

Method 1 or 2 in Table 2.

NOTE:

The parameter setting takes effect when the next session is created.

SUSET

Database administrator parameter. It can be set by common users when or after the database is started. It can also be set by database administrators using SQL statements.

Method 1 or 2 by a common user, or method 3 by a database administrator in Table 2.

USERSET

Common user parameter. It can be set by any user at any time.

Method 1, 2, or 3 in Table 2.

NOTE:

When you set parameters of the USERSET type, the parameter value set using ALTER DATABASE takes precedence over that set using gs_guc. To make the parameter settings of gs_guc take effect, run the alter database xxx reset xxx command to reset the parameters.

You can set GUC parameters in GaussDB using the methods listed in Table 2.
Table 2 Methods for setting GUC parameters

No.

Setting Method

Method 1

  1. Run the following command to set a parameter:
    gs_guc set -Z nodetype -D datadir -c "paraname=value"
    NOTE:

    If the parameter is a string variable, use -c parameter="'value'" or -c "parameter = 'value'".

    Run the following command to set a parameter for CNs and DNs at the same time:

    gs_guc set -Z coordinator -Z datanode -N all -I all -c "paraname=value"

    Run the following command to set a cm_agent parameter for CN and DN:

    gs_guc set -Z cmagent -N all -I all -c "paraname=value" 
    gs_guc set -Z cmagent -c "paraname=value"

    Run the following command to set a cm_server parameter for CN and DN:

    gs_guc set -Z cmserver -N all -I all -c "paraname=value" 
    gs_guc set -Z cmserver -c "paraname=value"
  2. Restart the database to make the setting take effect.
    NOTE:

    Restarting the database cluster results in operation interruption. Properly plan the restart to avoid affecting users.

    gs_om -t stop  gs_om -t start

Method 2

gs_guc reload -Z nodetype -D datadir -c "paraname=value"
NOTE:

Run the following command to set a parameter for CNs and DNs at the same time:

gs_guc reload -Z coordinator -Z datanode -N all -I all -c "paraname=value"

Run the following command to set a cm_agent parameter for CN and DN:

gs_guc reload -Z cmagent -N all -I all -c "paraname=value"
gs_guc reload -Z cmagent -c "paraname=value"

Run the following command to set a cm_server parameter for CN and DN:

gs_guc reload -Z cmserver -N all -I all -c "paraname=value"
gs_guc reload -Z cmserver -c "paraname=value"

Method 3

Modify a session-level parameter.

  • Set a session-level parameter.
    1
    openGauss=# SET paraname TO value;
    

    Parameter value in the current session is changed. After you exit the session, the setting becomes invalid.

If you use method 1 or 2 to set a parameter that does not belong to the current environment, the database displays a message indicating that the parameter is not supported.