The SET CLUSTER SETTING
statement modifies a cluster-wide setting.
Required privileges
To use the SET CLUSTER SETTING
statement, a user must have one of the following attributes:
- Be a member of the
admin
role. (By default, theroot
user belongs to theadmin
role.) Have the
MODIFYCLUSTERSETTING
system-level privilege granted.root
andadmin
users have this system-level privilege by default and are capable of granting it to other users and roles using theGRANT
statement. For example to grant this system-level privilege to usermaxroach
:GRANT SYSTEM MODIFYCLUSTERSETTING TO maxroach;
Have the
MODIFYSQLCLUSTERSETTING
system-level privilege granted. Users with this privilege are allowed to modify onlysql.defaults.*
cluster settings, not all cluster settings.
Synopsis
SET CLUSTER SETTING
statement is unrelated to the other SET TRANSACTION
and SET {session variable}
statements.Parameters
Parameter | Description |
---|---|
var_name |
The name of the cluster setting (case-insensitive). |
var_value |
The value for the cluster setting. |
DEFAULT |
Reset the cluster setting to its default value. The RESET CLUSTER SETTING resets a cluster setting as well. |
Examples
Change the default distributed execution parameter
To configure a cluster so that new sessions automatically try to run queries in a distributed fashion:
> SET CLUSTER SETTING sql.defaults.distsql = 1;
To disable distributed execution for all new sessions:
> SET CLUSTER SETTING sql.defaults.distsql = 0;
Use ALTER ROLE ALL SET {sessionvar} = {val}
instead of the sql.defaults.*
cluster settings. This allows you to set a default value for all users for any session variable that applies during login, making the sql.defaults.*
cluster settings redundant.
Disable automatic diagnostic reporting
To opt out of automatic diagnostic reporting of usage data to Cockroach Labs:
> SET CLUSTER SETTING diagnostics.reporting.enabled = false;
> SHOW CLUSTER SETTING diagnostics.reporting.enabled;
diagnostics.reporting.enabled
---------------------------------
false
(1 row)
Reset a setting to its default value
RESET CLUSTER SETTING
to reset a cluster setting as well.> SET CLUSTER SETTING sql.metrics.statement_details.enabled = false;
> SHOW CLUSTER SETTING sql.metrics.statement_details.enabled;
sql.metrics.statement_details.enabled
-----------------------------------------
false
(1 row)
> SET CLUSTER SETTING sql.metrics.statement_details.enabled = DEFAULT;
> SHOW CLUSTER SETTING sql.metrics.statement_details.enabled;
sql.metrics.statement_details.enabled
-----------------------------------------
true
(1 row)