> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cockroachlabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SET CLUSTER SETTING

The `SET CLUSTER SETTING` [statement](/docs/stable/sql-statements.md) modifies a [cluster-wide setting](/docs/stable/cluster-settings.md#setting-sql-defaults-cost-scans-with-default-col-size-enabled).

## 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, the `root` user belongs to the `admin` role.)

* Have the `MODIFYCLUSTERSETTING` [system-level privilege](/docs/stable/security-reference/authorization.md#privileges) granted. `root` and [`admin`](/docs/stable/security-reference/authorization#admin-role) users have this system-level privilege by default and are capable of granting it to other users and roles using the [`GRANT`](/docs/stable/grant) statement. For example to grant this system-level privilege to user `maxroach`:

  ```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  GRANT SYSTEM MODIFYCLUSTERSETTING TO maxroach;
  ```

* Have the `MODIFYSQLCLUSTERSETTING` [system-level privilege](/docs/stable/security-reference/authorization.md#privileges) granted. Users with this privilege are allowed to modify only [`sql.defaults.*` cluster settings](/docs/stable/cluster-settings#setting-sql-defaults-cost-scans-with-default-col-size-enabled), not all cluster settings.

## Synopsis

![set\_cluster\_setting syntax diagram](https://mintcdn.com/cockroachlabs/UZNSFbmU2EwEm6G5/images/sql-diagrams/common/set_cluster_setting.svg?fit=max\&auto=format\&n=UZNSFbmU2EwEm6G5\&q=85\&s=2ce32b1b0ab325090853a56edb633cb6)

## Parameters

| Parameter | Description |
| - | - |
| `var_name` | The name of the [cluster setting](/docs/stable/cluster-settings.md#setting-sql-defaults-cost-scans-with-default-col-size-enabled) (case-insensitive). |
| `var_value` | The value for the [cluster setting](/docs/stable/cluster-settings.md#setting-sql-defaults-cost-scans-with-default-col-size-enabled). |
| `DEFAULT` | Reset the [cluster setting](/docs/stable/cluster-settings.md#setting-sql-defaults-cost-scans-with-default-col-size-enabled) to its default value. The [`RESET CLUSTER SETTING`](/docs/stable/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](https://www.cockroachlabs.com/blog/local-and-distributed-processing-in-cockroachdb/):

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SET CLUSTER SETTING sql.defaults.distsql = 1;
```

To disable distributed execution for all new sessions:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SET CLUSTER SETTING sql.defaults.distsql = 0;
```

> [!NOTE]
>
> Use [`ALTER ROLE ALL SET {sessionvar} = {val}`](/docs/stable/alter-role#set-default-session-variable-values-for-all-users) instead of the `sql.defaults.*` [cluster settings](/docs/stable/cluster-settings.md#setting-sql-defaults-cost-scans-with-default-col-size-enabled). This allows you to set a default value for all users for any [session variable](/docs/stable/set-vars.md) that applies during login, making the `sql.defaults.*` cluster settings redundant.

### Disable automatic diagnostic reporting

To opt out of [automatic diagnostic reporting](/docs/stable/diagnostics-reporting.md) of usage data to Cockroach Labs:

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SET CLUSTER SETTING diagnostics.reporting.enabled = false;
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SHOW CLUSTER SETTING diagnostics.reporting.enabled;
```

```
  diagnostics.reporting.enabled
---------------------------------
              false
(1 row)
```

### Reset a setting to its default value

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SET CLUSTER SETTING sql.metrics.statement_details.enabled = false;
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SHOW CLUSTER SETTING sql.metrics.statement_details.enabled;
```

```
  sql.metrics.statement_details.enabled
-----------------------------------------
                  false
(1 row)
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SET CLUSTER SETTING sql.metrics.statement_details.enabled = DEFAULT;
```

```sql theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
> SHOW CLUSTER SETTING sql.metrics.statement_details.enabled;
```

```
  sql.metrics.statement_details.enabled
-----------------------------------------
                  true
(1 row)
```

## See also

* [`SET {session variable}`](/docs/stable/set-vars)
* [`SHOW CLUSTER SETTING`](/docs/stable/show-cluster-setting)
* [Cluster settings](/docs/stable/cluster-settings.md#setting-sql-defaults-cost-scans-with-default-col-size-enabled)
* [`SHOW DEFAULT SESSION VARIABLES FOR ROLE`](/docs/stable/show-default-session-variables-for-role)
