forked from ClickHouse/ClickHouse
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSettings.cpp
6492 lines (5361 loc) · 313 KB
/
Settings.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
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
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <Columns/ColumnMap.h>
#include <Core/BaseSettings.h>
#include <Core/BaseSettingsFwdMacrosImpl.h>
#include <Core/BaseSettingsProgramOptions.h>
#include <Core/DistributedCacheProtocol.h>
#include <Core/FormatFactorySettings.h>
#include <Core/Settings.h>
#include <Core/SettingsChangesHistory.h>
#include <Core/SettingsEnums.h>
#include <Core/SettingsFields.h>
#include <IO/ReadBufferFromString.h>
#include <IO/S3Defines.h>
#include <Storages/System/MutableColumnsAndConstraints.h>
#include <base/types.h>
#include <Common/NamePrompter.h>
#include <Common/typeid_cast.h>
#include <boost/program_options.hpp>
#include <Poco/Util/AbstractConfiguration.h>
#include <Poco/Util/Application.h>
#include <cstring>
namespace DB
{
namespace ErrorCodes
{
extern const int THERE_IS_NO_PROFILE;
extern const int NO_ELEMENTS_IN_CONFIG;
extern const int UNKNOWN_ELEMENT_IN_CONFIG;
extern const int BAD_ARGUMENTS;
}
/** List of settings: type, name, default value, description, flags
*
* This looks rather inconvenient. It is done that way to avoid repeating settings in different places.
* Note: as an alternative, we could implement settings to be completely dynamic in the form of the map: String -> Field,
* but we are not going to do it, because settings are used everywhere as static struct fields.
*
* `flags` can include a Tier (BETA | EXPERIMENTAL) and an optional bitwise AND with IMPORTANT.
* The default (0) means a PRODUCTION ready setting
*
* A setting is "IMPORTANT" if it affects the results of queries and can't be ignored by older versions.
* Tiers:
* EXPERIMENTAL: The feature is in active development stage. Mostly for developers or for ClickHouse enthusiasts.
* BETA: There are no known bugs problems in the functionality, but the outcome of using it together with other
* features/components is unknown and correctness is not guaranteed.
* PRODUCTION (Default): The feature is safe to use along with other features from the PRODUCTION tier.
*
* When adding new or changing existing settings add them to the settings changes history in SettingsChangesHistory.cpp
* for tracking settings changes in different versions and for special `compatibility` settings to work correctly.
*/
// clang-format off
#if defined(__CLION_IDE__)
/// CLion freezes for a minute every time it processes this
#define COMMON_SETTINGS(DECLARE, ALIAS)
#define OBSOLETE_SETTINGS(DECLARE, ALIAS)
#else
#define COMMON_SETTINGS(DECLARE, ALIAS) \
DECLARE(Dialect, dialect, Dialect::clickhouse, R"(
Which dialect will be used to parse query
)", 0)\
DECLARE(UInt64, min_compress_block_size, 65536, R"(
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.
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.
Let’s look at an example. Assume that `index_granularity` was set to 8192 during table creation.
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.
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.
:::note
This is an expert-level setting, and you shouldn't change it if you're just getting started with ClickHouse.
:::
)", 0) \
DECLARE(UInt64, max_compress_block_size, 1048576, R"(
The maximum size of blocks of uncompressed data before compressing for writing to a table. By default, 1,048,576 (1 MiB). Specifying a smaller block size generally leads to slightly reduced compression ratio, the compression and decompression speed increases slightly due to cache locality, and memory consumption is reduced.
:::note
This is an expert-level setting, and you shouldn't change it if you're just getting started with ClickHouse.
:::
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).
)", 0) \
DECLARE(UInt64, max_block_size, DEFAULT_BLOCK_SIZE, R"(
In ClickHouse, data is processed by blocks, which are sets of column parts. The internal processing cycles for a single block are efficient but there are noticeable costs when processing each block.
The `max_block_size` setting indicates the recommended maximum number of rows to include in a single block when loading data from tables. Blocks the size of `max_block_size` are not always loaded from the table: if ClickHouse determines that less data needs to be retrieved, a smaller block is processed.
The block size should not be too small to avoid noticeable costs when processing each block. It should also not be too large to ensure that queries with a LIMIT clause execute quickly after processing the first block. When setting `max_block_size`, the goal should be to avoid consuming too much memory when extracting a large number of columns in multiple threads and to preserve at least some cache locality.
)", 0) \
DECLARE(UInt64, max_insert_block_size, DEFAULT_INSERT_BLOCK_SIZE, R"(
The size of blocks (in a count of rows) to form for insertion into a table.
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.
But when using clickhouse-client, the client parses the data itself, and the ‘max_insert_block_size’ setting on the server does not affect the size of the inserted blocks.
The setting also does not have a purpose when using INSERT SELECT, since data is inserted using the same blocks that are formed after SELECT.
The default is slightly more than `max_block_size`. The reason for this is that 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.
)", 0) \
DECLARE(UInt64, min_insert_block_size_rows, DEFAULT_INSERT_BLOCK_SIZE, R"(
Sets the minimum number of rows in the block that can be inserted into a table by an `INSERT` query. Smaller-sized blocks are squashed into bigger ones.
Possible values:
- Positive integer.
- 0 — Squashing disabled.
)", 0) \
DECLARE(UInt64, min_insert_block_size_bytes, (DEFAULT_INSERT_BLOCK_SIZE * 256), R"(
Sets the minimum number of bytes in the block which can be inserted into a table by an `INSERT` query. Smaller-sized blocks are squashed into bigger ones.
Possible values:
- Positive integer.
- 0 — Squashing disabled.
)", 0) \
DECLARE(UInt64, min_insert_block_size_rows_for_materialized_views, 0, R"(
Sets the minimum number of rows in the 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.
Possible values:
- Any positive integer.
- 0 — Squashing disabled.
**See Also**
- [min_insert_block_size_rows](#min-insert-block-size-rows)
)", 0) \
DECLARE(UInt64, min_insert_block_size_bytes_for_materialized_views, 0, R"(
Sets the minimum number of bytes in the 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.
Possible values:
- Any positive integer.
- 0 — Squashing disabled.
**See also**
- [min_insert_block_size_bytes](#min-insert-block-size-bytes)
)", 0) \
DECLARE(UInt64, min_external_table_block_size_rows, DEFAULT_INSERT_BLOCK_SIZE, R"(
Squash blocks passed to external table to specified size in rows, if blocks are not big enough.
)", 0) \
DECLARE(UInt64, min_external_table_block_size_bytes, (DEFAULT_INSERT_BLOCK_SIZE * 256), R"(
Squash blocks passed to the external table to a specified size in bytes, if blocks are not big enough.
)", 0) \
DECLARE(UInt64, max_joined_block_size_rows, DEFAULT_BLOCK_SIZE, R"(
Maximum block size for JOIN result (if join algorithm supports it). 0 means unlimited.
)", 0) \
DECLARE(UInt64, min_joined_block_size_bytes, 524288, R"(
Minimum block size for JOIN result (if join algorithm supports it). 0 means unlimited.
)", 0) \
DECLARE(UInt64, max_insert_threads, 0, R"(
The maximum number of threads to execute the `INSERT SELECT` query.
Possible values:
- 0 (or 1) — `INSERT SELECT` no parallel execution.
- Positive integer. Bigger than 1.
Cloud default value: from `2` to `4`, depending on the service size.
Parallel `INSERT SELECT` has effect only if the `SELECT` part is executed in parallel, see [max_threads](#max_threads) setting.
Higher values will lead to higher memory usage.
)", 0) \
DECLARE(UInt64, max_insert_delayed_streams_for_parallel_write, 0, R"(
The maximum number of streams (columns) to delay final part flush. Default - auto (1000 in case of underlying storage supports parallel write, for example S3 and disabled otherwise)
)", 0) \
DECLARE(MaxThreads, max_final_threads, 0, R"(
Sets the maximum number of parallel threads for the `SELECT` query data read phase with the [FINAL](../../sql-reference/statements/select/from.md#select-from-final) modifier.
Possible values:
- Positive integer.
- 0 or 1 — Disabled. `SELECT` queries are executed in a single thread.
)", 0) \
DECLARE(UInt64, max_threads_for_indexes, 0, R"(
The maximum number of threads process indices.
)", 0) \
DECLARE(MaxThreads, max_threads, 0, R"(
The maximum number of query processing threads, excluding threads for retrieving data from remote servers (see the ‘max_distributed_connections’ parameter).
This parameter applies to threads that perform the same stages of the query processing pipeline in parallel.
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.
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.
The smaller the `max_threads` value, the less memory is consumed.
)", 0) \
DECLARE(Bool, use_concurrency_control, true, R"(
Respect the server's concurrency control (see the `concurrent_threads_soft_limit_num` and `concurrent_threads_soft_limit_ratio_to_cores` global server settings). If disabled, it allows using a larger number of threads even if the server is overloaded (not recommended for normal usage, and needed mostly for tests).
)", 0) \
DECLARE(MaxThreads, max_download_threads, 4, R"(
The maximum number of threads to download data (e.g. for URL engine).
)", 0) \
DECLARE(MaxThreads, max_parsing_threads, 0, R"(
The maximum number of threads to parse data in input formats that support parallel parsing. By default, it is determined automatically
)", 0) \
DECLARE(UInt64, max_download_buffer_size, 10*1024*1024, R"(
The maximal size of buffer for parallel downloading (e.g. for URL engine) per each thread.
)", 0) \
DECLARE(UInt64, max_read_buffer_size, DBMS_DEFAULT_BUFFER_SIZE, R"(
The maximum size of the buffer to read from the filesystem.
)", 0) \
DECLARE(UInt64, max_read_buffer_size_local_fs, 128*1024, R"(
The maximum size of the buffer to read from local filesystem. If set to 0 then max_read_buffer_size will be used.
)", 0) \
DECLARE(UInt64, max_read_buffer_size_remote_fs, 0, R"(
The maximum size of the buffer to read from remote filesystem. If set to 0 then max_read_buffer_size will be used.
)", 0) \
DECLARE(UInt64, max_distributed_connections, 1024, R"(
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.
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.
)", 0) \
DECLARE(UInt64, max_query_size, DBMS_DEFAULT_MAX_QUERY_SIZE, R"(
The maximum number of bytes of a query string parsed by the SQL parser.
Data in the VALUES clause of INSERT queries is processed by a separate stream parser (that consumes O(1) RAM) and not affected by this restriction.
:::note
`max_query_size` cannot be set within an SQL query (e.g., `SELECT now() SETTINGS max_query_size=10000`) because ClickHouse needs to allocate a buffer to parse the query, and this buffer size is determined by the `max_query_size` setting, which must be configured before the query is executed.
:::
)", 0) \
DECLARE(UInt64, interactive_delay, 100000, R"(
The interval in microseconds for checking whether request execution has been canceled and sending the progress.
)", 0) \
DECLARE(Seconds, connect_timeout, DBMS_DEFAULT_CONNECT_TIMEOUT_SEC, R"(
Connection timeout if there are no replicas.
)", 0) \
DECLARE(Milliseconds, handshake_timeout_ms, 10000, R"(
Timeout in milliseconds for receiving Hello packet from replicas during handshake.
)", 0) \
DECLARE(Milliseconds, connect_timeout_with_failover_ms, 1000, R"(
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.
If unsuccessful, several attempts are made to connect to various replicas.
)", 0) \
DECLARE(Milliseconds, connect_timeout_with_failover_secure_ms, 1000, R"(
Connection timeout for selecting first healthy replica (for secure connections).
)", 0) \
DECLARE(Seconds, receive_timeout, DBMS_DEFAULT_RECEIVE_TIMEOUT_SEC, R"(
Timeout for receiving data from the network, in seconds. If no bytes were received in this interval, the exception is thrown. If you set this setting on the client, the 'send_timeout' for the socket will also be set on the corresponding connection end on the server.
)", 0) \
DECLARE(Seconds, send_timeout, DBMS_DEFAULT_SEND_TIMEOUT_SEC, R"(
Timeout for sending data to the network, in seconds. If a client needs to send some data but is not able to send any bytes in this interval, the exception is thrown. If you set this setting on the client, the 'receive_timeout' for the socket will also be set on the corresponding connection end on the server.
)", 0) \
DECLARE(Seconds, tcp_keep_alive_timeout, DEFAULT_TCP_KEEP_ALIVE_TIMEOUT /* less than DBMS_DEFAULT_RECEIVE_TIMEOUT_SEC */, R"(
The time in seconds the connection needs to remain idle before TCP starts sending keepalive probes
)", 0) \
DECLARE(Milliseconds, hedged_connection_timeout_ms, 50, R"(
Connection timeout for establishing connection with replica for Hedged requests
)", 0) \
DECLARE(Milliseconds, receive_data_timeout_ms, 2000, R"(
Connection timeout for receiving first packet of data or packet with positive progress from replica
)", 0) \
DECLARE(Bool, use_hedged_requests, true, R"(
Enables hedged requests logic for remote queries. It allows to establish many connections with different replicas for query.
New connection is enabled in case existent connection(s) with replica(s) were not established within `hedged_connection_timeout`
or no data was received within `receive_data_timeout`. Query uses the first connection which send non empty progress packet (or data packet, if `allow_changing_replica_until_first_data_packet`);
other connections are cancelled. Queries with `max_parallel_replicas > 1` are supported.
Enabled by default.
Disabled by default on Cloud.
)", 0) \
DECLARE(Bool, allow_changing_replica_until_first_data_packet, false, R"(
If it's enabled, in hedged requests we can start new connection until receiving first data packet even if we have already made some progress
(but progress haven't updated for `receive_data_timeout` timeout), otherwise we disable changing replica after the first time we made progress.
)", 0) \
DECLARE(Milliseconds, queue_max_wait_ms, 0, R"(
The wait time in the request queue, if the number of concurrent requests exceeds the maximum.
)", 0) \
DECLARE(Milliseconds, connection_pool_max_wait_ms, 0, R"(
The wait time in milliseconds for a connection when the connection pool is full.
Possible values:
- Positive integer.
- 0 — Infinite timeout.
)", 0) \
DECLARE(Milliseconds, replace_running_query_max_wait_ms, 5000, R"(
The wait time for running the 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`.
)", 0) \
DECLARE(Milliseconds, kafka_max_wait_ms, 5000, R"(
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.
See also:
- [Apache Kafka](https://kafka.apache.org/)
)", 0) \
DECLARE(Milliseconds, rabbitmq_max_wait_ms, 5000, R"(
The wait time for reading from RabbitMQ before retry.
)", 0) \
DECLARE(UInt64, poll_interval, DBMS_DEFAULT_POLL_INTERVAL, R"(
Block at the query wait loop on the server for the specified number of seconds.
)", 0) \
DECLARE(UInt64, idle_connection_timeout, 3600, R"(
Timeout to close idle TCP connections after specified number of seconds.
Possible values:
- Positive integer (0 - close immediately, after 0 seconds).
)", 0) \
DECLARE(UInt64, distributed_connections_pool_size, 1024, R"(
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.
)", 0) \
DECLARE(UInt64, connections_with_failover_max_tries, 3, R"(
The maximum number of connection attempts with each replica for the Distributed table engine.
)", 0) \
DECLARE(UInt64, s3_strict_upload_part_size, S3::DEFAULT_STRICT_UPLOAD_PART_SIZE, R"(
The exact size of part to upload during multipart upload to S3 (some implementations does not supports variable size parts).
)", 0) \
DECLARE(UInt64, azure_strict_upload_part_size, 0, R"(
The exact size of part to upload during multipart upload to Azure blob storage.
)", 0) \
DECLARE(UInt64, azure_max_blocks_in_multipart_upload, 50000, R"(
Maximum number of blocks in multipart upload for Azure.
)", 0) \
DECLARE(UInt64, s3_min_upload_part_size, S3::DEFAULT_MIN_UPLOAD_PART_SIZE, R"(
The minimum size of part to upload during multipart upload to S3.
)", 0) \
DECLARE(UInt64, s3_max_upload_part_size, S3::DEFAULT_MAX_UPLOAD_PART_SIZE, R"(
The maximum size of part to upload during multipart upload to S3.
)", 0) \
DECLARE(UInt64, azure_min_upload_part_size, 16*1024*1024, R"(
The minimum size of part to upload during multipart upload to Azure blob storage.
)", 0) \
DECLARE(UInt64, azure_max_upload_part_size, 5ull*1024*1024*1024, R"(
The maximum size of part to upload during multipart upload to Azure blob storage.
)", 0) \
DECLARE(UInt64, s3_upload_part_size_multiply_factor, S3::DEFAULT_UPLOAD_PART_SIZE_MULTIPLY_FACTOR, R"(
Multiply s3_min_upload_part_size by this factor each time s3_multiply_parts_count_threshold parts were uploaded from a single write to S3.
)", 0) \
DECLARE(UInt64, s3_upload_part_size_multiply_parts_count_threshold, S3::DEFAULT_UPLOAD_PART_SIZE_MULTIPLY_PARTS_COUNT_THRESHOLD, R"(
Each time this number of parts was uploaded to S3, s3_min_upload_part_size is multiplied by s3_upload_part_size_multiply_factor.
)", 0) \
DECLARE(UInt64, s3_max_part_number, S3::DEFAULT_MAX_PART_NUMBER, R"(
Maximum part number number for s3 upload part.
)", 0) \
DECLARE(UInt64, s3_max_single_operation_copy_size, S3::DEFAULT_MAX_SINGLE_OPERATION_COPY_SIZE, R"(
Maximum size for a single copy operation in s3
)", 0) \
DECLARE(UInt64, azure_upload_part_size_multiply_factor, 2, R"(
Multiply azure_min_upload_part_size by this factor each time azure_multiply_parts_count_threshold parts were uploaded from a single write to Azure blob storage.
)", 0) \
DECLARE(UInt64, azure_upload_part_size_multiply_parts_count_threshold, 500, R"(
Each time this number of parts was uploaded to Azure blob storage, azure_min_upload_part_size is multiplied by azure_upload_part_size_multiply_factor.
)", 0) \
DECLARE(UInt64, s3_max_inflight_parts_for_one_file, S3::DEFAULT_MAX_INFLIGHT_PARTS_FOR_ONE_FILE, R"(
The maximum number of a concurrent loaded parts in multipart upload request. 0 means unlimited.
)", 0) \
DECLARE(UInt64, azure_max_inflight_parts_for_one_file, 20, R"(
The maximum number of a concurrent loaded parts in multipart upload request. 0 means unlimited.
)", 0) \
DECLARE(UInt64, s3_max_single_part_upload_size, S3::DEFAULT_MAX_SINGLE_PART_UPLOAD_SIZE, R"(
The maximum size of object to upload using singlepart upload to S3.
)", 0) \
DECLARE(UInt64, azure_max_single_part_upload_size, 100*1024*1024, R"(
The maximum size of object to upload using singlepart upload to Azure blob storage.
)", 0) \
DECLARE(UInt64, azure_max_single_part_copy_size, 256*1024*1024, R"(
The maximum size of object to copy using single part copy to Azure blob storage.
)", 0) \
DECLARE(UInt64, s3_max_single_read_retries, S3::DEFAULT_MAX_SINGLE_READ_TRIES, R"(
The maximum number of retries during single S3 read.
)", 0) \
DECLARE(UInt64, azure_max_single_read_retries, 4, R"(
The maximum number of retries during single Azure blob storage read.
)", 0) \
DECLARE(UInt64, azure_max_unexpected_write_error_retries, 4, R"(
The maximum number of retries in case of unexpected errors during Azure blob storage write
)", 0) \
DECLARE(UInt64, s3_max_unexpected_write_error_retries, S3::DEFAULT_MAX_UNEXPECTED_WRITE_ERROR_RETRIES, R"(
The maximum number of retries in case of unexpected errors during S3 write.
)", 0) \
DECLARE(UInt64, s3_max_redirects, S3::DEFAULT_MAX_REDIRECTS, R"(
Max number of S3 redirects hops allowed.
)", 0) \
DECLARE(UInt64, s3_max_connections, S3::DEFAULT_MAX_CONNECTIONS, R"(
The maximum number of connections per server.
)", 0) \
DECLARE(UInt64, s3_max_get_rps, 0, R"(
Limit on S3 GET request per second rate before throttling. Zero means unlimited.
)", 0) \
DECLARE(UInt64, s3_max_get_burst, 0, R"(
Max number of requests that can be issued simultaneously before hitting request per second limit. By default (0) equals to `s3_max_get_rps`
)", 0) \
DECLARE(UInt64, s3_max_put_rps, 0, R"(
Limit on S3 PUT request per second rate before throttling. Zero means unlimited.
)", 0) \
DECLARE(UInt64, s3_max_put_burst, 0, R"(
Max number of requests that can be issued simultaneously before hitting request per second limit. By default (0) equals to `s3_max_put_rps`
)", 0) \
DECLARE(UInt64, s3_list_object_keys_size, S3::DEFAULT_LIST_OBJECT_KEYS_SIZE, R"(
Maximum number of files that could be returned in batch by ListObject request
)", 0) \
DECLARE(Bool, s3_use_adaptive_timeouts, S3::DEFAULT_USE_ADAPTIVE_TIMEOUTS, R"(
When set to `true` than for all s3 requests first two attempts are made with low send and receive timeouts.
When set to `false` than all attempts are made with identical timeouts.
)", 0) \
DECLARE(UInt64, azure_list_object_keys_size, 1000, R"(
Maximum number of files that could be returned in batch by ListObject request
)", 0) \
DECLARE(Bool, s3_truncate_on_insert, false, R"(
Enables or disables truncate before inserts in s3 engine tables. If disabled, an exception will be thrown on insert attempts if an S3 object already exists.
Possible values:
- 0 — `INSERT` query appends new data to the end of the file.
- 1 — `INSERT` query replaces existing content of the file with the new data.
)", 0) \
DECLARE(Bool, azure_truncate_on_insert, false, R"(
Enables or disables truncate before insert in azure engine tables.
)", 0) \
DECLARE(Bool, s3_create_new_file_on_insert, false, R"(
Enables or disables creating a new file on each insert in s3 engine tables. If enabled, on each insert a new S3 object will be created with the key, similar to this pattern:
initial: `data.Parquet.gz` -> `data.1.Parquet.gz` -> `data.2.Parquet.gz`, etc.
Possible values:
- 0 — `INSERT` query appends new data to the end of the file.
- 1 — `INSERT` query creates a new file.
)", 0) \
DECLARE(Bool, s3_skip_empty_files, true, R"(
Enables or disables skipping empty files in [S3](../../engines/table-engines/integrations/s3.md) engine tables.
Possible values:
- 0 — `SELECT` throws an exception if empty file is not compatible with requested format.
- 1 — `SELECT` returns empty result for empty file.
)", 0) \
DECLARE(Bool, azure_create_new_file_on_insert, false, R"(
Enables or disables creating a new file on each insert in azure engine tables
)", 0) \
DECLARE(Bool, s3_check_objects_after_upload, false, R"(
Check each uploaded object to s3 with head request to be sure that upload was successful
)", 0) \
DECLARE(Bool, azure_check_objects_after_upload, false, R"(
Check each uploaded object in azure blob storage to be sure that upload was successful
)", 0) \
DECLARE(Bool, s3_allow_parallel_part_upload, true, R"(
Use multiple threads for s3 multipart upload. It may lead to slightly higher memory usage
)", 0) \
DECLARE(Bool, azure_allow_parallel_part_upload, true, R"(
Use multiple threads for azure multipart upload.
)", 0) \
DECLARE(Bool, s3_throw_on_zero_files_match, false, R"(
Throw an error, when ListObjects request cannot match any files
)", 0) \
DECLARE(Bool, hdfs_throw_on_zero_files_match, false, R"(
Throw an error if matched zero files according to glob expansion rules.
Possible values:
- 1 — `SELECT` throws an exception.
- 0 — `SELECT` returns empty result.
)", 0) \
DECLARE(Bool, azure_throw_on_zero_files_match, false, R"(
Throw an error if matched zero files according to glob expansion rules.
Possible values:
- 1 — `SELECT` throws an exception.
- 0 — `SELECT` returns empty result.
)", 0) \
DECLARE(Bool, s3_ignore_file_doesnt_exist, false, R"(
Ignore absence of file if it does not exist when reading certain keys.
Possible values:
- 1 — `SELECT` returns empty result.
- 0 — `SELECT` throws an exception.
)", 0) \
DECLARE(Bool, hdfs_ignore_file_doesnt_exist, false, R"(
Ignore absence of file if it does not exist when reading certain keys.
Possible values:
- 1 — `SELECT` returns empty result.
- 0 — `SELECT` throws an exception.
)", 0) \
DECLARE(Bool, azure_ignore_file_doesnt_exist, false, R"(
Ignore absence of file if it does not exist when reading certain keys.
Possible values:
- 1 — `SELECT` returns empty result.
- 0 — `SELECT` throws an exception.
)", 0) \
DECLARE(UInt64, azure_sdk_max_retries, 10, R"(
Maximum number of retries in azure sdk
)", 0) \
DECLARE(UInt64, azure_sdk_retry_initial_backoff_ms, 10, R"(
Minimal backoff between retries in azure sdk
)", 0) \
DECLARE(UInt64, azure_sdk_retry_max_backoff_ms, 1000, R"(
Maximal backoff between retries in azure sdk
)", 0) \
DECLARE(Bool, s3_validate_request_settings, true, R"(
Enables s3 request settings validation.
Possible values:
- 1 — validate settings.
- 0 — do not validate settings.
)", 0) \
DECLARE(Bool, s3_disable_checksum, S3::DEFAULT_DISABLE_CHECKSUM, R"(
Do not calculate a checksum when sending a file to S3. This speeds up writes by avoiding excessive processing passes on a file. It is mostly safe as the data of MergeTree tables is checksummed by ClickHouse anyway, and when S3 is accessed with HTTPS, the TLS layer already provides integrity while transferring through the network. While additional checksums on S3 give defense in depth.
)", 0) \
DECLARE(UInt64, s3_retry_attempts, S3::DEFAULT_RETRY_ATTEMPTS, R"(
Setting for Aws::Client::RetryStrategy, Aws::Client does retries itself, 0 means no retries
)", 0) \
DECLARE(UInt64, s3_request_timeout_ms, S3::DEFAULT_REQUEST_TIMEOUT_MS, R"(
Idleness timeout for sending and receiving data to/from S3. Fail if a single TCP read or write call blocks for this long.
)", 0) \
DECLARE(UInt64, s3_connect_timeout_ms, S3::DEFAULT_CONNECT_TIMEOUT_MS, R"(
Connection timeout for host from s3 disks.
)", 0) \
DECLARE(Bool, enable_s3_requests_logging, false, R"(
Enable very explicit logging of S3 requests. Makes sense for debug only.
)", 0) \
DECLARE(String, s3queue_default_zookeeper_path, "/clickhouse/s3queue/", R"(
Default zookeeper path prefix for S3Queue engine
)", 0) \
DECLARE(Bool, s3queue_enable_logging_to_s3queue_log, false, R"(
Enable writing to system.s3queue_log. The value can be overwritten per table with table settings
)", 0) \
DECLARE(UInt64, hdfs_replication, 0, R"(
The actual number of replications can be specified when the hdfs file is created.
)", 0) \
DECLARE(Bool, hdfs_truncate_on_insert, false, R"(
Enables or disables truncation before an insert in hdfs engine tables. If disabled, an exception will be thrown on an attempt to insert if a file in HDFS already exists.
Possible values:
- 0 — `INSERT` query appends new data to the end of the file.
- 1 — `INSERT` query replaces existing content of the file with the new data.
)", 0) \
DECLARE(Bool, hdfs_create_new_file_on_insert, false, R"(
Enables or disables creating a new file on each insert in HDFS engine tables. If enabled, on each insert a new HDFS file will be created with the name, similar to this pattern:
initial: `data.Parquet.gz` -> `data.1.Parquet.gz` -> `data.2.Parquet.gz`, etc.
Possible values:
- 0 — `INSERT` query appends new data to the end of the file.
- 1 — `INSERT` query creates a new file.
)", 0) \
DECLARE(Bool, hdfs_skip_empty_files, false, R"(
Enables or disables skipping empty files in [HDFS](../../engines/table-engines/integrations/hdfs.md) engine tables.
Possible values:
- 0 — `SELECT` throws an exception if empty file is not compatible with requested format.
- 1 — `SELECT` returns empty result for empty file.
)", 0) \
DECLARE(Bool, azure_skip_empty_files, false, R"(
Enables or disables skipping empty files in S3 engine.
Possible values:
- 0 — `SELECT` throws an exception if empty file is not compatible with requested format.
- 1 — `SELECT` returns empty result for empty file.
)", 0) \
DECLARE(UInt64, hsts_max_age, 0, R"(
Expired time for HSTS. 0 means disable HSTS.
)", 0) \
DECLARE(Bool, extremes, false, R"(
Whether to count extreme values (the minimums and maximums in columns of a query result). Accepts 0 or 1. By default, 0 (disabled).
For more information, see the section “Extreme values”.
)", IMPORTANT) \
DECLARE(Bool, use_uncompressed_cache, false, R"(
Whether to use a cache of uncompressed blocks. Accepts 0 or 1. By default, 0 (disabled).
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.
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.
)", 0) \
DECLARE(Bool, replace_running_query, false, R"(
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.
`0` (default) – Throw an exception (do not allow the query to run if a query with the same ‘query_id’ is already running).
`1` – Cancel the old query and start running the new one.
Set this parameter 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.
)", 0) \
DECLARE(UInt64, max_remote_read_network_bandwidth, 0, R"(
The maximum speed of data exchange over the network in bytes per second for read.
)", 0) \
DECLARE(UInt64, max_remote_write_network_bandwidth, 0, R"(
The maximum speed of data exchange over the network in bytes per second for write.
)", 0) \
DECLARE(UInt64, max_local_read_bandwidth, 0, R"(
The maximum speed of local reads in bytes per second.
)", 0) \
DECLARE(UInt64, max_local_write_bandwidth, 0, R"(
The maximum speed of local writes in bytes per second.
)", 0) \
DECLARE(Bool, stream_like_engine_allow_direct_select, false, R"(
Allow direct SELECT query for Kafka, RabbitMQ, FileLog, Redis Streams, and NATS engines. In case there are attached materialized views, SELECT query is not allowed even if this setting is enabled.
)", 0) \
DECLARE(String, stream_like_engine_insert_queue, "", R"(
When stream-like engine reads from multiple queues, the user will need to select one queue to insert into when writing. Used by Redis Streams and NATS.
)", 0) \
DECLARE(Bool, dictionary_validate_primary_key_type, false, R"(
Validate primary key type for dictionaries. By default id type for simple layouts will be implicitly converted to UInt64.
)", 0) \
DECLARE(Bool, distributed_insert_skip_read_only_replicas, false, R"(
Enables skipping read-only replicas for INSERT queries into Distributed.
Possible values:
- 0 — INSERT was as usual, if it will go to read-only replica it will fail
- 1 — Initiator will skip read-only replicas before sending data to shards.
)", 0) \
DECLARE(Bool, distributed_foreground_insert, false, R"(
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 background mode. When `distributed_foreground_insert=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 background mode.
- 1 — Data is inserted in synchronous mode.
Cloud default value: `1`.
**See Also**
- [Distributed Table Engine](../../engines/table-engines/special/distributed.md/#distributed)
- [Managing Distributed Tables](../../sql-reference/statements/system.md/#query-language-system-distributed)
)", 0) ALIAS(insert_distributed_sync) \
DECLARE(UInt64, distributed_background_insert_timeout, 0, R"(
Timeout for insert query into distributed. Setting is used only with insert_distributed_sync enabled. Zero value means no timeout.
)", 0) ALIAS(insert_distributed_timeout) \
DECLARE(Milliseconds, distributed_background_insert_sleep_time_ms, 100, R"(
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.
Possible values:
- A positive integer number of milliseconds.
)", 0) ALIAS(distributed_directory_monitor_sleep_time_ms) \
DECLARE(Milliseconds, distributed_background_insert_max_sleep_time_ms, 30000, R"(
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_background_insert_sleep_time_ms](#distributed_background_insert_sleep_time_ms) setting.
Possible values:
- A positive integer number of milliseconds.
)", 0) ALIAS(distributed_directory_monitor_max_sleep_time_ms) \
\
DECLARE(Bool, distributed_background_insert_batch, false, R"(
Enables/disables inserted data sending in batches.
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.
Possible values:
- 1 — Enabled.
- 0 — Disabled.
)", 0) ALIAS(distributed_directory_monitor_batch_inserts) \
DECLARE(Bool, distributed_background_insert_split_batch_on_failure, false, R"(
Enables/disables splitting batches on failures.
Sometimes sending particular batch to the remote shard may fail, because of some complex pipeline after (i.e. `MATERIALIZED VIEW` with `GROUP BY`) due to `Memory limit exceeded` or similar errors. In this case, retrying will not help (and this will stuck distributed sends for the table) but sending files from that batch one by one may succeed INSERT.
So installing this setting to `1` will disable batching for such batches (i.e. temporary disables `distributed_background_insert_batch` for failed batches).
Possible values:
- 1 — Enabled.
- 0 — Disabled.
:::note
This setting also affects broken batches (that may appears because of abnormal server (machine) termination and no `fsync_after_insert`/`fsync_directories` for [Distributed](../../engines/table-engines/special/distributed.md) table engine).
:::
:::note
You should not rely on automatic batch splitting, since this may hurt performance.
:::
)", 0) ALIAS(distributed_directory_monitor_split_batch_on_failure) \
\
DECLARE(Bool, optimize_move_to_prewhere, true, R"(
Enables or disables automatic [PREWHERE](../../sql-reference/statements/select/prewhere.md) optimization in [SELECT](../../sql-reference/statements/select/index.md) queries.
Works only for [*MergeTree](../../engines/table-engines/mergetree-family/index.md) tables.
Possible values:
- 0 — Automatic `PREWHERE` optimization is disabled.
- 1 — Automatic `PREWHERE` optimization is enabled.
)", 0) \
DECLARE(Bool, optimize_move_to_prewhere_if_final, false, R"(
Enables or disables automatic [PREWHERE](../../sql-reference/statements/select/prewhere.md) optimization in [SELECT](../../sql-reference/statements/select/index.md) queries with [FINAL](../../sql-reference/statements/select/from.md#select-from-final) modifier.
Works only for [*MergeTree](../../engines/table-engines/mergetree-family/index.md) tables.
Possible values:
- 0 — Automatic `PREWHERE` optimization in `SELECT` queries with `FINAL` modifier is disabled.
- 1 — Automatic `PREWHERE` optimization in `SELECT` queries with `FINAL` modifier is enabled.
**See Also**
- [optimize_move_to_prewhere](#optimize_move_to_prewhere) setting
)", 0) \
DECLARE(Bool, move_all_conditions_to_prewhere, true, R"(
Move all viable conditions from WHERE to PREWHERE
)", 0) \
DECLARE(Bool, enable_multiple_prewhere_read_steps, true, R"(
Move more conditions from WHERE to PREWHERE and do reads from disk and filtering in multiple steps if there are multiple conditions combined with AND
)", 0) \
DECLARE(Bool, move_primary_key_columns_to_end_of_prewhere, true, R"(
Move PREWHERE conditions containing primary key columns to the end of AND chain. It is likely that these conditions are taken into account during primary key analysis and thus will not contribute a lot to PREWHERE filtering.
)", 0) \
DECLARE(Bool, allow_reorder_prewhere_conditions, true, R"(
When moving conditions from WHERE to PREWHERE, allow reordering them to optimize filtering
)", 0) \
\
DECLARE(UInt64, alter_sync, 1, R"(
Allows to set up waiting for actions to be executed on replicas by [ALTER](../../sql-reference/statements/alter/index.md), [OPTIMIZE](../../sql-reference/statements/optimize.md) or [TRUNCATE](../../sql-reference/statements/truncate.md) queries.
Possible values:
- 0 — Do not wait.
- 1 — Wait for own execution.
- 2 — Wait for everyone.
Cloud default value: `0`.
:::note
`alter_sync` is applicable to `Replicated` tables only, it does nothing to alters of not `Replicated` tables.
:::
)", 0) ALIAS(replication_alter_partitions_sync) \
DECLARE(Int64, replication_wait_for_inactive_replica_timeout, 120, R"(
Specifies how long (in seconds) to wait for inactive replicas to execute [ALTER](../../sql-reference/statements/alter/index.md), [OPTIMIZE](../../sql-reference/statements/optimize.md) or [TRUNCATE](../../sql-reference/statements/truncate.md) queries.
Possible values:
- 0 — Do not wait.
- Negative integer — Wait for unlimited time.
- Positive integer — The number of seconds to wait.
)", 0) \
DECLARE(Bool, alter_move_to_space_execute_async, false, R"(
Execute ALTER TABLE MOVE ... TO [DISK|VOLUME] asynchronously
)", 0) \
\
DECLARE(LoadBalancing, load_balancing, LoadBalancing::RANDOM, R"(
Specifies the algorithm of replicas selection that is used for distributed query processing.
ClickHouse supports the following algorithms of choosing replicas:
- [Random](#load_balancing-random) (by default)
- [Nearest hostname](#load_balancing-nearest_hostname)
- [Hostname levenshtein distance](#load_balancing-hostname_levenshtein_distance)
- [In order](#load_balancing-in_order)
- [First or random](#load_balancing-first_or_random)
- [Round robin](#load_balancing-round_robin)
See also:
- [distributed_replica_max_ignored_errors](#distributed_replica_max_ignored_errors)
### Random (by Default) {#load_balancing-random}
``` sql
load_balancing = random
```
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.
Disadvantages: Server proximity is not accounted for; if the replicas have different data, you will also get different data.
### Nearest Hostname {#load_balancing-nearest_hostname}
``` sql
load_balancing = nearest_hostname
```
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).
For instance, example01-01-1 and example01-01-2 are different in one position, while example01-01-1 and example01-02-2 differ in two places.
This method might seem primitive, but it does not require external data about network topology, and it does not compare IP addresses, which would be complicated for our IPv6 addresses.
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.
### Hostname levenshtein distance {#load_balancing-hostname_levenshtein_distance}
``` sql
load_balancing = hostname_levenshtein_distance
```
Just like `nearest_hostname`, but it compares hostname in a [levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) manner. For example:
``` text
example-clickhouse-0-0 ample-clickhouse-0-0
1
example-clickhouse-0-0 example-clickhouse-1-10
2
example-clickhouse-0-0 example-clickhouse-12-0
3
```
### In Order {#load_balancing-in_order}
``` sql
load_balancing = in_order
```
Replicas with the same number of errors are accessed in the same order as they are specified in the configuration.
This method is appropriate when you know exactly which replica is preferable.
### First or Random {#load_balancing-first_or_random}
``` sql
load_balancing = first_or_random
```
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.
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.
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.
### Round Robin {#load_balancing-round_robin}
``` sql
load_balancing = round_robin
```
This algorithm uses a round-robin policy across replicas with the same number of errors (only the queries with `round_robin` policy is accounted).
)", 0) \
DECLARE(UInt64, load_balancing_first_offset, 0, R"(
Which replica to preferably send a query when FIRST_OR_RANDOM load balancing strategy is used.
)", 0) \
\
DECLARE(TotalsMode, totals_mode, TotalsMode::AFTER_HAVING_EXCLUSIVE, R"(
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”.
)", IMPORTANT) \
DECLARE(Float, totals_auto_threshold, 0.5, R"(
The threshold for `totals_mode = 'auto'`.
See the section “WITH TOTALS modifier”.
)", 0) \
\
DECLARE(Bool, allow_suspicious_low_cardinality_types, false, R"(
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:
- 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.
Merge times in [MergeTree](../../engines/table-engines/mergetree-family/mergetree.md)-engine tables can grow due to all the reasons described above.
Possible values:
- 1 — Usage of `LowCardinality` is not restricted.
- 0 — Usage of `LowCardinality` is restricted.
)", 0) \
DECLARE(Bool, allow_suspicious_fixed_string_types, false, R"(
In CREATE TABLE statement allows creating columns of type FixedString(n) with n > 256. FixedString with length >= 256 is suspicious and most likely indicates a misuse
)", 0) \
DECLARE(Bool, allow_suspicious_indices, false, R"(
Reject primary/secondary indexes and sorting keys with identical expressions
)", 0) \
DECLARE(Bool, allow_suspicious_ttl_expressions, false, R"(
Reject TTL expressions that don't depend on any of table's columns. It indicates a user error most of the time.
)", 0) \
DECLARE(Bool, allow_suspicious_variant_types, false, R"(
In CREATE TABLE statement allows specifying Variant type with similar variant types (for example, with different numeric or date types). Enabling this setting may introduce some ambiguity when working with values with similar types.
)", 0) \
DECLARE(Bool, allow_suspicious_primary_key, false, R"(
Allow suspicious `PRIMARY KEY`/`ORDER BY` for MergeTree (i.e. SimpleAggregateFunction).
)", 0) \
DECLARE(Bool, allow_suspicious_types_in_group_by, false, R"(
Allows or restricts using [Variant](../../sql-reference/data-types/variant.md) and [Dynamic](../../sql-reference/data-types/dynamic.md) types in GROUP BY keys.
)", 0) \
DECLARE(Bool, allow_suspicious_types_in_order_by, false, R"(
Allows or restricts using [Variant](../../sql-reference/data-types/variant.md) and [Dynamic](../../sql-reference/data-types/dynamic.md) types in ORDER BY keys.
)", 0) \
DECLARE(Bool, compile_expressions, false, R"(
Compile some scalar functions and operators to native code. Due to a bug in the LLVM compiler infrastructure, on AArch64 machines, it is known to lead to a nullptr dereference and, consequently, server crash. Do not enable this setting.
)", 0) \
DECLARE(UInt64, min_count_to_compile_expression, 3, R"(
Minimum count of executing same expression before it is get compiled.
)", 0) \
DECLARE(Bool, compile_aggregate_expressions, true, R"(
Enables or disables JIT-compilation of aggregate functions to native code. Enabling this setting can improve the performance.
Possible values:
- 0 — Aggregation is done without JIT compilation.
- 1 — Aggregation is done using JIT compilation.
**See Also**
- [min_count_to_compile_aggregate_expression](#min_count_to_compile_aggregate_expression)
)", 0) \
DECLARE(UInt64, min_count_to_compile_aggregate_expression, 3, R"(
The minimum number of identical aggregate expressions to start JIT-compilation. Works only if the [compile_aggregate_expressions](#compile_aggregate_expressions) setting is enabled.
Possible values:
- Positive integer.
- 0 — Identical aggregate expressions are always JIT-compiled.
)", 0) \
DECLARE(Bool, compile_sort_description, true, R"(
Compile sort description to native code.
)", 0) \
DECLARE(UInt64, min_count_to_compile_sort_description, 3, R"(
The number of identical sort descriptions before they are JIT-compiled
)", 0) \
DECLARE(UInt64, group_by_two_level_threshold, 100000, R"(
From what number of keys, a two-level aggregation starts. 0 - the threshold is not set.
)", 0) \
DECLARE(UInt64, group_by_two_level_threshold_bytes, 50000000, R"(
From what size of the aggregation state in bytes, a two-level aggregation begins to be used. 0 - the threshold is not set. Two-level aggregation is used when at least one of the thresholds is triggered.
)", 0) \
DECLARE(Bool, distributed_aggregation_memory_efficient, true, R"(
Is the memory-saving mode of distributed aggregation enabled.
)", 0) \
DECLARE(UInt64, aggregation_memory_efficient_merge_threads, 0, R"(
Number of threads to use for merge intermediate aggregation results in memory efficient mode. When bigger, then more memory is consumed. 0 means - same as 'max_threads'.
)", 0) \
DECLARE(Bool, enable_memory_bound_merging_of_aggregation_results, true, R"(
Enable memory bound merging strategy for aggregation.
)", 0) \
DECLARE(Bool, enable_positional_arguments, true, R"(
Enables or disables supporting positional arguments for [GROUP BY](../../sql-reference/statements/select/group-by.md), [LIMIT BY](../../sql-reference/statements/select/limit-by.md), [ORDER BY](../../sql-reference/statements/select/order-by.md) statements.
Possible values:
- 0 — Positional arguments aren't supported.
- 1 — Positional arguments are supported: column numbers can use instead of column names.
**Example**
Query:
```sql
CREATE TABLE positional_arguments(one Int, two Int, three Int) ENGINE=Memory();
INSERT INTO positional_arguments VALUES (10, 20, 30), (20, 20, 10), (30, 10, 20);
SELECT * FROM positional_arguments ORDER BY 2,3;
```
Result:
```text
┌─one─┬─two─┬─three─┐
│ 30 │ 10 │ 20 │
│ 20 │ 20 │ 10 │
│ 10 │ 20 │ 30 │
└─────┴─────┴───────┘
```
)", 0) \
DECLARE(Bool, enable_extended_results_for_datetime_functions, false, R"(
Enables or disables returning results of type:
- `Date32` with extended range (compared to type `Date`) for functions [toStartOfYear](../../sql-reference/functions/date-time-functions.md#tostartofyear), [toStartOfISOYear](../../sql-reference/functions/date-time-functions.md#tostartofisoyear), [toStartOfQuarter](../../sql-reference/functions/date-time-functions.md#tostartofquarter), [toStartOfMonth](../../sql-reference/functions/date-time-functions.md#tostartofmonth), [toLastDayOfMonth](../../sql-reference/functions/date-time-functions.md#tolastdayofmonth), [toStartOfWeek](../../sql-reference/functions/date-time-functions.md#tostartofweek), [toLastDayOfWeek](../../sql-reference/functions/date-time-functions.md#tolastdayofweek) and [toMonday](../../sql-reference/functions/date-time-functions.md#tomonday).
- `DateTime64` with extended range (compared to type `DateTime`) for functions [toStartOfDay](../../sql-reference/functions/date-time-functions.md#tostartofday), [toStartOfHour](../../sql-reference/functions/date-time-functions.md#tostartofhour), [toStartOfMinute](../../sql-reference/functions/date-time-functions.md#tostartofminute), [toStartOfFiveMinutes](../../sql-reference/functions/date-time-functions.md#tostartoffiveminutes), [toStartOfTenMinutes](../../sql-reference/functions/date-time-functions.md#tostartoftenminutes), [toStartOfFifteenMinutes](../../sql-reference/functions/date-time-functions.md#tostartoffifteenminutes) and [timeSlot](../../sql-reference/functions/date-time-functions.md#timeslot).
Possible values:
- 0 — Functions return `Date` or `DateTime` for all types of arguments.
- 1 — Functions return `Date32` or `DateTime64` for `Date32` or `DateTime64` arguments and `Date` or `DateTime` otherwise.
)", 0) \
DECLARE(Bool, allow_nonconst_timezone_arguments, false, R"(
Allow non-const timezone arguments in certain time-related functions like toTimeZone(), fromUnixTimestamp*(), snowflakeToDateTime*()
)", 0) \
DECLARE(Bool, function_locate_has_mysql_compatible_argument_order, true, R"(
Controls the order of arguments in function [locate](../../sql-reference/functions/string-search-functions.md#locate).
Possible values:
- 0 — Function `locate` accepts arguments `(haystack, needle[, start_pos])`.
- 1 — Function `locate` accepts arguments `(needle, haystack, [, start_pos])` (MySQL-compatible behavior)
)", 0) \
\
DECLARE(Bool, group_by_use_nulls, false, R"(
Changes the way the [GROUP BY clause](/docs/en/sql-reference/statements/select/group-by.md) treats the types of aggregation keys.
When the `ROLLUP`, `CUBE`, or `GROUPING SETS` specifiers are used, some aggregation keys may not be used to produce some result rows.
Columns for these keys are filled with either default value or `NULL` in corresponding rows depending on this setting.
Possible values:
- 0 — The default value for the aggregation key type is used to produce missing values.
- 1 — ClickHouse executes `GROUP BY` the same way as the SQL standard says. The types of aggregation keys are converted to [Nullable](/docs/en/sql-reference/data-types/nullable.md/#data_type-nullable). Columns for corresponding aggregation keys are filled with [NULL](/docs/en/sql-reference/syntax.md) for rows that didn't use it.
See also:
- [GROUP BY clause](/docs/en/sql-reference/statements/select/group-by.md)
)", 0) \
\
DECLARE(Bool, skip_unavailable_shards, false, R"(