2020-04-03 13:23:32 +00:00
---
2023-01-09 22:02:35 +00:00
sidebar_label: Settings Overview
2023-01-24 22:19:50 +00:00
sidebar_position: 1
2022-04-23 22:18:56 +00:00
slug: /en/operations/settings/
2022-10-04 11:36:59 +00:00
pagination_next: en/operations/settings/settings
2020-04-03 13:23:32 +00:00
---
2022-04-23 22:18:56 +00:00
# Settings Overview
2020-05-06 06:13:29 +00:00
2023-01-09 23:17:29 +00:00
There are multiple ways to define ClickHouse settings. Settings are configured in layers, and each subsequent layer redefines the previous values of a setting.
2017-12-28 15:13:23 +00:00
2023-01-09 22:02:35 +00:00
The order of priority for defining a setting is:
2017-12-28 15:13:23 +00:00
2023-07-10 21:21:37 +00:00
1. Settings in user profiles. Set user profiles either by:
- SQL (recommended)
- adding one or more XML or YAML files to `/etc/clickhouse-server/users.d`
2017-12-28 15:13:23 +00:00
2023-01-09 22:02:35 +00:00
2. Session settings
2017-12-28 15:13:23 +00:00
2023-01-09 22:02:35 +00:00
- Send `SET setting=value` from the ClickHouse console client in interactive mode.
2020-03-21 04:11:51 +00:00
Similarly, you can use ClickHouse sessions in the HTTP protocol. To do this, you need to specify the `session_id` HTTP parameter.
2017-12-28 15:13:23 +00:00
2023-01-09 22:02:35 +00:00
3. Query settings
2017-12-28 15:13:23 +00:00
2023-04-19 15:55:29 +00:00
- When starting the ClickHouse console client in non-interactive mode, set the startup parameter `--setting=value` .
- When using the HTTP API, pass CGI parameters (`URL?setting_1=value& setting_2=value...`).
- Define settings in the [SETTINGS ](../../sql-reference/statements/select/index.md#settings-in-select-query ) clause of the SELECT query. The setting value is applied only to that query and is reset to the default or previous value after the query is executed.
2023-01-09 22:02:35 +00:00
View the [Settings ](./settings.md ) page for a description of the ClickHouse settings.
2023-07-10 21:21:37 +00:00
## Examples
These examples all set the value of the `async_insert` setting to `1` , and show how to examine
the settings in a running system.
### Using SQL to create a user profile
```sql
CREATE
SETTINGS PROFILE log_ingest SETTINGS async_insert = 1
```
```sql
CREATE USER ingester
IDENTIFIED WITH sha256_hash BY '7e099f39b84ea79559b3e85ea046804e63725fd1f46b37f281276aae20f86dc3'
# highlight-next-line
SETTINGS PROFILE log_ingest
```
#### Examine the user profile and assignment
```sql
SHOW ACCESS
```
```response
┌─ACCESS─────────────────────────────────────────────────────────────────────────────┐
│ CREATE USER default IDENTIFIED WITH sha256_password │
# highlight-next-line
│ CREATE USER ingester IDENTIFIED WITH sha256_password SETTINGS PROFILE log_ingest │
│ CREATE SETTINGS PROFILE default │
# highlight-next-line
│ CREATE SETTINGS PROFILE log_ingest SETTINGS async_insert = true │
│ CREATE SETTINGS PROFILE readonly SETTINGS readonly = 1 │
│ ... │
└────────────────────────────────────────────────────────────────────────────────────┘
```
### Using XML to create a user profile
```xml title=/etc/clickhouse-server/users.d/users.xml
< clickhouse >
# highlight-start
< profiles >
< log_ingest >
< async_insert > 1< / async_insert >
< / log_ingest >
< / profiles >
# highlight-end
< users >
< ingester >
< password_sha256_hex > 7e099f39b84ea79559b3e85ea046804e63725fd1f46b37f281276aae20f86dc3< / password_sha256_hex >
# highlight-start
< profile > log_ingest< / profile >
# highlight-end
< / ingester >
< default replace = "true" >
< password_sha256_hex > 7e099f39b84ea79559b3e85ea046804e63725fd1f46b37f281276aae20f86dc3< / password_sha256_hex >
< access_management > 1< / access_management >
< named_collection_control > 1< / named_collection_control >
< / default >
< / users >
< / clickhouse >
```
#### Examine the user profile and assignment
```sql
SHOW ACCESS
```
```response
┌─ACCESS─────────────────────────────────────────────────────────────────────────────┐
│ CREATE USER default IDENTIFIED WITH sha256_password │
# highlight-next-line
│ CREATE USER ingester IDENTIFIED WITH sha256_password SETTINGS PROFILE log_ingest │
│ CREATE SETTINGS PROFILE default │
# highlight-next-line
│ CREATE SETTINGS PROFILE log_ingest SETTINGS async_insert = true │
│ CREATE SETTINGS PROFILE readonly SETTINGS readonly = 1 │
│ ... │
└────────────────────────────────────────────────────────────────────────────────────┘
```
2023-01-09 22:02:35 +00:00
## Converting a Setting to its Default Value
If you change a setting and would like to revert it back to its default value, set the value to `DEFAULT` . The syntax looks like:
```sql
SET setting_name = DEFAULT
```
For example, the default value of `max_insert_block_size` is 1048449. Suppose you change its value to 100000:
```sql
SET max_insert_block_size=100000;
SELECT value FROM system.settings where name='max_insert_block_size';
```
The response is:
```response
┌─value──┐
│ 100000 │
└────────┘
```
The following command sets its value back to 1048449:
```sql
SET max_insert_block_size=DEFAULT;
SELECT value FROM system.settings where name='max_insert_block_size';
```
The setting is now back to its default:
```response
┌─value───┐
│ 1048449 │
└─────────┘
```
2018-09-04 11:18:59 +00:00
2018-10-16 10:47:17 +00:00
2020-09-28 02:59:01 +00:00
## Custom Settings {#custom_settings}
2021-07-29 15:20:55 +00:00
In addition to the common [settings ](../../operations/settings/settings.md ), users can define custom settings.
2020-09-28 02:59:01 +00:00
A custom setting name must begin with one of predefined prefixes. The list of these prefixes must be declared in the [custom_settings_prefixes ](../../operations/server-configuration-parameters/settings.md#custom_settings_prefixes ) parameter in the server configuration file.
```xml
< custom_settings_prefixes > custom_< / custom_settings_prefixes >
```
To define a custom setting use `SET` command:
```sql
SET custom_a = 123;
```
To get the current value of a custom setting use `getSetting()` function:
```sql
2021-07-29 15:27:50 +00:00
SELECT getSetting('custom_a');
2020-09-28 02:59:01 +00:00
```
**See Also**
2023-04-19 15:55:29 +00:00
- [Server Configuration Settings ](../../operations/server-configuration-parameters/settings.md )