Setting Parameters
Context
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.
For details about parameters, 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.
Parameter Type |
Description |
Setting Method |
---|---|---|
INTERNAL |
Fixed parameters. They are set during database creation and cannot be modified. Users can only view the parameters by running the SHOW command or in the pg_settings view. |
None. |
POSTMASTER |
Database server parameters. They can be set when the database is started or in the configuration file. |
Method 1 in Table 2. |
SIGHUP |
Global database parameters. They can be set when the database is started or be modified later. |
Method 1 or 2 in Table 2. |
BACKEND |
Session connection parameters. They are specified during session connection creation and cannot be modified after that. The parameter setting becomes invalid when the session is disconnected. The parameters of this type are internal parameters 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 parameters. They can be set by common users during database startup or after the database is started. They 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 parameters. They can be set by any user at any time. |
Method 1, 2, or 3 in Table 2. |
No. |
Setting Method |
||||||
---|---|---|---|---|---|---|---|
Method 1 |
|
||||||
Method 2 |
gs_guc reload -D datadir -c "paraname=value"
NOTE:
Set a parameter for database nodes at the same time. gs_guc reload -Z datanode -N all -I all -c "paraname=value"
|
||||||
Method 3 |
Set parameters at the database, user, or session level.
|
- If you use method 1 or 2 to set a parameter that does not belong to the current node, the database displays a message indicating that the parameter is not supported.
- When you use method 3 to set a parameter, if the parameter value is an integer, leading zeros will be filtered out. For example, SET paraname TO 008192 and SET paraname TO 8192 have the same effect.
Procedure
The following example shows how to set hot_standby on the primary node of the database using method 1.
- Log in as the OS user omm to the primary node of the database.
- View the value of hot_standby.
1
cat /gaussdb/data/dbnode/gaussdb.conf | grep "hot_standby ="
hot_standby = on
The value on indicates that the query operation in the restoration phase is allowed.
- Set hot_standby to off to disable query operations in the restoration phase.
gs_guc set -Z datanode -D /gaussdb/data/dbnode -c "hot_standby=off"
You can set hot_standby to off for the database nodes.
gs_guc set -Z datanode -N all -I all -c "hot_standby=off"
- Restart the database to make the setting take effect.
gs_om -t stop && gs_om -t start
- Connect to the database. For details, see "Database Quick Start > Connecting to a Database > Using gsql to Connect to a Database" in Developer Guide.
- Check whether the parameter is correctly set.
1 2 3 4 5
gaussdb=# SHOW hot_standby; hot_standby ------------- off (1 row)
The following example shows how to set authentication_timeout on a the primary node of the database using method 2:
- Log in as the OS user omm to the primary node of the database.
- View the value of authentication_timeout.
1
cat /gaussdb/data/dbnode/gaussdb.conf | grep authentication_timeout
authentication_timeout = 1min
- Set authentication_timeout to 59s.
gs_guc reload -Z datanode -N all -I all -c "authentication_timeout = 59s" Total instances: 2. Failed instances: 0. Success to perform gs_guc!
You can set authentication_timeout to 59s for the database nodes.
gs_guc reload -Z datanode -N all -I all -c "authentication_timeout = 59s"
- Connect to the database. For details, see "Database Quick Start > Connecting to a Database > Using gsql to Connect to a Database" in Developer Guide.
- Check whether the parameter is correctly set.
1 2 3 4 5
gaussdb=# SHOW authentication_timeout; authentication_timeout ------------------------ 59s (1 row)
The following example shows how to set explain_perf_mode using method 3:
- Connect to the database. For details, see "Database Quick Start > Connecting to a Database > Using gsql to Connect to a Database" in Developer Guide.
- View the value of explain_perf_mode.
1 2 3 4 5
gaussdb=# SHOW explain_perf_mode; explain_perf_mode ------------------- normal (1 row)
- Set explain_perf_mode.
Perform one of the following operations:
- Set a database-level parameter.
1
gaussdb=# ALTER DATABASE postgres SET explain_perf_mode TO pretty;
If the following information is displayed, the setting is successful:
ALTER DATABASE
The setting takes effect in the next session.
- Set a user-level parameter.
1
gaussdb=# ALTER USER omm SET explain_perf_mode TO pretty;
If the following information is displayed, the setting is successful:
ALTER ROLE
The setting takes effect in the next session.
- Set a session-level parameter.
1
gaussdb=# SET explain_perf_mode TO pretty;
If the following information is displayed, the setting is successful:
SET
- Set a database-level parameter.
- Check whether the parameter is correctly set.
1 2 3 4 5
gaussdb=# SHOW explain_perf_mode; explain_perf_mode -------------- pretty (1 row)
Examples
- Example 1: Modify the maximum number of connections for the primary database node in GaussDB using method 1.
- Connect to the database. For details, see "Database Quick Start > Connecting to a Database > Using gsql to Connect to a Database" in Developer Guide.
- View the maximum number of connections.
1 2 3 4 5
gaussdb=# SHOW max_connections; max_connections ----------------- 200 (1 row)
- Exit the database.
1
gaussdb=# \q
- Change the maximum number of connections for the primary database node in GaussDB.
gs_guc set -Z datanode -N all -I all -c "max_connections = 800"
- Restart the database.
gs_om -t stop && gs_om -t start
- Connect to the database. For details, see "Database Quick Start > Connecting to a Database > Using gsql to Connect to a Database" in Developer Guide.
- View the maximum number of connections.
1 2 3 4 5
gaussdb=# SHOW max_connections; max_connections ----------------- 800 (1 row)
- Example 2: Set authentication_timeout (timeout period for client authentication) for the primary node using method 2.
- Connect to the database. For details, see "Database Quick Start > Connecting to a Database > Using gsql to Connect to a Database" in Developer Guide.
- View the timeout period for client authentication.
1 2 3 4 5
gaussdb=# SHOW authentication_timeout; authentication_timeout ------------------------ 1min (1 row)
- Exit the database.
1
gaussdb=# \q
- Change the timeout period for client authentication of the primary node.
gs_guc reload -Z datanode -N all -I all -c "authentication_timeout = 59s"
- Connect to the database. For details, see "Database Quick Start > Connecting to a Database > Using gsql to Connect to a Database" in Developer Guide.
- View the timeout period for client authentication.
1 2 3 4 5
gaussdb=# SHOW authentication_timeout; authentication_timeout ------------------------ 59s (1 row)
- Example 3: Change the maximum number of connections between GaussDB database nodes.
- Connect to the database. For details, see "Database Quick Start > Connecting to a Database > Using gsql to Connect to a Database" in Developer Guide.
- View the maximum number of connections.
1 2 3 4 5
gaussdb=# SHOW max_connections; max_connections ----------------- 200 (1 row)
- Exit the database.
1
gaussdb=# \q
- Change the maximum number of connections between GaussDB database nodes.
gs_guc set -Z datanode -N all -I all -c "max_connections = 500"
- Restart the database.
gs_om -t stop gs_om -t start
- Connect to the database. For details, see "Database Quick Start > Connecting to a Database > Using gsql to Connect to a Database" in Developer Guide.
- View the maximum number of connections.
1 2 3 4 5
gaussdb=# SHOW max_connections; max_connections ----------------- 500 (1 row)
- Example 4: Set authentication_timeout (timeout period for client authentication) for database nodes.
- Connect to the database. For details, see "Database Quick Start > Connecting to a Database > Using gsql to Connect to a Database" in Developer Guide.
- View the timeout period for client authentication.
1 2 3 4 5
gaussdb=# SHOW authentication_timeout; authentication_timeout ------------------------ 1min (1 row)
- Exit the database.
1
gaussdb=# \q
- Change the timeout period for client authentication of GaussDB database nodes.
gs_guc reload -Z datanode -N all -I all -c "authentication_timeout = 30s"
- Connect to the database. For details, see "Database Quick Start > Connecting to a Database > Using gsql to Connect to a Database" in Developer Guide.
- View the timeout period for client authentication.
1 2 3 4 5
gaussdb=# SHOW authentication_timeout; authentication_timeout ------------------------ 30s (1 row)
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot