settings.md 85.4 KB
Newer Older
1
# Settings {#settings}
2

3
## distributed\_product\_mode {#distributed-product-mode}
4

5
Changes the behavior of [distributed subqueries](../../sql-reference/operators/in.md).
6

7
ClickHouse applies this setting when the query contains the product of distributed tables, i.e. when the query for a distributed table contains a non-GLOBAL subquery for the distributed table.
8 9 10

Restrictions:

11 12 13
-   Only applied for IN and JOIN subqueries.
-   Only if the FROM section uses a distributed table containing more than one shard.
-   If the subquery concerns a distributed table containing more than one shard.
14
-   Not used for a table-valued [remote](../../sql-reference/table-functions/remote.md) function.
15

16
Possible values:
17

18 19 20 21
-   `deny` — Default value. Prohibits using these types of subqueries (returns the “Double-distributed in/JOIN subqueries is denied” exception).
-   `local` — Replaces the database and table in the subquery with local ones for the destination server (shard), leaving the normal `IN`/`JOIN.`
-   `global` — Replaces the `IN`/`JOIN` query with `GLOBAL IN`/`GLOBAL JOIN.`
-   `allow` — Allows the use of these types of subqueries.
22

23
## enable\_optimize\_predicate\_expression {#enable-optimize-predicate-expression}
24

25
Turns on predicate pushdown in `SELECT` queries.
26

27
Predicate pushdown may significantly reduce network traffic for distributed queries.
28 29 30

Possible values:

31 32
-   0 — Disabled.
-   1 — Enabled.
33

F
filimonov 已提交
34
Default value: 1.
35

S
Fixes  
Sergei Bocharov 已提交
36
Usage
37

38
Consider the following queries:
39

40 41
1.  `SELECT count() FROM test_table WHERE date = '2018-10-10'`
2.  `SELECT count() FROM (SELECT * FROM test_table) WHERE date = '2018-10-10'`
42

43
If `enable_optimize_predicate_expression = 1`, then the execution time of these queries is equal because ClickHouse applies `WHERE` to the subquery when processing it.
44

45
If `enable_optimize_predicate_expression = 0`, then the execution time of the second query is much longer, because the `WHERE` clause applies to all the data after the subquery finishes.
46

47
## fallback\_to\_stale\_replicas\_for\_distributed\_queries {#settings-fallback_to_stale_replicas_for_distributed_queries}
48

49
Forces a query to an out-of-date replica if updated data is not available. See [Replication](../../engines/table-engines/mergetree-family/replication.md).
50 51 52

ClickHouse selects the most relevant from the outdated replicas of the table.

53
Used when performing `SELECT` from a distributed table that points to replicated tables.
54 55 56

By default, 1 (enabled).

57
## force\_index\_by\_date {#settings-force_index_by_date}
58

59
Disables query execution if the index can’t be used by date.
60 61 62

Works with tables in the MergeTree family.

63
If `force_index_by_date=1`, ClickHouse checks whether the query has a date key condition that can be used for restricting data ranges. If there is no suitable condition, it throws an exception. However, it does not check whether the condition reduces the amount of data to read. For example, the condition `Date != ' 2000-01-01 '` is acceptable even when it matches all the data in the table (i.e., running the query requires a full scan). For more information about ranges of data in MergeTree tables, see [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md).
64

65
## force\_primary\_key {#force-primary-key}
66 67 68 69 70

Disables query execution if indexing by the primary key is not possible.

Works with tables in the MergeTree family.

71
If `force_primary_key=1`, ClickHouse checks to see if the query has a primary key condition that can be used for restricting data ranges. If there is no suitable condition, it throws an exception. However, it does not check whether the condition reduces the amount of data to read. For more information about data ranges in MergeTree tables, see [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md).
72

73 74 75 76
## force\_data\_skipping\_indices {#settings-force_data_skipping_indices}

Disables query execution if passed data skipping indices wasn't used.

77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
Consider the following example:

```sql
CREATE TABLE data
(
    key Int,
    d1 Int,
    d1_null Nullable(Int),
    INDEX d1_idx d1 TYPE minmax GRANULARITY 1,
    INDEX d1_null_idx assumeNotNull(d1_null) TYPE minmax GRANULARITY 1
)
Engine=MergeTree()
ORDER BY key;

SELECT * FROM data_01515;
SELECT * FROM data_01515 SETTINGS force_data_skipping_indices=''; -- query will produce CANNOT_PARSE_TEXT error.
SELECT * FROM data_01515 SETTINGS force_data_skipping_indices='d1_idx'; -- query will produce INDEX_NOT_USED error.
SELECT * FROM data_01515 WHERE d1 = 0 SETTINGS force_data_skipping_indices='d1_idx'; -- Ok.
SELECT * FROM data_01515 WHERE d1 = 0 SETTINGS force_data_skipping_indices='`d1_idx`'; -- Ok (example of full featured parser).
SELECT * FROM data_01515 WHERE d1 = 0 SETTINGS force_data_skipping_indices='`d1_idx`, d1_null_idx'; -- query will produce INDEX_NOT_USED error, since d1_null_idx is not used.
SELECT * FROM data_01515 WHERE d1 = 0 AND assumeNotNull(d1_null) = 0 SETTINGS force_data_skipping_indices='`d1_idx`, d1_null_idx'; -- Ok.
```

100 101
Works with tables in the MergeTree family.

102
## format\_schema {#format-schema}
A
Alexander Tokmakov 已提交
103

104
This parameter is useful when you are using formats that require a schema definition, such as [Cap’n Proto](https://capnproto.org/) or [Protobuf](https://developers.google.com/protocol-buffers/). The value depends on the format.
105

106
## fsync\_metadata {#fsync-metadata}
107

108
Enables or disables [fsync](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html) when writing `.sql` files. Enabled by default.
109

A
alexey-milovidov 已提交
110
It makes sense to disable it if the server has millions of tiny tables that are constantly being created and destroyed.
111

112
## enable\_http\_compression {#settings-enable_http_compression}
113

114
Enables or disables data compression in the response to an HTTP request.
115 116 117 118 119

For more information, read the [HTTP interface description](../../interfaces/http.md).

Possible values:

120 121
-   0 — Disabled.
-   1 — Enabled.
122 123 124

Default value: 0.

125
## http\_zlib\_compression\_level {#settings-http_zlib_compression_level}
126

127
Sets the level of data compression in the response to an HTTP request if [enable\_http\_compression = 1](#settings-enable_http_compression).
128

129
Possible values: Numbers from 1 to 9.
130 131 132

Default value: 3.

133
## http\_native\_compression\_disable\_checksumming\_on\_decompress {#settings-http_native_compression_disable_checksumming_on_decompress}
134

135
Enables or disables checksum verification when decompressing the HTTP POST data from the client. Used only for ClickHouse native compression format (not used with `gzip` or `deflate`).
136 137 138 139 140

For more information, read the [HTTP interface description](../../interfaces/http.md).

Possible values:

141 142
-   0 — Disabled.
-   1 — Enabled.
143 144 145

Default value: 0.

146
## send\_progress\_in\_http\_headers {#settings-send_progress_in_http_headers}
147

148
Enables or disables `X-ClickHouse-Progress` HTTP response headers in `clickhouse-server` responses.
149 150 151 152 153

For more information, read the [HTTP interface description](../../interfaces/http.md).

Possible values:

154 155
-   0 — Disabled.
-   1 — Enabled.
156 157 158

Default value: 0.

159
## max\_http\_get\_redirects {#setting-max_http_get_redirects}
160

161
Limits the maximum number of HTTP GET redirect hops for [URL](../../engines/table-engines/special/url.md)-engine tables. The setting applies to both types of tables: those created by the [CREATE TABLE](../../sql-reference/statements/create/table.md) query and by the [url](../../sql-reference/table-functions/url.md) table function.
162 163 164

Possible values:

165 166
-   Any positive integer number of hops.
-   0 — No hops allowed.
167 168 169

Default value: 0.

170
## input\_format\_allow\_errors\_num {#settings-input_format_allow_errors_num}
171 172 173 174 175

Sets the maximum number of acceptable errors when reading from text formats (CSV, TSV, etc.).

The default value is 0.

A
Alexander Tokmakov 已提交
176
Always pair it with `input_format_allow_errors_ratio`.
177 178 179

If an error occurred while reading rows but the error counter is still less than `input_format_allow_errors_num`, ClickHouse ignores the row and moves on to the next one.

A
Alexander Tokmakov 已提交
180
If both `input_format_allow_errors_num` and `input_format_allow_errors_ratio` are exceeded, ClickHouse throws an exception.
181

182
## input\_format\_allow\_errors\_ratio {#settings-input_format_allow_errors_ratio}
183 184 185 186 187 188

Sets the maximum percentage of errors allowed when reading from text formats (CSV, TSV, etc.).
The percentage of errors is set as a floating-point number between 0 and 1.

The default value is 0.

A
Alexander Tokmakov 已提交
189
Always pair it with `input_format_allow_errors_num`.
190 191 192

If an error occurred while reading rows but the error counter is still less than `input_format_allow_errors_ratio`, ClickHouse ignores the row and moves on to the next one.

A
Alexander Tokmakov 已提交
193
If both `input_format_allow_errors_num` and `input_format_allow_errors_ratio` are exceeded, ClickHouse throws an exception.
194

195
## input\_format\_values\_interpret\_expressions {#settings-input_format_values_interpret_expressions}
196

197
Enables or disables the full SQL parser if the fast stream parser can’t parse the data. This setting is used only for the [Values](../../interfaces/formats.md#data-format-values) format at the data insertion. For more information about syntax parsing, see the [Syntax](../../sql-reference/syntax.md) section.
198 199 200

Possible values:

201
-   0 — Disabled.
202

203
    In this case, you must provide formatted data. See the [Formats](../../interfaces/formats.md) section.
204

205
-   1 — Enabled.
206

207
    In this case, you can use an SQL expression as a value, but data insertion is much slower this way. If you insert only formatted data, then ClickHouse behaves as if the setting value is 0.
208 209 210

Default value: 1.

S
Fixes  
Sergei Bocharov 已提交
211
Example of Use
212

213
Insert the [DateTime](../../sql-reference/data-types/datetime.md) type value with the different settings.
214

215
``` sql
216 217
SET input_format_values_interpret_expressions = 0;
INSERT INTO datetime_t VALUES (now())
218
```
S
Fixes  
Sergei Bocharov 已提交
219

220
``` text
221 222 223 224
Exception on client:
Code: 27. DB::Exception: Cannot parse input: expected ) before: now()): (at row 1)
```

225
``` sql
226 227
SET input_format_values_interpret_expressions = 1;
INSERT INTO datetime_t VALUES (now())
228
```
S
Fixes  
Sergei Bocharov 已提交
229

230
``` text
231 232 233
Ok.
```

234
The last query is equivalent to the following:
235

236
``` sql
237 238
SET input_format_values_interpret_expressions = 0;
INSERT INTO datetime_t SELECT now()
239
```
S
Fixes  
Sergei Bocharov 已提交
240

241
``` text
242 243 244
Ok.
```

245
## input\_format\_values\_deduce\_templates\_of\_expressions {#settings-input_format_values_deduce_templates_of_expressions}
S
Fixes  
Sergei Bocharov 已提交
246

247
Enables or disables template deduction for SQL expressions in [Values](../../interfaces/formats.md#data-format-values) format. It allows parsing and interpreting expressions in `Values` much faster if expressions in consecutive rows have the same structure. ClickHouse tries to deduce template of an expression, parse the following rows using this template and evaluate the expression on a batch of successfully parsed rows.
B
BayoNet 已提交
248 249 250 251 252 253 254 255 256

Possible values:

-   0 — Disabled.
-   1 — Enabled.

Default value: 1.

For the following query:
S
Fixes  
Sergei Bocharov 已提交
257

258
``` sql
A
Alexander Tokmakov 已提交
259
INSERT INTO test VALUES (lower('Hello')), (lower('world')), (lower('INSERT')), (upper('Values')), ...
260
```
S
Fixes  
Sergei Bocharov 已提交
261

B
BayoNet 已提交
262 263 264
-   If `input_format_values_interpret_expressions=1` and `format_values_deduce_templates_of_expressions=0`, expressions are interpreted separately for each row (this is very slow for large number of rows).
-   If `input_format_values_interpret_expressions=0` and `format_values_deduce_templates_of_expressions=1`, expressions in the first, second and third rows are parsed using template `lower(String)` and interpreted together, expression in the forth row is parsed with another template (`upper(String)`).
-   If `input_format_values_interpret_expressions=1` and `format_values_deduce_templates_of_expressions=1`, the same as in previous case, but also allows fallback to interpreting expressions separately if it’s not possible to deduce template.
A
Alexander Tokmakov 已提交
265

266
## input\_format\_values\_accurate\_types\_of\_literals {#settings-input-format-values-accurate-types-of-literals}
S
Fixes  
Sergei Bocharov 已提交
267

B
BayoNet 已提交
268
This setting is used only when `input_format_values_deduce_templates_of_expressions = 1`. It can happen, that expressions for some column have the same structure, but contain numeric literals of different types, e.g.
269 270

``` sql
A
Alexander Tokmakov 已提交
271 272 273 274
(..., abs(0), ...),             -- UInt64 literal
(..., abs(3.141592654), ...),   -- Float64 literal
(..., abs(-1), ...),            -- Int64 literal
```
S
Fixes  
Sergei Bocharov 已提交
275

B
BayoNet 已提交
276 277 278 279 280 281 282 283 284 285 286
Possible values:

-   0 — Disabled.

    In this case, ClickHouse may use a more general type for some literals (e.g., `Float64` or `Int64` instead of `UInt64` for `42`), but it may cause overflow and precision issues.

-   1 — Enabled.

    In this case, ClickHouse checks the actual type of literal and uses an expression template of the corresponding type. In some cases, it may significantly slow down expression evaluation in `Values`.

Default value: 1.
A
Alexander Tokmakov 已提交
287

288
## input\_format\_defaults\_for\_omitted\_fields {#session_settings-input_format_defaults_for_omitted_fields}
289

290
When performing `INSERT` queries, replace omitted input column values with default values of the respective columns. This option only applies to [JSONEachRow](../../interfaces/formats.md#jsoneachrow), [CSV](../../interfaces/formats.md#csv) and [TabSeparated](../../interfaces/formats.md#tabseparated) formats.
291 292

!!! note "Note"
293
    When this option is enabled, extended table metadata are sent from server to client. It consumes additional computing resources on the server and can reduce performance.
294

295 296
Possible values:

297 298
-   0 — Disabled.
-   1 — Enabled.
299

300
Default value: 1.
301

302
## input\_format\_tsv\_empty\_as\_default {#settings-input-format-tsv-empty-as-default}
A
fixes  
Alexander Tokmakov 已提交
303 304 305 306 307

When enabled, replace empty input fields in TSV with default values. For complex default expressions `input_format_defaults_for_omitted_fields` must be enabled too.

Disabled by default.

308
## input\_format\_null\_as\_default {#settings-input-format-null-as-default}
A
Alexander Tokmakov 已提交
309

310
Enables or disables using default values if input data contain `NULL`, but data type of the corresponding column in not `Nullable(T)` (for text input formats).
A
Alexander Tokmakov 已提交
311

312
## input\_format\_skip\_unknown\_fields {#settings-input-format-skip-unknown-fields}
313

314
Enables or disables skipping insertion of extra data.
315

316
When writing data, ClickHouse throws an exception if input data contain columns that do not exist in the target table. If skipping is enabled, ClickHouse doesn’t insert extra data and doesn’t throw an exception.
317

318 319
Supported formats:

320 321 322 323
-   [JSONEachRow](../../interfaces/formats.md#jsoneachrow)
-   [CSVWithNames](../../interfaces/formats.md#csvwithnames)
-   [TabSeparatedWithNames](../../interfaces/formats.md#tabseparatedwithnames)
-   [TSKV](../../interfaces/formats.md#tskv)
324 325

Possible values:
326

327 328
-   0 — Disabled.
-   1 — Enabled.
329

330 331
Default value: 0.

332
## input\_format\_import\_nested\_json {#settings-input_format_import_nested_json}
333

334
Enables or disables the insertion of JSON data with nested objects.
335 336 337

Supported formats:

338
-   [JSONEachRow](../../interfaces/formats.md#jsoneachrow)
339 340 341

Possible values:

342 343
-   0 — Disabled.
-   1 — Enabled.
344 345 346

Default value: 0.

S
Fixes  
Sergei Bocharov 已提交
347
See also:
348

349
-   [Usage of Nested Structures](../../interfaces/formats.md#jsoneachrow-nested) with the `JSONEachRow` format.
350

351
## input\_format\_with\_names\_use\_header {#settings-input-format-with-names-use-header}
352 353

Enables or disables checking the column order when inserting data.
B
BayoNet 已提交
354

355 356 357
To improve insert performance, we recommend disabling this check if you are sure that the column order of the input data is the same as in the target table.

Supported formats:
358

359 360
-   [CSVWithNames](../../interfaces/formats.md#csvwithnames)
-   [TabSeparatedWithNames](../../interfaces/formats.md#tabseparatedwithnames)
361 362 363

Possible values:

364 365
-   0 — Disabled.
-   1 — Enabled.
366 367

Default value: 1.
368

369
## date\_time\_input\_format {#settings-date_time_input_format}
370

371
Allows choosing a parser of the text representation of date and time.
372

373
The setting doesn’t apply to [date and time functions](../../sql-reference/functions/date-time-functions.md).
374 375 376

Possible values:

377
-   `'best_effort'` — Enables extended parsing.
378

379
    ClickHouse can parse the basic `YYYY-MM-DD HH:MM:SS` format and all [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time formats. For example, `'2018-06-08T01:02:03.000Z'`.
380

381
-   `'basic'` — Use basic parser.
382

383
    ClickHouse can parse only the basic `YYYY-MM-DD HH:MM:SS` format. For example, `'2019-08-20 10:18:56'`.
384 385

Default value: `'basic'`.
386

S
Fixes  
Sergei Bocharov 已提交
387
See also:
388

389 390
-   [DateTime data type.](../../sql-reference/data-types/datetime.md)
-   [Functions for working with dates and times.](../../sql-reference/functions/date-time-functions.md)
391

392
## join\_default\_strictness {#settings-join_default_strictness}
B
BayoNet 已提交
393

394
Sets default strictness for [JOIN clauses](../../sql-reference/statements/select/join.md#select-join).
B
BayoNet 已提交
395

396
Possible values:
B
BayoNet 已提交
397

398 399 400 401
-   `ALL` — If the right table has several matching rows, ClickHouse creates a [Cartesian product](https://en.wikipedia.org/wiki/Cartesian_product) from matching rows. This is the normal `JOIN` behaviour from standard SQL.
-   `ANY` — If the right table has several matching rows, only the first one found is joined. If the right table has only one matching row, the results of `ANY` and `ALL` are the same.
-   `ASOF` — For joining sequences with an uncertain match.
-   `Empty string` — If `ALL` or `ANY` is not specified in the query, ClickHouse throws an exception.
B
BayoNet 已提交
402

403
Default value: `ALL`.
B
BayoNet 已提交
404

405
## join\_any\_take\_last\_row {#settings-join_any_take_last_row}
406

407
Changes behaviour of join operations with `ANY` strictness.
408

409
!!! warning "Attention"
410
    This setting applies only for `JOIN` operations with [Join](../../engines/table-engines/special/join.md) engine tables.
411 412 413

Possible values:

414 415
-   0 — If the right table has more than one matching row, only the first one found is joined.
-   1 — If the right table has more than one matching row, only the last one found is joined.
416

B
BayoNet 已提交
417
Default value: 0.
418

S
Fixes  
Sergei Bocharov 已提交
419
See also:
420

421
-   [JOIN clause](../../sql-reference/statements/select/join.md#select-join)
422
-   [Join table engine](../../engines/table-engines/special/join.md)
423
-   [join\_default\_strictness](#settings-join_default_strictness)
B
BayoNet 已提交
424

425
## join\_use\_nulls {#join_use_nulls}
426

427
Sets the type of [JOIN](../../sql-reference/statements/select/join.md) behavior. When merging tables, empty cells may appear. ClickHouse fills them differently based on this setting.
428

429
Possible values:
430

431
-   0 — The empty cells are filled with the default value of the corresponding field type.
432
-   1 — `JOIN` behaves the same way as in standard SQL. The type of the corresponding field is converted to [Nullable](../../sql-reference/data-types/nullable.md#data_type-nullable), and empty cells are filled with [NULL](../../sql-reference/syntax.md).
433

434 435
Default value: 0.

436
## partial\_merge\_join\_optimizations {#partial_merge_join_optimizations}
437 438 439

Disables optimizations in partial merge join algorithm for [JOIN](../../sql-reference/statements/select/join.md) queries.

440
By default, this setting enables improvements that could lead to wrong results. If you see suspicious results in your queries, disable optimizations by this setting. Optimizations can be different in different versions of the ClickHouse server.
441 442 443 444 445 446 447 448

Possible values:

-   0 — Optimizations disabled.
-   1 — Optimizations enabled.

Default value: 1.

449
## partial\_merge\_join\_rows\_in\_right\_blocks {#partial_merge_join_rows_in_right_blocks}
450 451 452 453 454

Limits sizes of right-hand join data blocks in partial merge join algorithm for [JOIN](../../sql-reference/statements/select/join.md) queries.

ClickHouse server:

455 456 457
1.  Splits right-hand join data into blocks with up to the specified number of rows.
2.  Indexes each block with their minimum and maximum values
3.  Unloads prepared blocks to disk if possible.
458 459 460

Possible values:

461
-   Any positive integer. Recommended range of values: \[1000, 100000\].
462 463 464

Default value: 65536.

465
## join\_on\_disk\_max\_files\_to\_merge {#join_on_disk_max_files_to_merge}
466

467
Limits the number of files allowed for parallel sorting in MergeJoin operations when they are executed on disk.
468 469 470 471 472

The bigger the value of the setting, the more RAM used and the less disk I/O needed.

Possible values:

473
-   Any positive integer, starting from 2.
474 475 476

Default value: 64.

477
## any\_join\_distinct\_right\_table\_keys {#any_join_distinct_right_table_keys}
478 479 480 481 482 483 484 485

Enables legacy ClickHouse server behavior in `ANY INNER|LEFT JOIN` operations.

!!! note "Warning"
    Use this setting only for the purpose of backward compatibility if your use cases depend on legacy `JOIN` behavior.

When the legacy behavior enabled:

486 487
-   Results of `t1 ANY LEFT JOIN t2` and `t2 ANY RIGHT JOIN t1` operations are not equal because ClickHouse uses the logic with many-to-one left-to-right table keys mapping.
-   Results of `ANY INNER JOIN` operations contain all rows from the left table like the `SEMI LEFT JOIN` operations do.
488 489 490

When the legacy behavior disabled:

491 492
-   Results of `t1 ANY LEFT JOIN t2` and `t2 ANY RIGHT JOIN t1` operations are equal because ClickHouse uses the logic which provides one-to-many keys mapping in `ANY RIGHT JOIN` operations.
-   Results of `ANY INNER JOIN` operations contain one row per key from both left and right tables.
493 494 495

Possible values:

496 497
-   0 — Legacy behavior is disabled.
-   1 — Legacy behavior is enabled.
498 499 500 501 502

Default value: 0.

See also:

503
-   [JOIN strictness](../../sql-reference/statements/select/join.md#join-settings)
504

505
## temporary\_files\_codec {#temporary_files_codec}
506 507 508

Sets compression codec for temporary files used in sorting and joining operations on disk.

509
Possible values:
510

511 512
-   LZ4 — [LZ4](https://en.wikipedia.org/wiki/LZ4_(compression_algorithm)) compression is applied.
-   NONE — No compression is applied.
513 514 515

Default value: LZ4.

516
## max\_block\_size {#setting-max_block_size}
517

518
In ClickHouse, data is processed by blocks (sets of column parts). The internal processing cycles for a single block are efficient enough, but there are noticeable expenditures on each block. The `max_block_size` setting is a recommendation for what size of the block (in a count of rows) to load from tables. The block size shouldn’t be too small, so that the expenditures on each block are still noticeable, but not too large so that the query with LIMIT that is completed after the first block is processed quickly. The goal is to avoid consuming too much memory when extracting a large number of columns in multiple threads and to preserve at least some cache locality.
519

520
Default value: 65,536.
521 522 523

Blocks the size of `max_block_size` are not always loaded from the table. If it is obvious that less data needs to be retrieved, a smaller block is processed.

524
## preferred\_block\_size\_bytes {#preferred-block-size-bytes}
525 526 527

Used for the same purpose as `max_block_size`, but it sets the recommended block size in bytes by adapting it to the number of rows in the block.
However, the block size cannot be more than `max_block_size` rows.
528
By default: 1,000,000. It only works when reading from MergeTree engines.
529

530
## merge\_tree\_min\_rows\_for\_concurrent\_read {#setting-merge-tree-min-rows-for-concurrent-read}
B
BayoNet 已提交
531

532
If the number of rows to be read from a file of a [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) table exceeds `merge_tree_min_rows_for_concurrent_read` then ClickHouse tries to perform a concurrent reading from this file on several threads.
B
BayoNet 已提交
533

534
Possible values:
B
BayoNet 已提交
535

536
-   Any positive integer.
537 538 539

Default value: 163840.

540
## merge\_tree\_min\_bytes\_for\_concurrent\_read {#setting-merge-tree-min-bytes-for-concurrent-read}
541

542
If the number of bytes to read from one file of a [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)-engine table exceeds `merge_tree_min_bytes_for_concurrent_read`, then ClickHouse tries to concurrently read from this file in several threads.
543

544
Possible value:
545

546
-   Any positive integer.
B
BayoNet 已提交
547

548
Default value: 251658240.
B
BayoNet 已提交
549

550
## merge\_tree\_min\_rows\_for\_seek {#setting-merge-tree-min-rows-for-seek}
B
BayoNet 已提交
551

552
If the distance between two data blocks to be read in one file is less than `merge_tree_min_rows_for_seek` rows, then ClickHouse does not seek through the file but reads the data sequentially.
B
BayoNet 已提交
553

554
Possible values:
B
BayoNet 已提交
555

556
-   Any positive integer.
557 558 559

Default value: 0.

560
## merge\_tree\_min\_bytes\_for\_seek {#setting-merge-tree-min-bytes-for-seek}
561

562
If the distance between two data blocks to be read in one file is less than `merge_tree_min_bytes_for_seek` bytes, then ClickHouse sequentially reads a range of file that contains both blocks, thus avoiding extra seek.
563 564 565

Possible values:

566
-   Any positive integer.
567 568

Default value: 0.
B
BayoNet 已提交
569

570
## merge\_tree\_coarse\_index\_granularity {#setting-merge-tree-coarse-index-granularity}
B
BayoNet 已提交
571

572
When searching for data, ClickHouse checks the data marks in the index file. If ClickHouse finds that required keys are in some range, it divides this range into `merge_tree_coarse_index_granularity` subranges and searches the required keys there recursively.
B
BayoNet 已提交
573

574
Possible values:
B
BayoNet 已提交
575

576
-   Any positive even integer.
B
BayoNet 已提交
577

578
Default value: 8.
B
BayoNet 已提交
579

580
## merge\_tree\_max\_rows\_to\_use\_cache {#setting-merge-tree-max-rows-to-use-cache}
B
BayoNet 已提交
581

582
If ClickHouse should read more than `merge_tree_max_rows_to_use_cache` rows in one query, it doesn’t use the cache of uncompressed blocks.
B
BayoNet 已提交
583

584
The cache of uncompressed blocks stores data extracted for queries. ClickHouse uses this cache to speed up responses to repeated small queries. This setting protects the cache from trashing by queries that read a large amount of data. The [uncompressed\_cache\_size](../../operations/server-configuration-parameters/settings.md#server-settings-uncompressed_cache_size) server setting defines the size of the cache of uncompressed blocks.
585 586 587

Possible values:

588
-   Any positive integer.
589 590

Default value: 128 ✕ 8192.
B
BayoNet 已提交
591

592
## merge\_tree\_max\_bytes\_to\_use\_cache {#setting-merge-tree-max-bytes-to-use-cache}
593

594
If ClickHouse should read more than `merge_tree_max_bytes_to_use_cache` bytes in one query, it doesn’t use the cache of uncompressed blocks.
595

596
The cache of uncompressed blocks stores data extracted for queries. ClickHouse uses this cache to speed up responses to repeated small queries. This setting protects the cache from trashing by queries that read a large amount of data. The [uncompressed\_cache\_size](../../operations/server-configuration-parameters/settings.md#server-settings-uncompressed_cache_size) server setting defines the size of the cache of uncompressed blocks.
597

598
Possible value:
599

600
-   Any positive integer.
B
BayoNet 已提交
601

602
Default value: 2013265920.
B
BayoNet 已提交
603

604
## min\_bytes\_to\_use\_direct\_io {#settings-min-bytes-to-use-direct-io}
605

606
The minimum data volume required for using direct I/O access to the storage disk.
607

608
ClickHouse uses this setting when reading data from tables. If the total storage volume of all the data to be read exceeds `min_bytes_to_use_direct_io` bytes, then ClickHouse reads the data from the storage disk with the `O_DIRECT` option.
609

S
Fixes  
Sergei Bocharov 已提交
610
Possible values:
611

612 613
-   0 — Direct I/O is disabled.
-   Positive integer.
614

S
Fixes  
Sergei Bocharov 已提交
615
Default value: 0.
616

617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641
## network_compression_method {#network_compression_method}

Sets the method of data compression that is used for communication between servers and between server and [clickhouse-client](../../interfaces/cli.md).

Possible values:

-   `LZ4` — sets LZ4 compression method.
-   `ZSTD` — sets ZSTD compression method.

Default value: `LZ4`.

**See Also**

-   [network_zstd_compression_level](#network_zstd_compression_level)

## network_zstd_compression_level {#network_zstd_compression_level}

Adjusts the level of ZSTD compression. Used only when [network_compression_method](#network_compression_method) is set to `ZSTD`.

Possible values:

-   Positive integer from 1 to 15.

Default value: `1`.

642
## log\_queries {#settings-log-queries}
643

644
Setting up query logging.
645

646
Queries sent to ClickHouse with this setup are logged according to the rules in the [query\_log](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-query-log) server configuration parameter.
647

S
Fixes  
Sergei Bocharov 已提交
648
Example:
649

650
``` text
S
Fixes  
Sergei Bocharov 已提交
651 652
log_queries=1
```
653

654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671
## log\_queries\_min\_type {#settings-log-queries-min-type}

`query_log` minimal type to log.

Possible values:
- `QUERY_START` (`=1`)
- `QUERY_FINISH` (`=2`)
- `EXCEPTION_BEFORE_START` (`=3`)
- `EXCEPTION_WHILE_PROCESSING` (`=4`)

Default value: `QUERY_START`.

Can be used to limit which entiries will goes to `query_log`, say you are interesting only in errors, then you can use `EXCEPTION_WHILE_PROCESSING`:

``` text
log_queries_min_type='EXCEPTION_WHILE_PROCESSING'
```

672
## log\_query\_threads {#settings-log-query-threads}
673 674 675

Setting up query threads logging.

676
Queries’ threads runned by ClickHouse with this setup are logged according to the rules in the [query\_thread\_log](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-query_thread_log) server configuration parameter.
677

S
Fixes  
Sergei Bocharov 已提交
678
Example:
679

680
``` text
S
Fixes  
Sergei Bocharov 已提交
681 682
log_query_threads=1
```
683

684
## max\_insert\_block\_size {#settings-max_insert_block_size}
685

686
The size of blocks (in a count of rows) to form for insertion into a table.
687 688
This setting only applies in cases when the server forms the blocks.
For example, for an INSERT via the HTTP interface, the server parses the data format and forms blocks of the specified size.
689 690
But when using clickhouse-client, the client parses the data itself, and the ‘max\_insert\_block\_size’ setting on the server doesn’t affect the size of the inserted blocks.
The setting also doesn’t have a purpose when using INSERT SELECT, since data is inserted using the same blocks that are formed after SELECT.
691

692
Default value: 1,048,576.
693

694
The default is slightly more than `max_block_size`. The reason for this is because certain table engines (`*MergeTree`) form a data part on the disk for each inserted block, which is a fairly large entity. Similarly, `*MergeTree` tables sort data during insertion and a large enough block size allow sorting more data in RAM.
695

696
## min\_insert\_block\_size\_rows {#min-insert-block-size-rows}
697 698 699 700 701

Sets minimum number of rows in block which can be inserted into a table by an `INSERT` query. Smaller-sized blocks are squashed into bigger ones.

Possible values:

702 703
-   Positive integer.
-   0 — Squashing disabled.
704 705 706

Default value: 1048576.

707
## min\_insert\_block\_size\_bytes {#min-insert-block-size-bytes}
708 709 710 711 712

Sets minimum number of bytes in block which can be inserted into a table by an `INSERT` query. Smaller-sized blocks are squashed into bigger ones.

Possible values:

713 714
-   Positive integer.
-   0 — Squashing disabled.
715 716 717

Default value: 268435456.

718
## max\_replica\_delay\_for\_distributed\_queries {#settings-max_replica_delay_for_distributed_queries}
719

720
Disables lagging replicas for distributed queries. See [Replication](../../engines/table-engines/mergetree-family/replication.md).
721 722 723

Sets the time in seconds. If a replica lags more than the set value, this replica is not used.

724
Default value: 300.
725

726
Used when performing `SELECT` from a distributed table that points to replicated tables.
727

728
## max\_threads {#settings-max_threads}
729

730
The maximum number of query processing threads, excluding threads for retrieving data from remote servers (see the ‘max\_distributed\_connections’ parameter).
731 732

This parameter applies to threads that perform the same stages of the query processing pipeline in parallel.
733
For example, when reading from a table, if it is possible to evaluate expressions with functions, filter with WHERE and pre-aggregate for GROUP BY in parallel using at least ‘max\_threads’ number of threads, then ‘max\_threads’ are used.
734

A
alexey-milovidov 已提交
735
Default value: the number of physical CPU cores.
736 737 738

If less than one SELECT query is normally run on a server at a time, set this parameter to a value slightly less than the actual number of processor cores.

739
For queries that are completed quickly because of a LIMIT, you can set a lower ‘max\_threads’. For example, if the necessary number of entries are located in every block and max\_threads = 8, then 8 blocks are retrieved, although it would have been enough to read just one.
740 741 742

The smaller the `max_threads` value, the less memory is consumed.

743
## max\_insert\_threads {#settings-max-insert-threads}
D
Denis Zhuravlev 已提交
744 745 746 747 748

The maximum number of threads to execute the `INSERT SELECT` query.

Possible values:

749 750
-   0 (or 1) — `INSERT SELECT` no parallel execution.
-   Positive integer. Bigger than 1.
D
Denis Zhuravlev 已提交
751 752 753

Default value: 0.

754
Parallel `INSERT SELECT` has effect only if the `SELECT` part is executed in parallel, see [max\_threads](#settings-max_threads) setting.
D
Denis Zhuravlev 已提交
755 756
Higher values will lead to higher memory usage.

757
## max\_compress\_block\_size {#max-compress-block-size}
758

759
The maximum size of blocks of uncompressed data before compressing for writing to a table. By default, 1,048,576 (1 MiB). If the size is reduced, the compression rate is significantly reduced, the compression and decompression speed increases slightly due to cache locality, and memory consumption is reduced. There usually isn’t any reason to change this setting.
760

761
Don’t confuse blocks for compression (a chunk of memory consisting of bytes) with blocks for query processing (a set of rows from a table).
762

763
## min\_compress\_block\_size {#min-compress-block-size}
764

765
For [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)" tables. In order to reduce latency when processing queries, a block is compressed when writing the next mark if its size is at least ‘min\_compress\_block\_size’. By default, 65,536.
766

767
The actual size of the block, if the uncompressed data is less than ‘max\_compress\_block\_size’, is no less than this value and no less than the volume of data for one mark.
768

769
Let’s look at an example. Assume that ‘index\_granularity’ was set to 8192 during table creation.
770

771
We are writing a UInt32-type column (4 bytes per value). When writing 8192 rows, the total will be 32 KB of data. Since min\_compress\_block\_size = 65,536, a compressed block will be formed for every two marks.
772

773
We are writing a URL column with the String type (average size of 60 bytes per value). When writing 8192 rows, the average will be slightly less than 500 KB of data. Since this is more than 65,536, a compressed block will be formed for each mark. In this case, when reading data from the disk in the range of a single mark, extra data won’t be decompressed.
774

775
There usually isn’t any reason to change this setting.
776

777
## max\_query\_size {#settings-max_query_size}
778 779 780 781

The maximum part of a query that can be taken to RAM for parsing with the SQL parser.
The INSERT query also contains data for INSERT that is processed by a separate stream parser (that consumes O(1) RAM), which is not included in this restriction.

782
Default value: 256 KiB.
783

B
BayoNet 已提交
784 785 786 787 788 789
## max\_parser\_depth {#max_parser_depth}

Limits maximum recursion depth in the recursive descent parser. Allows to control stack size.

Possible values:

790 791
-   Positive integer.
-   0 — Recursion depth is unlimited.
B
BayoNet 已提交
792 793 794

Default value: 1000.

795
## interactive\_delay {#interactive-delay}
796

797
The interval in microseconds for checking whether request execution has been cancelled and sending the progress.
798

799
Default value: 100,000 (checks for cancelling and sends the progress ten times per second).
800

801
## connect\_timeout, receive\_timeout, send\_timeout {#connect-timeout-receive-timeout-send-timeout}
802 803 804

Timeouts in seconds on the socket used for communicating with the client.

805
Default value: 10, 300, 300.
806

807
## cancel\_http\_readonly\_queries\_on\_client\_close {#cancel-http-readonly-queries-on-client-close}
808

809
Cancels HTTP read-only queries (e.g. SELECT) when a client closes the connection without waiting for the response.
810 811 812

Default value: 0

813
## poll\_interval {#poll-interval}
814 815 816

Lock in a wait loop for the specified number of seconds.

817
Default value: 10.
818

819
## max\_distributed\_connections {#max-distributed-connections}
820 821 822

The maximum number of simultaneous connections with remote servers for distributed processing of a single query to a single Distributed table. We recommend setting a value no less than the number of servers in the cluster.

823
Default value: 1024.
824 825 826

The following parameters are only used when creating Distributed tables (and when launching a server), so there is no reason to change them at runtime.

827
## distributed\_connections\_pool\_size {#distributed-connections-pool-size}
828 829 830

The maximum number of simultaneous connections with remote servers for distributed processing of all queries to a single Distributed table. We recommend setting a value no less than the number of servers in the cluster.

831
Default value: 1024.
832

833
## connect\_timeout\_with\_failover\_ms {#connect-timeout-with-failover-ms}
834

835
The timeout in milliseconds for connecting to a remote server for a Distributed table engine, if the ‘shard’ and ‘replica’ sections are used in the cluster definition.
836 837
If unsuccessful, several attempts are made to connect to various replicas.

838
Default value: 50.
839

B
BayoNet 已提交
840 841 842 843 844 845 846 847 848 849 850
## connection\_pool\_max\_wait\_ms {#connection-pool-max-wait-ms}

The wait time in milliseconds for a connection when the connection pool is full.

Possible values:

- Positive integer.
- 0 — Infinite timeout.

Default value: 0.

851
## connections\_with\_failover\_max\_tries {#connections-with-failover-max-tries}
852

853
The maximum number of connection attempts with each replica for the Distributed table engine.
854

855
Default value: 3.
856

857
## extremes {#extremes}
858 859

Whether to count extreme values (the minimums and maximums in columns of a query result). Accepts 0 or 1. By default, 0 (disabled).
860
For more information, see the section “Extreme values”.
861

B
BayoNet 已提交
862 863 864 865 866 867 868 869 870 871 872 873 874 875 876
## kafka\_max\_wait\_ms {#kafka-max-wait-ms}

The wait time in milliseconds for reading messages from [Kafka](../../engines/table-engines/integrations/kafka.md#kafka) before retry.

Possible values:

- Positive integer.
- 0 — Infinite timeout.

Default value: 5000.

See also:

-   [Apache Kafka](https://kafka.apache.org/)

877
## use\_uncompressed\_cache {#setting-use_uncompressed_cache}
878

879
Whether to use a cache of uncompressed blocks. Accepts 0 or 1. By default, 0 (disabled).
880
Using the uncompressed cache (only for tables in the MergeTree family) can significantly reduce latency and increase throughput when working with a large number of short queries. Enable this setting for users who send frequent short requests. Also pay attention to the [uncompressed\_cache\_size](../../operations/server-configuration-parameters/settings.md#server-settings-uncompressed_cache_size) configuration parameter (only set in the config file) – the size of uncompressed cache blocks. By default, it is 8 GiB. The uncompressed cache is filled in as needed and the least-used data is automatically deleted.
881

882
For queries that read at least a somewhat large volume of data (one million rows or more), the uncompressed cache is disabled automatically to save space for truly small queries. This means that you can keep the ‘use\_uncompressed\_cache’ setting always set to 1.
883

884
## replace\_running\_query {#replace-running-query}
885

886 887
When using the HTTP interface, the ‘query\_id’ parameter can be passed. This is any string that serves as the query identifier.
If a query from the same user with the same ‘query\_id’ already exists at this time, the behaviour depends on the ‘replace\_running\_query’ parameter.
888

889
`0` (default) – Throw an exception (don’t allow the query to run if a query with the same ‘query\_id’ is already running).
890 891 892

`1` – Cancel the old query and start running the new one.

893
Yandex.Metrica uses this parameter set to 1 for implementing suggestions for segmentation conditions. After entering the next character, if the old query hasn’t finished yet, it should be cancelled.
894

B
BayoNet 已提交
895 896 897 898 899 900 901 902 903 904 905
## replace\_running\_query\_max\_wait\_ms {#replace-running-query-max-wait-ms}

The wait time for running query with the same `query_id` to finish, when the [replace_running_query](#replace-running-query) setting is active.

Possible values:

- Positive integer.
- 0 — Throwing an exception that does not allow to run a new query if the server already executes a query with the  same `query_id`.

Default value: 5000.

906
## stream\_flush\_interval\_ms {#stream-flush-interval-ms}
907

908
Works for tables with streaming in the case of a timeout, or when a thread generates [max\_insert\_block\_size](#settings-max_insert_block_size) rows.
909 910 911 912 913

The default value is 7500.

The smaller the value, the more often data is flushed into the table. Setting the value too low leads to poor performance.

914
## load\_balancing {#settings-load_balancing}
915

916
Specifies the algorithm of replicas selection that is used for distributed query processing.
917

918
ClickHouse supports the following algorithms of choosing replicas:
919

920 921 922 923
-   [Random](#load_balancing-random) (by default)
-   [Nearest hostname](#load_balancing-nearest_hostname)
-   [In order](#load_balancing-in_order)
-   [First or random](#load_balancing-first_or_random)
A
Azat Khuzhin 已提交
924
-   [Round robin](#load_balancing-round_robin)
925

926 927 928 929
See also:

-   [distributed\_replica\_max\_ignored\_errors](#settings-distributed_replica_max_ignored_errors)

I
Ivan Blinkov 已提交
930
### Random (by Default) {#load_balancing-random}
931

932
``` sql
933 934
load_balancing = random
```
935

936
The number of errors is counted for each replica. The query is sent to the replica with the fewest errors, and if there are several of these, to anyone of them.
937 938
Disadvantages: Server proximity is not accounted for; if the replicas have different data, you will also get different data.

939
### Nearest Hostname {#load_balancing-nearest_hostname}
940

941
``` sql
942 943
load_balancing = nearest_hostname
```
944

945
The number of errors is counted for each replica. Every 5 minutes, the number of errors is integrally divided by 2. Thus, the number of errors is calculated for a recent time with exponential smoothing. If there is one replica with a minimal number of errors (i.e. errors occurred recently on the other replicas), the query is sent to it. If there are multiple replicas with the same minimal number of errors, the query is sent to the replica with a hostname that is most similar to the server’s hostname in the config file (for the number of different characters in identical positions, up to the minimum length of both hostnames).
946 947

For instance, example01-01-1 and example01-01-2.yandex.ru are different in one position, while example01-01-1 and example01-02-2 differ in two places.
948
This method might seem primitive, but it doesn’t require external data about network topology, and it doesn’t compare IP addresses, which would be complicated for our IPv6 addresses.
949 950 951 952

Thus, if there are equivalent replicas, the closest one by name is preferred.
We can also assume that when sending a query to the same server, in the absence of failures, a distributed query will also go to the same servers. So even if different data is placed on the replicas, the query will return mostly the same results.

953
### In Order {#load_balancing-in_order}
954

955
``` sql
956 957
load_balancing = in_order
```
958

959
Replicas with the same number of errors are accessed in the same order as they are specified in the configuration.
960 961
This method is appropriate when you know exactly which replica is preferable.

962
### First or Random {#load_balancing-first_or_random}
963

964
``` sql
965 966 967
load_balancing = first_or_random
```

968
This algorithm chooses the first replica in the set or a random replica if the first is unavailable. It’s effective in cross-replication topology setups, but useless in other configurations.
969

970
The `first_or_random` algorithm solves the problem of the `in_order` algorithm. With `in_order`, if one replica goes down, the next one gets a double load while the remaining replicas handle the usual amount of traffic. When using the `first_or_random` algorithm, the load is evenly distributed among replicas that are still available.
971

972 973
It's possible to explicitly define what the first replica is by using the setting `load_balancing_first_offset`. This gives more control to rebalance query workloads among replicas.

974
### Round Robin {#load_balancing-round_robin}
A
Azat Khuzhin 已提交
975 976 977 978 979 980 981

``` sql
load_balancing = round_robin
```

This algorithm uses round robin policy across replicas with the same number of errors (only the queries with `round_robin` policy is accounted).

982
## prefer\_localhost\_replica {#settings-prefer-localhost-replica}
983 984 985 986 987

Enables/disables preferable using the localhost replica when processing distributed queries.

Possible values:

988 989
-   1 — ClickHouse always sends a query to the localhost replica if it exists.
-   0 — ClickHouse uses the balancing strategy specified by the [load\_balancing](#settings-load_balancing) setting.
990 991 992

Default value: 1.

993
!!! warning "Warning"
994
    Disable this setting if you use [max\_parallel\_replicas](#settings-max_parallel_replicas).
995

996
## totals\_mode {#totals-mode}
997

998 999
How to calculate TOTALS when HAVING is present, as well as when max\_rows\_to\_group\_by and group\_by\_overflow\_mode = ‘any’ are present.
See the section “WITH TOTALS modifier”.
1000

1001
## totals\_auto\_threshold {#totals-auto-threshold}
1002

1003
The threshold for `totals_mode = 'auto'`.
1004
See the section “WITH TOTALS modifier”.
1005

1006
## max\_parallel\_replicas {#settings-max_parallel_replicas}
1007 1008 1009 1010 1011

The maximum number of replicas for each shard when executing a query.
For consistency (to get different parts of the same data split), this option only works when the sampling key is set.
Replica lag is not controlled.

1012
## compile {#compile}
1013 1014 1015

Enable compilation of queries. By default, 0 (disabled).

1016
The compilation is only used for part of the query-processing pipeline: for the first stage of aggregation (GROUP BY).
1017
If this portion of the pipeline was compiled, the query may run faster due to deployment of short cycles and inlining aggregate function calls. The maximum performance improvement (up to four times faster in rare cases) is seen for queries with multiple simple aggregate functions. Typically, the performance gain is insignificant. In very rare cases, it may slow down query execution.
1018

1019
## min\_count\_to\_compile {#min-count-to-compile}
1020 1021

How many times to potentially use a compiled chunk of code before running compilation. By default, 3.
1022 1023
For testing, the value can be set to 0: compilation runs synchronously and the query waits for the end of the compilation process before continuing execution. For all other cases, use values ​​starting with 1. Compilation normally takes about 5-10 seconds.
If the value is 1 or more, compilation occurs asynchronously in a separate thread. The result will be used as soon as it is ready, including queries that are currently running.
1024 1025

Compiled code is required for each different combination of aggregate functions used in the query and the type of keys in the GROUP BY clause.
1026
The results of the compilation are saved in the build directory in the form of .so files. There is no restriction on the number of compilation results since they don’t use very much space. Old results will be used after server restarts, except in the case of a server upgrade – in this case, the old results are deleted.
1027

1028
## output\_format\_json\_quote\_64bit\_integers {#session_settings-output_format_json_quote_64bit_integers}
1029

1030
If the value is true, integers appear in quotes when using JSON\* Int64 and UInt64 formats (for compatibility with most JavaScript implementations); otherwise, integers are output without the quotes.
I
Ivan Zhukov 已提交
1031

1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130
## output\_format\_json\_quote\_denormals {#settings-output_format_json_quote_denormals}

Enables `+nan`, `-nan`, `+inf`, `-inf` outputs in [JSON](../../interfaces/formats.md#json) output format.

Possible values:

-   0 — Disabled.
-   1 — Enabled.

Default value: 0.

**Example**

Consider the following table `account_orders`:

```text
┌─id─┬─name───┬─duration─┬─period─┬─area─┐
│  1 │ Andrew │       20 │      0 │  400 │
│  2 │ John   │       40 │      0 │    0 │
│  3 │ Bob    │       15 │      0 │ -100 │
└────┴────────┴──────────┴────────┴──────┘
```

When `output_format_json_quote_denormals = 0`, the query returns `null` values in output:

```sql
SELECT area/period FROM account_orders FORMAT JSON;
```

```json
{
        "meta":
        [
                {
                        "name": "divide(area, period)",
                        "type": "Float64"
                }
        ],

        "data":
        [
                {
                        "divide(area, period)": null
                },
                {
                        "divide(area, period)": null
                },
                {
                        "divide(area, period)": null
                }
        ],

        "rows": 3,

        "statistics":
        {
                "elapsed": 0.003648093,
                "rows_read": 3,
                "bytes_read": 24
        }
}
```

When `output_format_json_quote_denormals = 1`, the query returns:

```json
{
        "meta":
        [
                {
                        "name": "divide(area, period)",
                        "type": "Float64"
                }
        ],

        "data":
        [
                {
                        "divide(area, period)": "inf"
                },
                {
                        "divide(area, period)": "-nan"
                },
                {
                        "divide(area, period)": "-inf"
                }
        ],

        "rows": 3,

        "statistics":
        {
                "elapsed": 0.000070241,
                "rows_read": 3,
                "bytes_read": 24
        }
}
```

1131
## format\_csv\_delimiter {#settings-format_csv_delimiter}
I
Ivan Zhukov 已提交
1132

1133 1134
The character interpreted as a delimiter in the CSV data. By default, the delimiter is `,`.

1135
## input\_format\_csv\_unquoted\_null\_literal\_as\_null {#settings-input_format_csv_unquoted_null_literal_as_null}
A
Alexander Tokmakov 已提交
1136 1137 1138

For CSV input format enables or disables parsing of unquoted `NULL` as literal (synonym for `\N`).

1139
## output\_format\_csv\_crlf\_end\_of\_line {#settings-output-format-csv-crlf-end-of-line}
M
Mikhail Korotov 已提交
1140

1141
Use DOS/Windows-style line separator (CRLF) in CSV instead of Unix style (LF).
M
Mikhail Korotov 已提交
1142

1143
## output\_format\_tsv\_crlf\_end\_of\_line {#settings-output-format-tsv-crlf-end-of-line}
M
millb 已提交
1144

1145
Use DOC/Windows-style line separator (CRLF) in TSV instead of Unix style (LF).
M
millb 已提交
1146

1147
## insert\_quorum {#settings-insert_quorum}
1148

1149
Enables the quorum writes.
1150

1151 1152
-   If `insert_quorum < 2`, the quorum writes are disabled.
-   If `insert_quorum >= 2`, the quorum writes are enabled.
1153

1154
Default value: 0.
1155

S
Fixes  
Sergei Bocharov 已提交
1156
Quorum writes
1157 1158 1159 1160 1161

`INSERT` succeeds only when ClickHouse manages to correctly write data to the `insert_quorum` of replicas during the `insert_quorum_timeout`. If for any reason the number of replicas with successful writes does not reach the `insert_quorum`, the write is considered failed and ClickHouse will delete the inserted block from all the replicas where data has already been written.

All the replicas in the quorum are consistent, i.e., they contain data from all previous `INSERT` queries. The `INSERT` sequence is linearized.

1162
When reading the data written from the `insert_quorum`, you can use the [select\_sequential\_consistency](#settings-select_sequential_consistency) option.
1163

S
Fixes  
Sergei Bocharov 已提交
1164
ClickHouse generates an exception
1165

1166 1167
-   If the number of available replicas at the time of the query is less than the `insert_quorum`.
-   At an attempt to write data when the previous block has not yet been inserted in the `insert_quorum` of replicas. This situation may occur if the user tries to perform an `INSERT` before the previous one with the `insert_quorum` is completed.
1168

S
Fixes  
Sergei Bocharov 已提交
1169
See also:
1170

1171 1172
-   [insert\_quorum\_timeout](#settings-insert_quorum_timeout)
-   [select\_sequential\_consistency](#settings-select_sequential_consistency)
1173

1174
## insert\_quorum\_timeout {#settings-insert_quorum_timeout}
1175

D
dmi-feo 已提交
1176
Write to quorum timeout in milliseconds. If the timeout has passed and no write has taken place yet, ClickHouse will generate an exception and the client must repeat the query to write the same block to the same or any other replica.
1177

A
alexey-milovidov 已提交
1178
Default value: 600000 milliseconds (ten minutes).
1179

S
Fixes  
Sergei Bocharov 已提交
1180
See also:
1181

1182 1183
-   [insert\_quorum](#settings-insert_quorum)
-   [select\_sequential\_consistency](#settings-select_sequential_consistency)
1184

1185
## select\_sequential\_consistency {#settings-select_sequential_consistency}
1186

1187 1188 1189
Enables or disables sequential consistency for `SELECT` queries:

Possible values:
1190

1191 1192
-   0 — Disabled.
-   1 — Enabled.
1193

1194
Default value: 0.
1195

S
Fixes  
Sergei Bocharov 已提交
1196
Usage
1197

1198 1199
When sequential consistency is enabled, ClickHouse allows the client to execute the `SELECT` query only for those replicas that contain data from all previous `INSERT` queries executed with `insert_quorum`. If the client refers to a partial replica, ClickHouse will generate an exception. The SELECT query will not include data that has not yet been written to the quorum of replicas.

S
Fixes  
Sergei Bocharov 已提交
1200
See also:
1201

1202 1203
-   [insert\_quorum](#settings-insert_quorum)
-   [insert\_quorum\_timeout](#settings-insert_quorum_timeout)
1204

1205
## insert\_deduplicate {#settings-insert-deduplicate}
D
Denis Zhuravlev 已提交
1206

1207
Enables or disables block deduplication of `INSERT` (for Replicated\* tables).
D
Denis Zhuravlev 已提交
1208 1209 1210

Possible values:

1211 1212
-   0 — Disabled.
-   1 — Enabled.
D
Denis Zhuravlev 已提交
1213 1214 1215

Default value: 1.

F
Fan() 已提交
1216 1217
By default, blocks inserted into replicated tables by the `INSERT` statement are deduplicated (see [Data Replication](../../engines/table-engines/mergetree-family/replication.md)).

1218
## deduplicate\_blocks\_in\_dependent\_materialized\_views {#settings-deduplicate-blocks-in-dependent-materialized-views}
D
Denis Zhuravlev 已提交
1219

1220
Enables or disables the deduplication check for materialized views that receive data from Replicated\* tables.
D
Denis Zhuravlev 已提交
1221 1222 1223

Possible values:

1224 1225
      0 — Disabled.
      1 — Enabled.
D
Denis Zhuravlev 已提交
1226 1227 1228 1229 1230

Default value: 0.

Usage

1231 1232
By default, deduplication is not performed for materialized views but is done upstream, in the source table.
If an INSERTed block is skipped due to deduplication in the source table, there will be no insertion into attached materialized views. This behaviour exists to enable insertion of highly aggregated data into materialized views, for cases where inserted blocks are the same after materialized view aggregation but derived from different INSERTs into the source table.
1233
At the same time, this behaviour “breaks” `INSERT` idempotency. If an `INSERT` into the main table was successful and `INSERT` into a materialized view failed (e.g. because of communication failure with Zookeeper) a client will get an error and can retry the operation. However, the materialized view won’t receive the second insert because it will be discarded by deduplication in the main (source) table. The setting `deduplicate_blocks_in_dependent_materialized_views` allows for changing this behaviour. On retry, a materialized view will receive the repeat insert and will perform deduplication check by itself,
1234
ignoring check result for the source table, and will insert rows lost because of the first failure.
D
Denis Zhuravlev 已提交
1235

1236
## max\_network\_bytes {#settings-max-network-bytes}
1237

1238
Limits the data volume (in bytes) that is received or transmitted over the network when executing a query. This setting applies to every individual query.
1239 1240 1241

Possible values:

1242 1243
-   Positive integer.
-   0 — Data volume control is disabled.
1244 1245 1246

Default value: 0.

1247
## max\_network\_bandwidth {#settings-max-network-bandwidth}
1248

1249
Limits the speed of the data exchange over the network in bytes per second. This setting applies to every query.
1250 1251 1252

Possible values:

1253 1254
-   Positive integer.
-   0 — Bandwidth control is disabled.
1255 1256 1257

Default value: 0.

1258
## max\_network\_bandwidth\_for\_user {#settings-max-network-bandwidth-for-user}
1259

1260
Limits the speed of the data exchange over the network in bytes per second. This setting applies to all concurrently running queries performed by a single user.
1261 1262 1263

Possible values:

1264 1265
-   Positive integer.
-   0 — Control of the data speed is disabled.
1266 1267 1268

Default value: 0.

1269
## max\_network\_bandwidth\_for\_all\_users {#settings-max-network-bandwidth-for-all-users}
1270

1271
Limits the speed that data is exchanged at over the network in bytes per second. This setting applies to all concurrently running queries on the server.
1272 1273 1274

Possible values:

1275 1276
-   Positive integer.
-   0 — Control of the data speed is disabled.
1277 1278 1279

Default value: 0.

1280
## count\_distinct\_implementation {#settings-count_distinct_implementation}
1281

1282
Specifies which of the `uniq*` functions should be used to perform the [COUNT(DISTINCT …)](../../sql-reference/aggregate-functions/reference/count.md#agg_function-count) construction.
1283 1284 1285

Possible values:

1286 1287 1288 1289 1290
-   [uniq](../../sql-reference/aggregate-functions/reference/uniq.md#agg_function-uniq)
-   [uniqCombined](../../sql-reference/aggregate-functions/reference/uniqcombined.md#agg_function-uniqcombined)
-   [uniqCombined64](../../sql-reference/aggregate-functions/reference/uniqcombined64.md#agg_function-uniqcombined64)
-   [uniqHLL12](../../sql-reference/aggregate-functions/reference/uniqhll12.md#agg_function-uniqhll12)
-   [uniqExact](../../sql-reference/aggregate-functions/reference/uniqexact.md#agg_function-uniqexact)
1291 1292

Default value: `uniqExact`.
I
Ivan Blinkov 已提交
1293

1294
## skip\_unavailable\_shards {#settings-skip_unavailable_shards}
1295

1296
Enables or disables silently skipping of unavailable shards.
1297

1298
Shard is considered unavailable if all its replicas are unavailable. A replica is unavailable in the following cases:
1299

1300
-   ClickHouse can’t connect to replica for any reason.
1301

1302
    When connecting to a replica, ClickHouse performs several attempts. If all these attempts fail, the replica is considered unavailable.
1303

1304
-   Replica can’t be resolved through DNS.
1305

1306
    If replica’s hostname can’t be resolved through DNS, it can indicate the following situations:
1307

1308
    -   Replica’s host has no DNS record. It can occur in systems with dynamic DNS, for example, [Kubernetes](https://kubernetes.io), where nodes can be unresolvable during downtime, and this is not an error.
1309

1310
    -   Configuration error. ClickHouse configuration file contains a wrong hostname.
1311 1312 1313

Possible values:

1314
-   1 — skipping enabled.
1315

1316
    If a shard is unavailable, ClickHouse returns a result based on partial data and doesn’t report node availability issues.
1317

1318
-   0 — skipping disabled.
1319

1320
    If a shard is unavailable, ClickHouse throws an exception.
1321

1322 1323
Default value: 0.

1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364
## distributed\_group\_by\_no\_merge {#distributed-group-by-no-merge}

Do not merge aggregation states from different servers for distributed query processing, you can use this in case it is for certain that there are different keys on different shards

Possible values:

-   0 — Disabled (final query processing is done on the initiator node).
-   1 - Do not merge aggregation states from different servers for distributed query processing (query completelly processed on the shard, initiator only proxy the data).
-   2 - Same as 1 but apply `ORDER BY` and `LIMIT` on the initiator (can be used for queries with `ORDER BY` and/or `LIMIT`).

**Example**

```sql
SELECT *
FROM remote('127.0.0.{2,3}', system.one)
GROUP BY dummy
LIMIT 1
SETTINGS distributed_group_by_no_merge = 1
FORMAT PrettyCompactMonoBlock

┌─dummy─┐
     0 
     0 
└───────┘
```

```sql
SELECT *
FROM remote('127.0.0.{2,3}', system.one)
GROUP BY dummy
LIMIT 1
SETTINGS distributed_group_by_no_merge = 2
FORMAT PrettyCompactMonoBlock

┌─dummy─┐
     0 
└───────┘
```

Default value: 0

1365
## optimize\_skip\_unused\_shards {#optimize-skip-unused-shards}
1366

1367 1368 1369 1370
Enables or disables skipping of unused shards for [SELECT](../../sql-reference/statements/select/index.md) queries that have sharding key condition in `WHERE/PREWHERE` (assuming that the data is distributed by sharding key, otherwise does nothing).

Possible values:

1371 1372
-   0 — Disabled.
-   1 — Enabled.
1373 1374 1375

Default value: 0

1376 1377
## optimize\_skip\_unused\_shards\_nesting {#optimize-skip-unused-shards-nesting}

A
Azat Khuzhin 已提交
1378
Controls [`optimize_skip_unused_shards`](#optimize-skip-unused-shards) (hence still requires [`optimize_skip_unused_shards`](#optimize-skip-unused-shards)) depends on the nesting level of the distributed query (case when you have `Distributed` table that look into another `Distributed` table).
1379 1380 1381

Possible values:

A
Azat Khuzhin 已提交
1382 1383 1384
-   0 — Disabled, `optimize_skip_unused_shards` works always.
-   1 — Enables `optimize_skip_unused_shards` only for the first level.
-   2 — Enables `optimize_skip_unused_shards` up to the second level.
1385 1386 1387

Default value: 0

1388
## force\_optimize\_skip\_unused\_shards {#force-optimize-skip-unused-shards}
1389

1390
Enables or disables query execution if [optimize\_skip\_unused\_shards](#optimize-skip-unused-shards) is enabled and skipping of unused shards is not possible. If the skipping is not possible and the setting is enabled, an exception will be thrown.
1391 1392 1393

Possible values:

1394
-   0 — Disabled. ClickHouse doesn’t throw an exception.
1395 1396
-   1 — Enabled. Query execution is disabled only if the table has a sharding key.
-   2 — Enabled. Query execution is disabled regardless of whether a sharding key is defined for the table.
1397 1398 1399

Default value: 0

1400
## force\_optimize\_skip\_unused\_shards\_nesting {#settings-force_optimize_skip_unused_shards_nesting}
1401

A
Azat Khuzhin 已提交
1402
Controls [`force_optimize_skip_unused_shards`](#force-optimize-skip-unused-shards) (hence still requires [`force_optimize_skip_unused_shards`](#force-optimize-skip-unused-shards)) depends on the nesting level of the distributed query (case when you have `Distributed` table that look into another `Distributed` table).
1403 1404 1405

Possible values:

A
Azat Khuzhin 已提交
1406 1407 1408
-   0 - Disabled, `force_optimize_skip_unused_shards` works always.
-   1 — Enables `force_optimize_skip_unused_shards` only for the first level.
-   2 — Enables `force_optimize_skip_unused_shards` up to the second level.
1409

A
Azat Khuzhin 已提交
1410
Default value: 0
1411

1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445
## optimize\_distributed\_group\_by\_sharding\_key {#optimize-distributed-group-by-sharding-key}

Optimize `GROUP BY sharding_key` queries, by avoiding costly aggregation on the initiator server (which will reduce memory usage for the query on the initiator server).

The following types of queries are supported (and all combinations of them):

- `SELECT DISTINCT [..., ]sharding_key[, ...] FROM dist`
- `SELECT ... FROM dist GROUP BY sharding_key[, ...]`
- `SELECT ... FROM dist GROUP BY sharding_key[, ...] ORDER BY x`
- `SELECT ... FROM dist GROUP BY sharding_key[, ...] LIMIT 1`
- `SELECT ... FROM dist GROUP BY sharding_key[, ...] LIMIT 1 BY x`

The following types of queries are not supported (support for some of them may be added later):

- `SELECT ... GROUP BY sharding_key[, ...] WITH TOTALS`
- `SELECT ... GROUP BY sharding_key[, ...] WITH ROLLUP`
- `SELECT ... GROUP BY sharding_key[, ...] WITH CUBE`
- `SELECT ... GROUP BY sharding_key[, ...] SETTINGS extremes=1`

Possible values:

-   0 — Disabled.
-   1 — Enabled.

Default value: 0

See also:

-   [distributed\_group\_by\_no\_merge](#distributed-group-by-no-merge)
-   [optimize\_skip\_unused\_shards](#optimize-skip-unused-shards)

!!! note "Note"
    Right now it requires `optimize_skip_unused_shards` (the reason behind this is that one day it may be enabled by default, and it will work correctly only if data was inserted via Distributed table, i.e. data is distributed according to sharding_key).

1446
## optimize\_throw\_if\_noop {#setting-optimize_throw_if_noop}
1447

1448
Enables or disables throwing an exception if an [OPTIMIZE](../../sql-reference/statements/misc.md#misc_operations-optimize) query didn’t perform a merge.
1449

1450
By default, `OPTIMIZE` returns successfully even if it didn’t do anything. This setting lets you differentiate these situations and get the reason in an exception message.
1451 1452 1453

Possible values:

1454 1455
-   1 — Throwing an exception is enabled.
-   0 — Throwing an exception is disabled.
1456 1457

Default value: 0.
1458

1459
## distributed\_replica\_error\_half\_life {#settings-distributed_replica_error_half_life}
V
Vasily Nemkov 已提交
1460

1461 1462
-   Type: seconds
-   Default value: 60 seconds
V
Vasily Nemkov 已提交
1463

1464
Controls how fast errors in distributed tables are zeroed. If a replica is unavailable for some time, accumulates 5 errors, and distributed\_replica\_error\_half\_life is set to 1 second, then the replica is considered normal 3 seconds after last error.
V
Vasily Nemkov 已提交
1465

S
Fixes  
Sergei Bocharov 已提交
1466
See also:
V
Vasily Nemkov 已提交
1467

1468
-   [load\_balancing](#load_balancing-round_robin)
1469
-   [Table engine Distributed](../../engines/table-engines/special/distributed.md)
1470
-   [distributed\_replica\_error\_cap](#settings-distributed_replica_error_cap)
1471
-   [distributed\_replica\_max\_ignored\_errors](#settings-distributed_replica_max_ignored_errors)
V
Vasily Nemkov 已提交
1472

1473
## distributed\_replica\_error\_cap {#settings-distributed_replica_error_cap}
V
Vasily Nemkov 已提交
1474

1475 1476
-   Type: unsigned int
-   Default value: 1000
V
Vasily Nemkov 已提交
1477

F
FeehanG 已提交
1478
Error count of each replica is capped at this value, preventing a single replica from accumulating too many errors.
V
Vasily Nemkov 已提交
1479

S
Fixes  
Sergei Bocharov 已提交
1480
See also:
V
Vasily Nemkov 已提交
1481

1482
-   [load\_balancing](#load_balancing-round_robin)
1483
-   [Table engine Distributed](../../engines/table-engines/special/distributed.md)
1484
-   [distributed\_replica\_error\_half\_life](#settings-distributed_replica_error_half_life)
1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499
-   [distributed\_replica\_max\_ignored\_errors](#settings-distributed_replica_max_ignored_errors)

## distributed\_replica\_max\_ignored\_errors {#settings-distributed_replica_max_ignored_errors}

-   Type: unsigned int
-   Default value: 0

Number of errors that will be ignored while choosing replicas (according to `load_balancing` algorithm).

See also:

-   [load\_balancing](#load_balancing-round_robin)
-   [Table engine Distributed](../../engines/table-engines/special/distributed.md)
-   [distributed\_replica\_error\_cap](#settings-distributed_replica_error_cap)
-   [distributed\_replica\_error\_half\_life](#settings-distributed_replica_error_half_life)
1500

1501
## distributed\_directory\_monitor\_sleep\_time\_ms {#distributed_directory_monitor_sleep_time_ms}
1502

1503
Base interval for the [Distributed](../../engines/table-engines/special/distributed.md) table engine to send data. The actual interval grows exponentially in the event of errors.
1504 1505 1506

Possible values:

1507
-   A positive integer number of milliseconds.
1508 1509 1510

Default value: 100 milliseconds.

1511
## distributed\_directory\_monitor\_max\_sleep\_time\_ms {#distributed_directory_monitor_max_sleep_time_ms}
1512

1513
Maximum interval for the [Distributed](../../engines/table-engines/special/distributed.md) table engine to send data. Limits exponential growth of the interval set in the [distributed\_directory\_monitor\_sleep\_time\_ms](#distributed_directory_monitor_sleep_time_ms) setting.
1514 1515 1516

Possible values:

1517
-   A positive integer number of milliseconds.
1518 1519 1520

Default value: 30000 milliseconds (30 seconds).

1521
## distributed\_directory\_monitor\_batch\_inserts {#distributed_directory_monitor_batch_inserts}
1522 1523 1524

Enables/disables sending of inserted data in batches.

1525
When batch sending is enabled, the [Distributed](../../engines/table-engines/special/distributed.md) table engine tries to send multiple files of inserted data in one operation instead of sending them separately. Batch sending improves cluster performance by better-utilizing server and network resources.
1526 1527 1528

Possible values:

1529 1530
-   1 — Enabled.
-   0 — Disabled.
1531

1532
Default value: 0.
1533

1534
## os\_thread\_priority {#setting-os-thread-priority}
1535

1536
Sets the priority ([nice](https://en.wikipedia.org/wiki/Nice_(Unix))) for threads that execute queries. The OS scheduler considers this priority when choosing the next thread to run on each available CPU core.
1537 1538

!!! warning "Warning"
1539
    To use this setting, you need to set the `CAP_SYS_NICE` capability. The `clickhouse-server` package sets it up during installation. Some virtual environments don’t allow you to set the `CAP_SYS_NICE` capability. In this case, `clickhouse-server` shows a message about it at the start.
1540 1541 1542

Possible values:

1543
-   You can set values in the range `[-20, 19]`.
1544

1545
Lower values mean higher priority. Threads with low `nice` priority values are executed more frequently than threads with high values. High values are preferable for long-running non-interactive queries because it allows them to quickly give up resources in favour of short interactive queries when they arrive.
1546 1547 1548

Default value: 0.

1549
## query\_profiler\_real\_time\_period\_ns {#query_profiler_real_time_period_ns}
1550

1551
Sets the period for a real clock timer of the [query profiler](../../operations/optimizing-performance/sampling-query-profiler.md). Real clock timer counts wall-clock time.
1552 1553 1554

Possible values:

1555
-   Positive integer number, in nanoseconds.
1556

1557
    Recommended values:
1558

1559 1560
            - 10000000 (100 times a second) nanoseconds and less for single queries.
            - 1000000000 (once a second) for cluster-wide profiling.
1561

1562
-   0 for turning off the timer.
1563

1564
Type: [UInt64](../../sql-reference/data-types/int-uint.md).
1565

1566
Default value: 1000000000 nanoseconds (once a second).
1567

S
Fixes  
Sergei Bocharov 已提交
1568
See also:
B
BayoNet 已提交
1569

1570
-   System table [trace\_log](../../operations/system-tables/trace_log.md#system_tables-trace_log)
1571

1572
## query\_profiler\_cpu\_time\_period\_ns {#query_profiler_cpu_time_period_ns}
1573

1574
Sets the period for a CPU clock timer of the [query profiler](../../operations/optimizing-performance/sampling-query-profiler.md). This timer counts only CPU time.
1575 1576 1577

Possible values:

1578
-   A positive integer number of nanoseconds.
1579

1580
    Recommended values:
1581

1582 1583
            - 10000000 (100 times a second) nanoseconds and more for single queries.
            - 1000000000 (once a second) for cluster-wide profiling.
1584

1585
-   0 for turning off the timer.
1586

1587
Type: [UInt64](../../sql-reference/data-types/int-uint.md).
1588 1589 1590

Default value: 1000000000 nanoseconds.

S
Fixes  
Sergei Bocharov 已提交
1591
See also:
B
BayoNet 已提交
1592

1593
-   System table [trace\_log](../../operations/system-tables/trace_log.md#system_tables-trace_log)
B
BayoNet 已提交
1594

1595
## allow\_introspection\_functions {#settings-allow_introspection_functions}
1596

1597
Enables or disables [introspections functions](../../sql-reference/functions/introspection.md) for query profiling.
1598 1599 1600

Possible values:

1601 1602
-   1 — Introspection functions enabled.
-   0 — Introspection functions disabled.
1603 1604 1605

Default value: 0.

1606 1607
**See Also**

1608 1609
-   [Sampling Query Profiler](../../operations/optimizing-performance/sampling-query-profiler.md)
-   System table [trace\_log](../../operations/system-tables/trace_log.md#system_tables-trace_log)
1610

1611
## input\_format\_parallel\_parsing {#input-format-parallel-parsing}
N
docs  
Nikita Mikhaylov 已提交
1612

1613 1614
-   Type: bool
-   Default value: True
N
docs  
Nikita Mikhaylov 已提交
1615

N
Nikita Mikhaylov 已提交
1616
Enable order-preserving parallel parsing of data formats. Supported only for TSV, TKSV, CSV and JSONEachRow formats.
N
docs  
Nikita Mikhaylov 已提交
1617

1618
## min\_chunk\_bytes\_for\_parallel\_parsing {#min-chunk-bytes-for-parallel-parsing}
N
docs  
Nikita Mikhaylov 已提交
1619

1620 1621
-   Type: unsigned int
-   Default value: 1 MiB
N
docs  
Nikita Mikhaylov 已提交
1622

A
Alexander Kuzmenkov 已提交
1623
The minimum chunk size in bytes, which each thread will parse in parallel.
1624

1625
## output\_format\_avro\_codec {#settings-output_format_avro_codec}
A
Andrew Onyshchuk 已提交
1626 1627 1628 1629 1630 1631 1632

Sets the compression codec used for output Avro file.

Type: string

Possible values:

1633 1634 1635
-   `null` — No compression
-   `deflate` — Compress with Deflate (zlib)
-   `snappy` — Compress with [Snappy](https://google.github.io/snappy/)
A
Andrew Onyshchuk 已提交
1636 1637 1638

Default value: `snappy` (if available) or `deflate`.

1639
## output\_format\_avro\_sync\_interval {#settings-output_format_avro_sync_interval}
A
Andrew Onyshchuk 已提交
1640 1641 1642 1643 1644 1645 1646 1647 1648

Sets minimum data size (in bytes) between synchronization markers for output Avro file.

Type: unsigned int

Possible values: 32 (32 bytes) - 1073741824 (1 GiB)

Default value: 32768 (32 KiB)

1649
## format\_avro\_schema\_registry\_url {#format_avro_schema_registry_url}
A
Andrew Onyshchuk 已提交
1650

1651
Sets [Confluent Schema Registry](https://docs.confluent.io/current/schema-registry/index.html) URL to use with [AvroConfluent](../../interfaces/formats.md#data-format-avro-confluent) format.
A
Andrew Onyshchuk 已提交
1652

1653
Default value: `Empty`.
A
Andrew Onyshchuk 已提交
1654

1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665
## input_format_avro_allow_missing_fields {#input_format_avro_allow_missing_fields}

Enables using fields that are not specified in [Avro](../../interfaces/formats.md#data-format-avro) or [AvroConfluent](../../interfaces/formats.md#data-format-avro-confluent) format schema. When a field is not found in the schema, ClickHouse uses the default value instead of throwing an exception.

Possible values:

-   0 — Disabled.
-   1 — Enabled.

Default value: 0.

1666
## background\_pool\_size {#background_pool_size}
1667

1668 1669
Sets the number of threads performing background operations in table engines (for example, merges in [MergeTree engine](../../engines/table-engines/mergetree-family/index.md) tables). This setting is applied from `default` profile at ClickHouse server start and can’t be changed in a user session. By adjusting this setting, you manage CPU and disk load. Smaller pool size utilizes less CPU and disk resources, but background processes advance slower which might eventually impact query performance.

A
alesapin 已提交
1670
Before changing it, please also take a look at related [MergeTree settings](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-merge_tree), such as `number_of_free_entries_in_pool_to_lower_max_size_of_merge` and `number_of_free_entries_in_pool_to_execute_mutation`.
1671 1672 1673 1674 1675 1676 1677

Possible values:

-   Any positive integer.

Default value: 16.

1678 1679
## parallel_distributed_insert_select {#parallel_distributed_insert_select}

1680
Enables parallel distributed `INSERT ... SELECT` query.
1681 1682 1683 1684 1685 1686

If we execute `INSERT INTO distributed_table_a SELECT ... FROM distributed_table_b` queries and both tables use the same cluster, and both tables are either [replicated](../../engines/table-engines/mergetree-family/replication.md) or non-replicated, then this query is processed locally on every shard.

Possible values:

-   0 — Disabled.
1687 1688
-   1 — `SELECT` will be executed on each shard from underlying table of the distributed engine.
-   2 — `SELECT` and `INSERT` will be executed on each shard from/to underlying table of the distributed engine.
1689 1690 1691

Default value: 0.

1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708
## insert_distributed_sync {#insert_distributed_sync}

Enables or disables synchronous data insertion into a [Distributed](../../engines/table-engines/special/distributed.md#distributed) table.

By default, when inserting data into a `Distributed` table, the ClickHouse server sends data to cluster nodes in asynchronous mode. When `insert_distributed_sync=1`, the data is processed synchronously, and the `INSERT` operation succeeds only after all the data is saved on all shards (at least one replica for each shard if `internal_replication` is true). 

Possible values:

-   0 — Data is inserted in asynchronous mode.
-   1 — Data is inserted in synchronous mode.

Default value: `0`.

**See Also**

-   [Distributed Table Engine](../../engines/table-engines/special/distributed.md#distributed)
-   [Managing Distributed Tables](../../sql-reference/statements/system.md#query-language-system-distributed)
1709
## background\_buffer\_flush\_schedule\_pool\_size {#background_buffer_flush_schedule_pool_size}
1710

1711
Sets the number of threads performing background flush in [Buffer](../../engines/table-engines/special/buffer.md)-engine tables. This setting is applied at ClickHouse server start and can’t be changed in a user session.
1712

1713 1714 1715 1716 1717 1718
Possible values:

-   Any positive integer.

Default value: 16.

1719
## background\_move\_pool\_size {#background_move_pool_size}
1720 1721 1722 1723 1724 1725 1726 1727 1728

Sets the number of threads performing background moves of data parts for [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md#table_engine-mergetree-multiple-volumes)-engine tables. This setting is applied at ClickHouse server start and can’t be changed in a user session.

Possible values:

-   Any positive integer.

Default value: 8.

1729
## background\_schedule\_pool\_size {#background_schedule_pool_size}
1730

1731
Sets the number of threads performing background tasks for [replicated](../../engines/table-engines/mergetree-family/replication.md) tables, [Kafka](../../engines/table-engines/integrations/kafka.md) streaming, [DNS cache updates](../../operations/server-configuration-parameters/settings.md#server-settings-dns-cache-update-period). This setting is applied at ClickHouse server start and can’t be changed in a user session.
1732 1733 1734 1735 1736 1737 1738

Possible values:

-   Any positive integer.

Default value: 16.

1739
## always\_fetch\_merged\_part {#always_fetch_merged_part}
1740

1741
Prohibits data parts merging in [Replicated\*MergeTree](../../engines/table-engines/mergetree-family/replication.md)-engine tables.
1742 1743 1744 1745 1746 1747

When merging is prohibited, the replica never merges parts and always downloads merged parts from other replicas. If there is no required data yet, the replica waits for it. CPU and disk load on the replica server decreases, but the network load on cluster increases. This setting can be useful on servers with relatively weak CPUs or slow disks, such as servers for backups storage.

Possible values:

-   0 — `Replicated*MergeTree`-engine tables merge data parts at the replica.
1748
-   1 — `Replicated*MergeTree`-engine tables don’t merge data parts at the replica. The tables download merged data parts from other replicas.
1749 1750 1751

Default value: 0.

1752
**See Also**
1753 1754 1755

-   [Data Replication](../../engines/table-engines/mergetree-family/replication.md)

1756
## background\_distributed\_schedule\_pool\_size {#background_distributed_schedule_pool_size}
1757 1758 1759 1760 1761 1762 1763

Sets the number of threads performing background tasks for [distributed](../../engines/table-engines/special/distributed.md) sends. This setting is applied at ClickHouse server start and can’t be changed in a user session.

Possible values:

-   Any positive integer.

1764 1765
Default value: 16.

1766 1767
## validate\_polygons {#validate_polygons}

1768
Enables or disables throwing an exception in the [pointInPolygon](../../sql-reference/functions/geo/index.md#pointinpolygon) function, if the polygon is self-intersecting or self-tangent.
1769 1770 1771 1772 1773 1774 1775 1776

Possible values:

- 0 — Throwing an exception is disabled. `pointInPolygon` accepts invalid polygons and returns possibly incorrect results for them.
- 1 — Throwing an exception is enabled.

Default value: 1.

1777
## transform\_null\_in {#transform_null_in}
B
BayoNet 已提交
1778 1779 1780

Enables equality of [NULL](../../sql-reference/syntax.md#null-literal) values for [IN](../../sql-reference/operators/in.md) operator.

1781
By default, `NULL` values can’t be compared because `NULL` means undefined value. Thus, comparison `expr = NULL` must always return `false`. With this setting `NULL = NULL` returns `true` for `IN` operator.
B
BayoNet 已提交
1782 1783 1784 1785 1786 1787 1788 1789

Possible values:

-   0 — Comparison of `NULL` values in `IN` operator returns `false`.
-   1 — Comparison of `NULL` values in `IN` operator returns `true`.

Default value: 0.

1790
**Example**
B
BayoNet 已提交
1791 1792 1793

Consider the `null_in` table:

1794
``` text
B
BayoNet 已提交
1795 1796 1797 1798 1799 1800 1801 1802 1803
┌──idx─┬─────i─┐
│    1 │     1 │
│    2 │  NULL │
│    3 │     3 │
└──────┴───────┘
```

Query:

1804
``` sql
B
BayoNet 已提交
1805 1806 1807 1808 1809
SELECT idx, i FROM null_in WHERE i IN (1, NULL) SETTINGS transform_null_in = 0;
```

Result:

1810
``` text
B
BayoNet 已提交
1811 1812 1813 1814 1815 1816 1817
┌──idx─┬────i─┐
│    1 │    1 │
└──────┴──────┘
```

Query:

1818
``` sql
B
BayoNet 已提交
1819 1820 1821 1822 1823
SELECT idx, i FROM null_in WHERE i IN (1, NULL) SETTINGS transform_null_in = 1;
```

Result:

1824
``` text
B
BayoNet 已提交
1825 1826 1827 1828 1829 1830
┌──idx─┬─────i─┐
│    1 │     1 │
│    2 │  NULL │
└──────┴───────┘
```

1831
**See Also**
B
BayoNet 已提交
1832 1833 1834

-   [NULL Processing in IN Operators](../../sql-reference/operators/in.md#in-null-processing)

1835
## low\_cardinality\_max\_dictionary\_size {#low_cardinality_max_dictionary_size}
B
BayoNet 已提交
1836

1837
Sets a maximum size in rows of a shared global dictionary for the [LowCardinality](../../sql-reference/data-types/lowcardinality.md) data type that can be written to a storage file system. This setting prevents issues with RAM in case of unlimited dictionary growth. All the data that can’t be encoded due to maximum dictionary size limitation ClickHouse writes in an ordinary method.
B
BayoNet 已提交
1838 1839 1840 1841 1842 1843 1844

Possible values:

-   Any positive integer.

Default value: 8192.

1845
## low\_cardinality\_use\_single\_dictionary\_for\_part {#low_cardinality_use_single_dictionary_for_part}
B
BayoNet 已提交
1846 1847 1848

Turns on or turns off using of single dictionary for the data part.

E
Evgeniia Sudarikova 已提交
1849
By default, the ClickHouse server monitors the size of dictionaries and if a dictionary overflows then the server starts to write the next one. To prohibit creating several dictionaries set `low_cardinality_use_single_dictionary_for_part = 1`.
B
BayoNet 已提交
1850 1851 1852

Possible values:

1853 1854
-   1 — Creating several dictionaries for the data part is prohibited.
-   0 — Creating several dictionaries for the data part is not prohibited.
B
BayoNet 已提交
1855 1856 1857

Default value: 0.

1858
## low\_cardinality\_allow\_in\_native\_format {#low_cardinality_allow_in_native_format}
B
BayoNet 已提交
1859 1860 1861 1862 1863

Allows or restricts using the [LowCardinality](../../sql-reference/data-types/lowcardinality.md) data type with the [Native](../../interfaces/formats.md#native) format.

If usage of `LowCardinality` is restricted, ClickHouse server converts `LowCardinality`-columns to ordinary ones for `SELECT` queries, and convert ordinary columns to `LowCardinality`-columns for `INSERT` queries.

1864
This setting is required mainly for third-party clients which don’t support `LowCardinality` data type.
B
BayoNet 已提交
1865 1866 1867

Possible values:

1868 1869
-   1 — Usage of `LowCardinality` is not restricted.
-   0 — Usage of `LowCardinality` is restricted.
B
BayoNet 已提交
1870 1871 1872

Default value: 1.

1873
## allow\_suspicious\_low\_cardinality\_types {#allow_suspicious_low_cardinality_types}
B
BayoNet 已提交
1874 1875 1876 1877 1878

Allows or restricts using [LowCardinality](../../sql-reference/data-types/lowcardinality.md) with data types with fixed size of 8 bytes or less: numeric data types and `FixedString(8_bytes_or_less)`.

For small fixed values using of `LowCardinality` is usually inefficient, because ClickHouse stores a numeric index for each row. As a result:

1879 1880 1881
-   Disk space usage can rise.
-   RAM consumption can be higher, depending on a dictionary size.
-   Some functions can work slower due to extra coding/encoding operations.
B
BayoNet 已提交
1882 1883 1884 1885 1886

Merge times in [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)-engine tables can grow due to all the reasons described above.

Possible values:

1887 1888
-   1 — Usage of `LowCardinality` is not restricted.
-   0 — Usage of `LowCardinality` is restricted.
B
BayoNet 已提交
1889 1890 1891

Default value: 0.

1892
## min\_insert\_block\_size\_rows\_for\_materialized\_views {#min-insert-block-size-rows-for-materialized-views}
E
Evgenia Sudarikova 已提交
1893

1894
Sets minimum number of rows in block which can be inserted into a table by an `INSERT` query. Smaller-sized blocks are squashed into bigger ones. This setting is applied only for blocks inserted into [materialized view](../../sql-reference/statements/create/view.md). By adjusting this setting, you control blocks squashing while pushing to materialized view and avoid excessive memory usage.
E
Evgenia Sudarikova 已提交
1895 1896 1897 1898 1899 1900 1901 1902 1903 1904

Possible values:

-   Any positive integer.
-   0 — Squashing disabled.

Default value: 1048576.

**See Also**

1905
-   [min\_insert\_block\_size\_rows](#min-insert-block-size-rows)
E
Evgenia Sudarikova 已提交
1906

1907
## min\_insert\_block\_size\_bytes\_for\_materialized\_views {#min-insert-block-size-bytes-for-materialized-views}
E
Evgenia Sudarikova 已提交
1908

1909
Sets minimum number of bytes in block which can be inserted into a table by an `INSERT` query. Smaller-sized blocks are squashed into bigger ones. This setting is applied only for blocks inserted into [materialized view](../../sql-reference/statements/create/view.md). By adjusting this setting, you control blocks squashing while pushing to materialized view and avoid excessive memory usage.
E
Evgenia Sudarikova 已提交
1910 1911 1912 1913 1914 1915 1916 1917 1918 1919

Possible values:

-   Any positive integer.
-   0 — Squashing disabled.

Default value: 268435456.

**See also**

1920
-   [min\_insert\_block\_size\_bytes](#min-insert-block-size-bytes)
E
Evgenia Sudarikova 已提交
1921

1922
## output\_format\_pretty\_grid\_charset {#output-format-pretty-grid-charset}
1923 1924 1925

Allows to change a charset which is used for printing grids borders. Available charsets are following: UTF-8, ASCII.

1926
**Example**
1927

1928
``` text
1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940
SET output_format_pretty_grid_charset = 'UTF-8';
SELECT * FROM a;
┌─a─┐
│ 1 │
└───┘

SET output_format_pretty_grid_charset = 'ASCII';
SELECT * FROM a;
+-a-+
| 1 |
+---+
```
1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954
## optimize_read_in_order {#optimize_read_in_order}

Enables [ORDER BY](../../sql-reference/statements/select/order-by.md#optimize_read_in_order) optimization in [SELECT](../../sql-reference/statements/select/index.md) queries for reading data from [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) tables.

Possible values:

-   0 — `ORDER BY` optimization is disabled. 
-   1 — `ORDER BY` optimization is enabled. 

Default value: `1`.

**See Also**

-   [ORDER BY Clause](../../sql-reference/statements/select/order-by.md#optimize_read_in_order)
1955

1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972
## mutations_sync {#mutations_sync}

Allows to execute `ALTER TABLE ... UPDATE|DELETE` queries ([mutations](../../sql-reference/statements/alter/index.md#mutations)) synchronously.

Possible values:

-   0 - Mutations execute asynchronously. 
-   1 - The query waits for all mutations to complete on the current server. 
-   2 - The query waits for all mutations to complete on all replicas (if they exist).

Default value: `0`.

**See Also**

-   [Synchronicity of ALTER Queries](../../sql-reference/statements/alter/index.md#synchronicity-of-alter-queries)
-   [Mutations](../../sql-reference/statements/alter/index.md#mutations)

1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994
## ttl_only_drop_parts {#ttl_only_drop_parts}

Enables or disables complete dropping of data parts where all rows are expired in [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md) tables. 

When `ttl_only_drop_parts` is disabled (by default), the ClickHouse server only deletes expired rows according to their TTL. 

When `ttl_only_drop_parts` is enabled, the ClickHouse server drops a whole part when all rows in it are expired. 

Dropping whole parts instead of partial cleaning TTL-d rows allows to have shorter `merge_with_ttl_timeout` times and lower impact on system performance.

Possible values:

-   0 — Complete dropping of data parts is disabled.
-   1 — Complete dropping of data parts is enabled.

Default value: `0`.

**See Also** 

-   [CREATE TABLE query clauses and settings](../../engines/table-engines/mergetree-family/mergetree.md#mergetree-query-clauses) (`merge_with_ttl_timeout` setting)
-   [Table TTL](../../engines/table-engines/mergetree-family/mergetree.md#mergetree-table-ttl)

1995 1996 1997 1998
## lock_acquire_timeout {#lock_acquire_timeout}

Defines how many seconds locking request waits before failing. 

1999
Locking timeout is used to protect from deadlocks while executing read/write operations with tables. When timeout expires and locking request fails, the ClickHouse server throws an exeption "Locking attempt timed out! Possible deadlock avoided. Client should retry." with error code `DEADLOCK_AVOIDED`.
2000 2001 2002

Possible values:

2003
-   Positive integer (in seconds).
2004 2005
-   0 — No locking timeout.

2006
Default value: `120` seconds.
2007

2008 2009
## output_format_pretty_max_value_width {#output_format_pretty_max_value_width}

2010
Limits the width of value displayed in [Pretty](../../interfaces/formats.md#pretty) formats. If the value width exceeds the limit, the value is cut. 
2011 2012 2013

Possible values:

O
Olga Revyakina 已提交
2014
-   Positive integer. 
2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057
-   0 — The value is cut completely.

Default value: `10000` symbols.

**Examples**

Query:
```sql
SET output_format_pretty_max_value_width = 10;
SELECT range(number) FROM system.numbers LIMIT 10 FORMAT PrettyCompactNoEscapes;
```
Result:
```text
┌─range(number)─┐
│ []            │
│ [0]           │
│ [0,1]         │
│ [0,1,2]       │
│ [0,1,2,3]     │
│ [0,1,2,3,4⋯   │
│ [0,1,2,3,4⋯   │
│ [0,1,2,3,4⋯   │
│ [0,1,2,3,4⋯   │
│ [0,1,2,3,4⋯   │
└───────────────┘
```

Query with zero width:
```sql
SET output_format_pretty_max_value_width = 0;
SELECT range(number) FROM system.numbers LIMIT 5 FORMAT PrettyCompactNoEscapes;
```
Result:
```text
┌─range(number)─┐
│ ⋯             │
│ ⋯             │
│ ⋯             │
│ ⋯             │
│ ⋯             │
└───────────────┘
```

I
Ivan Blinkov 已提交
2058
[Original article](https://clickhouse.tech/docs/en/operations/settings/settings/) <!-- hide -->
2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069

## allow_experimental_bigint_types {#allow_experimental_bigint_types}

Enables or disables integer values exceeding the range that is supported by the int data type.

Possible values:

-   1 — The bigint data type is enabled.
-   0 — The bigint data type is disabled.

Default value: `0`.