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-01-09 22:02:35 +00:00
1. Settings in the `users.xml` server configuration file
2017-12-28 15:13:23 +00:00
2023-01-09 22:02:35 +00:00
- Set in the element `<profiles>` .
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.
## 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 )