Configure via GUC
Overview
Server configuration parameters (also known as Grand Unified Configuration, GUC) allow ADB administrators to manage the DBMS state and configuration. Many of these parameters have the same names and behaviors as in PostgreSQL.
|
NOTE
To see the full list of server configuration parameters, refer to Greenplum documentation.
|
The main GUC features are listed below:
-
Parameter names and values are case-insensitive.
-
Every parameter takes a value of one of the following types: boolean, integer, floating point, enum, or string.
-
Boolean values may be specified as:
-
true:ON,TRUE,YES,1; -
false:OFF,FALSE,NO,0.
-
-
Enum parameters are specified in the same way as string parameters, but are limited by the specified set of values.
-
For those parameters that specify the memory size, you can use the following size units:
-
kB— kilobytes; -
MB— megabytes; -
GB— gigabytes.
Remember that the multiplier for memory units is
1024, not1000. -
-
For those parameters that specify time values, you can use the following time units:
-
ms— milliseconds; -
s— seconds; -
min— minutes; -
h— hours; -
d— days.
-
-
When specifying a memory or time parameter, enclose its value in single quotes
'and do not use any spaces between the value and the unit name. For example:SET effective_cache_size = '20GB';
Set parameters
Every server configuration parameter belongs to one of the categories (see the Set Classifications column in the Greenplum documentation), which define limitations on who and how can change this parameter. All categories are described in detail below.
session or system
This classification defines whether the parameter can be changed "on the fly" (without the DBMS restart and the configuration file reload):
-
session — parameters of this type can be changed "on the fly" at one of the following levels:
-
session:
SET <parameter> = <value>; -
database and role:
ALTER ROLE <role_name> IN DATABASE <database_name> SET <parameter> = <value>; -
role:
ALTER ROLE <role_name> SET <parameter> = <value>; -
database:
ALTER DATABASE <database_name> SET <parameter> = <value>;
You can also define session parameters at the system level — via the postgresql.conf file. In this case, session parameters cannot be applied "on the fly" and require a system restart or a configuration file reload (like system parameters that are described below).
If a session parameter is set at multiple levels, then the most granular setting has a higher precedence. For example, the parameter value that is defined at the session level overrides all other settings. The value specified at the database and role level overrides other level settings except the session one, and so on. The system level has the lowest priority.
-
-
system — parameters of this type can only be changed via the postgresql.conf file (using the
gpconfigutility). You cannot alter these parameters "on the fly". To define a system parameter value, run one of the following commands and then perform a restart or reload operation (depending on the parameter classification):-
Set the parameter value on master only. Use this command for master parameters:
$ gpconfig -c <parameter> -v <value> --masteronlyCAUTIONThis command cannot be applied to thegp_default_storage_optionsparameter, despite this parameter belongs to the master category. If you try to set different values for this parameter on master and segment hosts, you get the following error:gp_default_storage_options value cannot be different on master and segments. Use the next command instead. -
Set the parameter value on all segments (including master):
$ gpconfig -c <parameter> -v <value> -
Set different values of the specified parameter on segment hosts and master:
$ gpconfig -c <parameter> -v <value_segment> -m <value_master> -
Comment the parameter in all configuration files, thus restoring its default value:
$ gpconfig –r <parameter>
-
master or local
This classification applies only to parameters which values are changed via the postgresql.conf file (system or session at the system level):
-
master — parameters of this type should be set in the configuration file of the master instance. The values for these parameters are then passed to or ignored by segments at run time.
-
local — parameters of this type should be set in the configuration file of every segment (including master). Each segment looks through its own configuration file to get the parameter value. Local parameters always require a DBMS restart for changes to be applied.
restart or reload
This classification applies only to parameters which values are changed via the postgresql.conf file (system or session at the system level):
-
restart — parameters of this type require a DBMS restart:
$ gpstop -r -a -
reload — parameters of this type do not require a DBMS restart and can be refreshed by just reloading the server configuration file:
$ gpstop -u -a
Get parameters
To show the current parameter value, use one of the following ways:
-
If you use
psqlor any other client program, run theSHOW <parameter>;command. For example:SHOW effective_cache_size;The result can be like:
effective_cache_size ---------------------- 16GB (1 row)
IMPORTANTFor session parameters that are defined at multiple levels, theSHOWcommand takes into account the priority of settings. The session level has the highest precedence, the system level — the lowest one. -
To get the parameter value that is stored in the postgresql.conf file (at the system level), log out from
psqlor any other client and run the following command:gpconfig –s <parameter>. This command shows the parameter values separately for master and segment hosts. It also checks whether values on all segments are consistent. Example:$ gpconfig -s effective_cache_sizeResult:
Values on all segments are consistent GUC : effective_cache_size Master value: 16GB Segment value: 16GB
Examples
Below is an example of changing the optimizer parameter. This parameter has the master, session, reload classification. To change the parameter value at the session level, do the following:
-
Connect to the ADB master host (via SSH, etc.) and log in under the default user
gpadmin:$ sudo su - gpadmin -
Connect to the database via
psql(or any other client program):$ psql adbThe output is:
psql (9.4.24) Type "help" for help.
-
Get the current parameter value:
SHOW optimizer;Result:
optimizer ----------- on (1 row)
-
Change the parameter value to
offat the session level:SET optimizer = off;Result:
SET
-
Get the current parameter value again:
SHOW optimizer;The value has changed:
optimizer ----------- off (1 row)
-
Log out of
psql(or any other client you use):\q -
Connect to the database via
psql(or any other client program):$ psql adb -
Get the current parameter value again:
SHOW optimizer;In another session, the parameter still has a default value:
optimizer ----------- on (1 row)
Below is an example of changing the gp_external_max_segs parameter. This parameter has the master, session, reload classification. To change the parameter value at the database level, do the following:
-
Connect to the ADB master host (via SSH, etc.) and log in under the default user
gpadmin:$ sudo su - gpadmin -
Connect to the database via
psql(or any other client program):$ psql adbThe output is:
psql (9.4.24) Type "help" for help.
-
Get the current parameter value:
SHOW gp_external_max_segs;Result:
gp_external_max_segs ---------------------- 64 (1 row)
-
Change the parameter value to
32for theadbdatabase:ALTER DATABASE adb SET gp_external_max_segs = 32;Result:
ALTER DATABASE
-
Log out of
psql(or any other client you use):\q -
Connect to the database via
psql(or any other client program):$ psql adb -
Get the current parameter value again:
SHOW gp_external_max_segs;The value has changed:
gp_external_max_segs ---------------------- 32 (1 row)
TIPWhen changing the session configuration parameter at the database level, do not forget to restart the current database session. Otherwise, you cannot see the changes. -
Connect to any other database:
\c books_storeResult:
You are now connected to database "books_store" as user "gpadmin".
-
Check the current parameter value again:
SHOW gp_external_max_segs;In another database, the parameter still has a default value:
gp_external_max_segs ---------------------- 64 (1 row)
Below is an example of changing the gp_connection_send_timeout parameter. This parameter has the master, system, reload classification. To change the parameter value, do the following:
-
Connect to the ADB master host (via SSH, etc.) and log in under the default user
gpadmin:$ sudo su - gpadmin -
Get the current parameter values:
$ gpconfig -s gp_connection_send_timeoutResult:
Values on all segments are consistent GUC : gp_connection_send_timeout Master value: 3600 Segment value: 3600
-
Change the parameter value to
1800on master:$ gpconfig -c gp_connection_send_timeout -v 1800 --masteronlyResult:
20221214:19:32:05:010670 gpconfig:bds-mdw:gpadmin-[INFO]:-completed successfully with parameters '-c gp_connection_send_timeout -v 1800 --masteronly'
-
Get the current parameter values again:
$ gpconfig -s gp_connection_send_timeoutThey are still the same:
Values on all segments are consistent GUC : gp_connection_send_timeout Master value: 3600 Segment value: 3600
-
Reload the configuration file:
$ gpstop -u -a -
Check the current parameter values again:
$ gpconfig -s gp_connection_send_timeoutThe value is changed on master:
Values on all segments are consistent GUC : gp_connection_send_timeout Master value: 1800 Segment value: 3600
As the
gp_connection_send_timeoutparameter belongs to themastercategory, it is not required to change the parameter value on other segments.
Below is an example of changing the max_connections parameter. This parameter has the local, system, restart classification. To change the parameter value, do the following:
-
Connect to the ADB master host (via SSH, etc.) and log in under the default user
gpadmin:$ sudo su - gpadmin -
Get the current parameter values:
$ gpconfig -s max_connectionsResult:
Values on all segments are consistent GUC : max_connections Master value: 250 Segment value: 750
-
Change the parameter value on master to
300and on segment hosts — to800:$ gpconfig -c max_connections -v 800 -m 300Result:
20221214:19:19:15:009073 gpconfig:bds-mdw:gpadmin-[INFO]:-completed successfully with parameters '-c max_connections -v 800 -m 300'
-
Get the current parameter values again:
$ gpconfig -s max_connectionsThey are still the same:
Values on all segments are consistent GUC : max_connections Master value: 250 Segment value: 750
-
Restart the system:
$ gpstop -r -a -
Check the current parameter values again:
$ gpconfig -s max_connectionsThe values are changed on master and segments according to step 3:
Values on all segments are consistent GUC : max_connections Master value: 300 Segment value: 800