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

# SET CLUSTER SETTING

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

The `SET CLUSTER SETTING` <InternalLink path="sql-statements">statement</InternalLink> modifies a <InternalLink path="cluster-settings">cluster-wide setting</InternalLink>.

<Danger>
  Many cluster settings are intended for tuning CockroachDB internals. Before changing these settings, we strongly
  encourage you to discuss your goals with CockroachDB; otherwise, you use them at your own risk.
</Danger>

## 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` <InternalLink path="security-reference/authorization#privileges">system-level privilege</InternalLink> granted. `root` and <InternalLink path="security-reference/authorization#admin-role">`admin`</InternalLink> users have this system-level privilege by default and are capable of granting it to other users and roles using the <InternalLink path="grant">`GRANT`</InternalLink> 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` <InternalLink path="security-reference/authorization#privileges">system-level privilege</InternalLink> granted. Users with this privilege are allowed to modify only <InternalLink path="cluster-settings">`sql.defaults.*` cluster settings</InternalLink>, not all cluster settings.

## Synopsis

<img src="https://mintcdn.com/cockroachlabs/tGEtnfk6iFpQGcmj/images/sql-diagrams/v26.1/set_cluster_setting.svg?fit=max&auto=format&n=tGEtnfk6iFpQGcmj&q=85&s=9b141b5f016b5c6f2bc634b9f32b39ed" alt="set_cluster_setting syntax diagram" style={{maxWidth: "100%", overflowX: "auto"}} width="609" height="81" data-path="images/sql-diagrams/v26.1/set_cluster_setting.svg" />

<Note>
  The `SET CLUSTER SETTING` statement is unrelated to the other <InternalLink path="set-transaction">`SET TRANSACTION`</InternalLink> and <InternalLink path="set-vars">`SET session variable`</InternalLink> statements.
</Note>

## Parameters

| Parameter    | Description                                                                                                                                                                                                                                 |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `var\_name`  | The name of the <InternalLink path="cluster-settings">cluster setting</InternalLink> (case-insensitive).                                                                                                                                    |
| `var\_value` | The value for the <InternalLink path="cluster-settings">cluster setting</InternalLink>.                                                                                                                                                     |
| `DEFAULT`    | Reset the <InternalLink path="cluster-settings">cluster setting</InternalLink> to its default value.     The{" "} <InternalLink path="reset-cluster-setting">`RESET CLUSTER SETTING`</InternalLink>\{" "} 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;
```

Use <InternalLink path="alter-role#set-default-session-variable-values-for-all-users">`ALTER ROLE ALL SET &#123;sessionvar&#125; = &#123;val&#125;
  `</InternalLink> instead of the `sql.defaults.*` <InternalLink path="cluster-settings">cluster
settings</InternalLink>. This allows you to set a default value for all users for any <InternalLink path="set-vars">session
variable</InternalLink> that applies during login, making the `sql.defaults.*` cluster settings redundant.

### Disable automatic diagnostic reporting

To opt out of <InternalLink path="diagnostics-reporting">automatic diagnostic reporting</InternalLink> 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;
```

```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  diagnostics.reporting.enabled
---------------------------------
              false
(1 row)
```

### Reset a setting to its default value

<Tip>
  You can use <InternalLink path="reset-cluster-setting">`RESET CLUSTER SETTING`</InternalLink> to reset a cluster setting as well.
</Tip>

```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;
```

```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  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;
```

```text theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
  sql.metrics.statement_details.enabled
-----------------------------------------
                  true
(1 row)
```

## See also

* <InternalLink path="set-vars">`SET session variable`</InternalLink>
* <InternalLink path="show-cluster-setting">`SHOW CLUSTER SETTING`</InternalLink>
* <InternalLink path="cluster-settings">Cluster settings</InternalLink>
* <InternalLink path="show-default-session-variables-for-role">`SHOW DEFAULT SESSION VARIABLES FOR ROLE`</InternalLink>
