#include #include #include #include #include #include #include #if ENABLE_DISTRIBUTED_CACHE #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace { #if defined(MEMORY_SANITIZER) constexpr UInt64 default_query_profiler_period_ns = 0; #else constexpr UInt64 default_query_profiler_period_ns = DB::QUERY_PROFILER_DEFAULT_SAMPLE_RATE_NS; #endif #if !CLICKHOUSE_CLOUD constexpr UInt64 default_max_size_to_drop = 50000000000lu; #else constexpr UInt64 default_max_size_to_drop = 0lu; #endif #if ENABLE_DISTRIBUTED_CACHE constexpr UInt64 default_distributed_cache_connect_max_tries = DistributedCache::DEFAULT_CONNECT_MAX_TRIES; constexpr UInt64 default_distributed_cache_read_request_max_tries = DistributedCache::DEFAULT_READ_REQUEST_MAX_TRIES; constexpr UInt64 default_distributed_cache_write_request_max_tries = DistributedCache::DEFAULT_WRITE_REQUEST_MAX_TRIES; constexpr UInt64 default_distributed_cache_credentials_refresh_period_seconds = DistributedCache::DEFAULT_CREDENTIALS_REFRESH_PERIOD_SECONDS; constexpr UInt64 default_distributed_cache_connect_backoff_min_ms = DistributedCache::DEFAULT_CONNECT_BACKOFF_MIN_MS; constexpr UInt64 default_distributed_cache_connect_backoff_max_ms = DistributedCache::DEFAULT_CONNECT_BACKOFF_MAX_MS; constexpr UInt64 default_distributed_cache_connect_timeout_ms = DistributedCache::DEFAULT_CONNECT_TIMEOUTS_MS; constexpr UInt64 default_distributed_cache_send_timeout_ms = DistributedCache::DEFAULT_SEND_TIMEOUT_MS; constexpr UInt64 default_distributed_cache_receive_timeout_ms = DistributedCache::DEFAULT_RECEIVE_TIMEOUT_MS; constexpr UInt64 default_distributed_cache_tcp_keep_alive_timeout_ms = DistributedCache::DEFAULT_TCP_KEEP_ALIVE_TIMEOUT_MS; constexpr UInt64 default_distributed_cache_use_clients_cache_for_read = DistributedCache::DEFAULT_USE_CLIENTS_CACHE_FOR_READ; constexpr UInt64 default_distributed_cache_max_unacked_inflight_packets = DistributedCache::MAX_UNACKED_INFLIGHT_PACKETS; constexpr UInt64 default_distributed_cache_data_packet_ack_window = DistributedCache::ACK_DATA_PACKET_WINDOW; #else constexpr UInt64 default_distributed_cache_connect_max_tries = 5lu; constexpr UInt64 default_distributed_cache_read_request_max_tries = 10lu; constexpr UInt64 default_distributed_cache_write_request_max_tries = 10lu; constexpr UInt64 default_distributed_cache_credentials_refresh_period_seconds = 5; constexpr UInt64 default_distributed_cache_connect_backoff_min_ms = 0; constexpr UInt64 default_distributed_cache_connect_backoff_max_ms = 50; constexpr UInt64 default_distributed_cache_connect_timeout_ms = 50; constexpr UInt64 default_distributed_cache_send_timeout_ms = 3000; constexpr UInt64 default_distributed_cache_receive_timeout_ms = 3000; constexpr UInt64 default_distributed_cache_tcp_keep_alive_timeout_ms = 2900; constexpr UInt64 default_distributed_cache_use_clients_cache_for_read = true; constexpr UInt64 default_distributed_cache_max_unacked_inflight_packets = 10lu; constexpr UInt64 default_distributed_cache_data_packet_ack_window = 5lu; #endif } 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; extern const int NOT_IMPLEMENTED; } /** 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 | PRIVATE_PREVIEW | 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, in increasing order of maturity: * EXPERIMENTAL: The feature is in active development stage. Mostly for developers or for ClickHouse enthusiasts. * PRIVATE_PREVIEW: The feature is on a clear path to general availability, but its applicability is still * limited and it is not recommended for production use. * 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 a new setting or changing the default of an existing one, append a history record to its `DECLARE`: * `{"", previous_value, new_value, "reason"}` (newest record first, one per version), so that * `system.settings_changes` and the `compatibility` setting work correctly. Add `CompatibilitySetting::Ignore` * as a fifth field when the new default must apply even with an older `compatibility` version. * * The settings in this list are used to autogenerate the markdown documentation. You can find the script which * generates the markdown from source here: https://github.com/ClickHouse/clickhouse-docs/blob/main/scripts/settings/autogenerate-settings.sh * * If a setting has an effect only in ClickHouse Cloud, then please include in the description: "Only has an effect in ClickHouse Cloud." */ // clang-format off #if defined(__CLION_IDE__) /// CLion freezes for a minute every time it processes this #define COMMON_SETTINGS(DECLARE, DECLARE_WITH_ALIAS) #define OBSOLETE_SETTINGS(DECLARE, DECLARE_WITH_ALIAS) #else #define COMMON_SETTINGS(DECLARE, DECLARE_WITH_ALIAS) \ DECLARE(Dialect, dialect, Dialect::clickhouse, R"( Which dialect will be used to parse query. Supported values: - `clickhouse` (default) — standard ClickHouse SQL. - `kusto` — Kusto Query Language. Requires the beta setting `enable_kusto_dialect`. - `prql` — PRQL. Requires the experimental setting `enable_prql_dialect`. - `polyglot` — transpiles SQL from other dialects (MySQL, PostgreSQL, etc.) into ClickHouse SQL. Requires the experimental setting `enable_polyglot_dialect`. - `promql` — PromQL (Prometheus Query Language) evaluated over a TimeSeries table, configured by the `promql_database`, `promql_table`, and `promql_evaluation_time` settings. - `clickhouse_json` — instead of SQL text, the query is interpreted as a JSON AST (the output of `parseQueryToJSON`). The `SET` query is still recognized in plain form so that the dialect can be switched back. Requires the experimental setting `enable_json_ast_dialect`. - `logsql` — LogsQL, the log query language of VictoriaLogs, translated into `SELECT` queries over the logs table configured by the `logsql_database` and `logsql_table` settings. Requires the experimental setting `enable_logsql_dialect`. - `trino` — Trino SQL: translates Trino syntax (`ARRAY[...]`, `TRY_CAST`, `UNNEST`, ...) and maps Trino function names to their ClickHouse equivalents. Requires the beta setting `enable_trino_dialect`. )", 0)\ DECLARE(UInt64, min_compress_block_size, 65536, R"( For [MergeTree](/reference/engines/table-engines/mergetree-family/mergetree) 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. 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. 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(NonZeroUInt64, 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(Bool, use_strict_insert_block_limits, false, R"( When enabled, strictly enforces both minimum and maximum insert block size limits. A block is emitted when: - Min thresholds (AND): Both min_insert_block_size_rows AND min_insert_block_size_bytes are reached. - Max thresholds (OR): Either max_insert_block_size_rows OR max_insert_block_size_bytes is reached. When disabled, a block is emitted when: - Min thresholds (OR): min_insert_block_size_rows OR min_insert_block_size_bytes is reached. **Note**: If max settings are smaller than min settings, the max limits take precedence and blocks will be emitted before min thresholds are reached. **Note**: This setting is automatically disabled for async inserts, because async inserts attach per-entry deduplication tokens that are incompatible with block splitting that is needed for enforcement of strict limits. Disabled by default. )", 0, \ {"26.4", false, false, "New setting to use strict min and max insert bounds on inserts. When min < max, max limits take precedence."}) \ DECLARE_WITH_ALIAS(NonZeroUInt64, max_insert_block_size, DEFAULT_INSERT_BLOCK_SIZE, R"( The maximum size of blocks (in a count of rows) to form for insertion into a table. This setting controls block formation in two contexts: 1. Format parsing: When the server parses row-based input formats (CSV, TSV, JSONEachRow, etc.) from any interface (HTTP, clickhouse-client with inline data, gRPC, PostgreSQL wire protocol), blocks are emitted when: - Both min_insert_block_size_rows AND min_insert_block_size_bytes are reached, OR - Either max_insert_block_size_rows OR max_insert_block_size_bytes is reached Note: When using clickhouse-client or clickhouse-local to read from a file, the client itself parses the data and this setting applies on the client side. 2. INSERT operations: During INSERT queries and when data flows through materialized views, this setting's behavior depends on `use_strict_insert_block_limits`: - When enabled: Blocks are emitted when: - Min thresholds (AND): Both min_insert_block_size_rows AND min_insert_block_size_bytes are reached - Max thresholds (OR): Either max_insert_block_size_rows OR max_insert_block_size_bytes is reached - When disabled: Blocks are emitted when min_insert_block_size_rows OR min_insert_block_size_bytes is reached. The max_insert_block_size settings are not enforced. Possible values: - Positive integer. )", 0, max_insert_block_size_rows, \ {"26.1", DEFAULT_INSERT_BLOCK_SIZE, DEFAULT_INSERT_BLOCK_SIZE, "Added the alias `max_insert_block_size_rows`."}) \ DECLARE(UInt64, max_insert_block_size_bytes, 0, R"( The maximum size of blocks (in bytes) to form for insertion into a table. This setting works together with max_insert_block_size_rows and controls block formation in the same context. See max_insert_block_size_rows for detailed information about when and how these settings are applied. Possible values: - Positive integer. - 0 — setting does not participate in block formation. )", 0, \ {"26.1", 0, 0, "New setting that allows to control the size of blocks in bytes during parsing of data in Row Input Format."}) \ DECLARE(UInt64, min_insert_block_size_rows, DEFAULT_INSERT_BLOCK_SIZE, R"( The minimum size of blocks (in rows) to form for insertion into a table. This setting controls block formation in two contexts: 1. Format parsing: When the server parses row-based input formats (CSV, TSV, JSONEachRow, etc.) from any interface (HTTP, clickhouse-client with inline data, gRPC, PostgreSQL wire protocol), blocks are emitted when: - Both min_insert_block_size_rows AND min_insert_block_size_bytes are reached, OR - Either max_insert_block_size_rows OR max_insert_block_size_bytes is reached Note: When using clickhouse-client or clickhouse-local to read from a file, the client itself parses the data and this setting applies on the client side. 2. INSERT operations: During INSERT queries and when data flows through materialized views, this setting's behavior depends on `use_strict_insert_block_limits`: - When enabled: Blocks are emitted when: - Min thresholds (AND): Both min_insert_block_size_rows AND min_insert_block_size_bytes are reached - Max thresholds (OR): Either max_insert_block_size_rows OR max_insert_block_size_bytes is reached - When disabled (default): Blocks are emitted when min_insert_block_size_rows OR min_insert_block_size_bytes is reached. The max_insert_block_size settings are not enforced. Possible values: - Positive integer. - 0 — setting does not participate in block formation. )", 0) \ DECLARE(UInt64, min_insert_block_size_bytes, (DEFAULT_INSERT_BLOCK_SIZE * 256), R"( The minimum size of blocks (in bytes) to form for insertion into a table. This setting works together with min_insert_block_size_rows and controls block formation in the same contexts (format parsing and INSERT operations). See min_insert_block_size_rows for detailed information about when and how these settings are applied. Possible values: - Positive integer. - 0 — setting does not participate in block formation. )", 0) \ DECLARE(Double, insert_squashing_max_memory_ratio, 0.1125, R"( Caps `min_insert_block_size_bytes` by this fraction of the server's memory limit (`max_server_memory_usage`) in the squashing stages of an `INSERT`: the squashing for the target table, the squashing of the results of dependent materialized views, and the block size of the source of a trivial `INSERT ... SELECT`. A squashing stage does not hold one block of `min_insert_block_size_bytes` but several: it accumulates the next block while the previous one is concatenated, the concatenated block is alive in the sink, and blocks are measured by their logical size while the arrays behind them round their capacity up. On a server with little memory that can make an `INSERT` fail with `MEMORY_LIMIT_EXCEEDED`. With the default `min_insert_block_size_bytes` the default value binds only below about 2.2 GiB of memory limit; a lower value such as `0.0625` helps an `INSERT` into a wide table fit into the memory of a small server. The cap depends only on the memory limit and this setting, not on the number of materialized views or insert streams. Note that the memory limit can change at runtime (see `memory_worker_dynamic_hard_limit`), and when the cap binds, a retried `INSERT` may be split into blocks differently than the first attempt. Possible values: from `0` to `1`. Set to `0` to disable the cap. )", 0, \ {"26.11", 0.1125, 0.1125, "New setting. The cap of `min_insert_block_size_bytes` by the memory limit was hardcoded as 0.9 / 8 of the limit; it is now configurable."}) \ 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](/reference/statements/create/view). 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](/reference/statements/create/view). 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(Float, shrink_over_allocated_columns_min_waste_ratio, 1.0, R"( On INSERT, over-allocated columns (whose reserved memory exceeds the used memory, e.g. due to power-of-two growth of variable-length columns) are shrunk to fit before the expensive materialization and part-writing stages, to reduce peak memory usage. A column is shrunk only when `allocatedBytes() > byteSize() * shrink_over_allocated_columns_min_waste_ratio` and the absolute waste is at least `shrink_over_allocated_columns_min_waste_bytes`. Possible values: - Float greater than 1. - Value less than or equal to 1 disables the shrinking (the default `1.0` keeps it disabled). )", 0, \ {"26.8", 1.0, 1.0, "New setting to shrink over-allocated columns to fit on INSERT to reduce peak memory usage. Disabled by default (1.0)."}) \ DECLARE(UInt64, shrink_over_allocated_columns_min_waste_bytes, (16 * 1024 * 1024), R"( Minimum absolute amount of wasted (reserved but unused) memory in a column, in bytes, for it to be shrunk to fit on INSERT. See [shrink_over_allocated_columns_min_waste_ratio](#shrink_over_allocated_columns_min_waste_ratio). Prevents reallocating columns whose over-allocation is small, where the memory saving would not justify the cost. )", 0, \ {"26.8", 16 * 1024 * 1024, 16 * 1024 * 1024, "New setting: minimum absolute wasted memory in a column for it to be shrunk to fit on INSERT."}) \ 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, \ {"24.2", DEFAULT_INSERT_BLOCK_SIZE, DEFAULT_INSERT_BLOCK_SIZE, "Squash blocks passed to external table to specified size in rows, if blocks are not big enough"}) \ 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, \ {"24.2", DEFAULT_INSERT_BLOCK_SIZE * 256, DEFAULT_INSERT_BLOCK_SIZE * 256, "Squash blocks passed to external table to specified size in bytes, if blocks are not big enough."}) \ 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, max_joined_block_size_bytes, 4_MiB, R"( Maximum block size in bytes for JOIN result (if join algorithm supports it). 0 means unlimited. )", 0, \ {"25.8", 0, 4 * 1024 * 1024, "New setting"}) \ DECLARE(UInt64, min_joined_block_size_rows, DEFAULT_BLOCK_SIZE, R"( Minimum block size in rows for JOIN input and output blocks (if join algorithm supports it). Small blocks will be squashed. 0 means unlimited. )", 0, \ {"25.7", 0, DEFAULT_BLOCK_SIZE, "New setting."}) \ DECLARE(UInt64, min_joined_block_size_bytes, 512 * 1024, R"( Minimum block size in bytes for JOIN input and output blocks (if join algorithm supports it). Small blocks will be squashed. 0 means unlimited. )", 0, \ {"24.11", 524288, 524288, "New setting."}) \ DECLARE(Bool, joined_block_split_single_row, false, R"( Allow to chunk hash join result by rows corresponding to single row from left table. This may reduce memory usage in case of row with many matches in right table, but may increase CPU usage. Note that `max_joined_block_size_rows != 0` is mandatory for this setting to have effect. The `max_joined_block_size_bytes` combined with this setting is helpful to avoid excessive memory usage in case of skewed data with some large rows having many matches in right table. )", 0, \ {"25.10", false, false, "New setting"}) \ DECLARE(Bool, parallel_non_joined_rows_processing, true, R"( Allow multiple threads to process non-joined rows from the right table in parallel during RIGHT and FULL JOINs. This can speed up the non-joined phase of hash joins with large right tables that build the hash table on several threads (see `parallel_hash_join_threshold`). When disabled, or when the hash table is built on one thread, non-joined rows are processed by a single thread. In every case the non-joined rows come out in no fixed order. Use `ORDER BY` when the query needs a stable order. )", 0, \ {"26.2", true, true, "New setting to enable parallel processing of non-joined rows in RIGHT/FULL parallel_hash joins."}) \ DECLARE(MaxThreads, max_insert_threads, 0, R"( The maximum number of threads to execute the `INSERT` query. This applies both to `INSERT SELECT` and to a plain `INSERT` whose data is sent from `clickhouse-client` or over the HTTP interface. The writing side of the pipeline (squashing the blocks and writing them to the destination table) is parallelized across up to this many threads. Possible values: - 0 — Auto. Uses the number of CPU cores available to the server (the same auto value as [`max_threads`](#max_threads)), reduced under memory pressure by [`max_insert_threads_min_free_memory_per_thread`](#max_insert_threads_min_free_memory_per_thread). - 1 — the `INSERT` is executed in a single thread (no parallel execution). Use this to preserve the insertion order of `INSERT ... SELECT`. - Positive integer bigger than 1 — Parallel execution with the specified number of threads. Before version 26.8 the default was `1` (no parallel execution). Since 26.8 the default (`0`) resolves to the number of CPU cores, so `INSERT` is parallelized by default. Set `max_insert_threads` to `1` (or use the `compatibility` setting) to restore the previous behavior. Cloud default value: - `1` for nodes with 8 GiB memory - `2` for nodes with 16 GiB memory - `4` for larger nodes Parallel `INSERT SELECT` has effect only if the `SELECT` part is executed in parallel, see [`max_threads`](#max_threads) setting. For a plain `INSERT`, the input data is read and parsed as a single stream, and the pipeline is then resized to this many streams for writing. The write-side parallelization applies only to synchronous plain `INSERT`s: asynchronous inserts ([`async_insert`](#async_insert) `= 1`) are stored in a queue and flushed in the background, so they are unaffected by this setting and always stay single-stream. The writing side is parallelized only when it is safe to do so; otherwise it stays single-stream and this setting has no effect on it. In particular, the write is kept single-stream when [`use_strict_insert_block_limits`](#use_strict_insert_block_limits) is enabled, a destination table (or a table it forwards to) deduplicates inserted blocks, and insert deduplication is enabled for the query (see [`deduplicate_insert`](#deduplicate_insert)), when the destination has dependent materialized views — including views of a table the destination forwards to, e.g. behind an `Alias` — (unless [`parallel_view_processing`](#parallel_view_processing) is enabled and the dependent view chains are free of deduplication hazards — deduplication in the views is disabled ([`deduplicate_blocks_in_dependent_materialized_views`](#deduplicate_blocks_in_dependent_materialized_views)) or no dependent view path can deduplicate), and always for `Buffer` and `Distributed` destinations. A `Buffer` flushes in its own context and a `Distributed` forwards the write to a remote shard (which may itself buffer the data), so this query's deduplication settings do not govern the final write and it is kept single-stream regardless of them. A non-parallel quorum insert ([`insert_quorum`](#insert_quorum) is `2` or greater, or `'auto'`, and [`insert_quorum_parallel`](#insert_quorum_parallel) is disabled) also stays single-stream, because it permits only one in-flight quorum part per table. Higher values will lead to higher memory usage. )", 0, \ {"26.8", 1, 0, "Changed the default from 1 (no parallel execution) to auto (0), which resolves to the number of CPU cores available to the server, reduced under memory pressure via `max_insert_threads_min_free_memory_per_thread`. This parallelizes `INSERT SELECT` by default. Set to 1 to restore the previous single-threaded behavior."}) \ DECLARE(UInt64, max_insert_delayed_streams_for_parallel_write, 0, R"( The maximum number of streams (columns) to delay final part flush. Default - auto (100 in case of underlying storage supports parallel write, for example S3 and disabled otherwise) Cloud default value: `50`. )", 0) \ DECLARE(Bool, finalize_projection_parts_synchronously, false, R"( When enabled, projection parts are finalized synchronously during INSERT, reducing peak memory usage at the cost of reduced S3 upload parallelism. By default, each projection's output stream is kept alive until the entire part (including all projections) is finalized, which allows overlapping S3 uploads but increases peak memory proportional to the number of projections. This setting only affects the INSERT path; merge and mutation already finalize projections synchronously. )", 0, \ {"26.4", false, false, "New setting to finalize projection parts synchronously during INSERT to reduce peak memory usage."}) \ DECLARE(MaxThreads, max_final_threads, 0, R"( Sets the maximum number of parallel threads for the `SELECT` query data read phase with the [FINAL](/reference/statements/select/from#final-modifier) 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'](/reference/settings/session-settings/max-distributed#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. The `max_threads` setting by default matches the number of hardware threads (number of CPU cores) available to ClickHouse. As a special case, for x86 processors with less than 32 CPU cores and SMT (e.g. Intel HyperThreading), ClickHouse uses the number of logical cores (= 2 x physical core count) by default. Without SMT (e.g. Intel HyperThreading), this corresponds to the number of CPU cores. For ClickHouse Cloud users, the default value will display as `auto(N)` where N matches the vCPU size of your service e.g. 2vCPU/8GiB, 4vCPU/16GiB etc. See the settings tab in the Cloud console for a list of all service sizes. )", 0) \ DECLARE(UInt64, max_threads_min_free_memory_per_thread, 1_GiB, R"( Lowers `max_threads` when the server is under memory pressure, to avoid starting highly-parallel queries that are likely to hit the memory limit. Free memory is computed as the server's `max_server_memory_usage` minus the memory currently tracked by the global memory tracker. If that free memory is less than `max_threads` multiplied by this value, `max_threads` is reduced to the largest N such that `N * value <= free_memory`, with a minimum of `1`. Free memory is taken once per query, when its plan is built, so that all parts of the query are planned with the same number of threads. Set to `0` to disable this limit. For example, with the default of 1 GiB and 32 GiB of free memory, `max_threads` is capped at 32; with 1 GiB of free memory it falls back to 1. This setting applies to read-side parallelism (`SELECT`, `UNION`, `INTERSECT`/`EXCEPT`, and the `SELECT` side of `INSERT ... SELECT`). For the write side, see `max_insert_threads_min_free_memory_per_thread`. )", 0, \ {"26.5", 0, 1073741824, "New setting to limit the number of threads based on available free memory"}) \ DECLARE(UInt64, max_insert_threads_min_free_memory_per_thread, 4_GiB, R"( Same as `max_threads_min_free_memory_per_thread`, but applied to `max_insert_threads` instead of `max_threads`. The default is higher because insert pipelines typically hold larger per-thread buffers (merge tree parts, compression blocks) than read pipelines. If the amount of free memory is less than `max_insert_threads` multiplied by this value, `max_insert_threads` is reduced to fit, down to a minimum of `1`. Set to `0` to disable this limit. )", 0, \ {"26.5", 0, 4294967296, "New setting to limit the number of insert threads based on available free memory"}) \ 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, \ {"24.12", false, true, "Enable concurrency control by default"}) \ DECLARE(Bool, use_concurrency_control_for_max_threads, true, R"( Choose the parallelism of a query (the number of streams and threads it is planned with) from the fair share of CPU slots of the server's concurrency control, instead of the number of CPU cores. The fair share is the slot limit (see the `concurrent_threads_soft_limit_num` and `concurrent_threads_soft_limit_ratio_to_cores` global server settings) divided evenly between the currently running pipelines and the new query. This way, when many queries run concurrently, each of them is planned with fewer streams: it uses less memory and spends less CPU on merging the partial results of its threads (e.g. aggregation states), which increases the total throughput. A query that is planned while the server is idle uses all CPU cores as before. The fair share is taken once per query, when its plan is built, so that all parts of the query (subqueries, sets, joined tables) are planned with the same number of streams. It only applies if `max_threads` is `auto` (not set explicitly) and `use_concurrency_control` is enabled. )", 0, \ {"26.10", false, true, "New setting to choose the parallelism of a query from the fair share of CPU slots of the concurrency control"}) \ 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, \ {"24.4", 0, 0, "Add a separate setting to control number of threads in parallel parsing from files"}) \ 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(NonZeroUInt64, max_read_buffer_size, DBMS_DEFAULT_BUFFER_SIZE, R"( The maximum size of the buffer to read from the filesystem. Values above 256 MiB are clamped to 256 MiB, as a read buffer never needs to be larger. )", 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. Values above 256 MiB are clamped to 256 MiB, as a read buffer never needs to be larger. )", 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. Values above 256 MiB are clamped to 256 MiB, as a read buffer never needs to be larger. )", 0) \ DECLARE(NonZeroUInt64, 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. `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, \ {"23.4", 50, 1000, "Increase default connect timeout because of async connect"}) \ DECLARE(Milliseconds, connect_timeout_with_failover_secure_ms, 1000, R"( Connection timeout for selecting first healthy replica (for secure connections). )", 0, \ {"23.4", 100, 1000, "Increase default secure connect timeout because of async connect"}) \ 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, \ {"23.4", 100, 50, "Start new connection in hedged requests after 50 ms instead of 100 to correspond with previous connect timeout"}) \ 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. Cloud default value: `0`. )", 0, \ {"21.9", false, true, "Enable Hedged Requests feature by default"}) \ 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. The wait applies per replica, because there is one connection pool per replica. When it expires the attempt fails with `NO_FREE_CONNECTION`. On the failover path used by distributed `SELECT`s that is treated like any other unusable replica: the query tries the remaining replicas, and only fails with `ALL_CONNECTION_TRIES_FAILED` once every one of them has been tried. So this setting does not bound the whole query; with `N` replicas and `T` tries each, the total wait can reach `connection_pool_max_wait_ms` times `N` times `T`, where `T` is [connections_with_failover_max_tries](#connections_with_failover_max_tries) but never less than one, because a replica is always tried once before it is written off. Use [max_execution_time](/reference/settings/session-settings/max-execution#max_execution_time) to bound the query itself. `skip_unavailable_shards` does not silence this: a replica the initiator had no free connection slot for was never contacted, so the shard is not treated as unavailable. Possible values: - Positive integer. - 0 — Infinite timeout. The wait is still interrupted by `KILL QUERY`, and by `max_execution_time` at the default [timeout_overflow_mode](/reference/settings/session-settings/timeout-overflow-mode#timeout_overflow_mode) `throw`. Under `break` the time limit does not cancel the query, so the wait continues until a connection is released; `KILL QUERY` still interrupts it. )", 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](/reference/engines/table-engines/integrations/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, \ {"24.3", 0, 0, "The exact size of part to upload during multipart upload to Azure blob storage."}) \ DECLARE(NonZeroUInt64, azure_max_blocks_in_multipart_upload, 50000, R"( Maximum number of blocks in multipart upload for Azure. )", 0, \ {"24.5", 50000, 50000, "Maximum number of blocks in multipart upload for Azure."}) \ 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, \ {"24.3", 16*1024*1024, 16*1024*1024, "The minimum size of part to upload during multipart upload to Azure blob storage."}) \ 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, \ {"24.3", 5ull*1024*1024*1024, 5ull*1024*1024*1024, "The maximum size of part to upload during multipart upload to Azure blob storage."}) \ 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 for s3 upload part. )", 0, \ {"24.6", 10000, 10000, "Maximum part number for s3 upload part"}) \ DECLARE(Bool, s3_allow_multipart_copy, true, R"( Allow multipart copy in S3. )", 0, \ {"25.2", true, true, "New setting."}) \ DECLARE(UInt64, s3_max_single_operation_copy_size, S3::DEFAULT_MAX_SINGLE_OPERATION_COPY_SIZE, R"( Maximum size for single-operation copy in s3. This setting is used only if s3_allow_multipart_copy is true. )", 0, \ {"24.6", 32 * 1024 * 1024, 32 * 1024 * 1024, "Maximum size for a single copy operation in s3"}) \ 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, \ {"24.3", 2, 2, "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."}) \ 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, \ {"24.3", 500, 500, "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."}) \ 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, \ {"24.3", 20, 20, "The maximum number of a concurrent loaded parts in multipart upload request. 0 means unlimited."}) \ 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, S3::DEFAULT_MAX_SINGLE_PART_UPLOAD_SIZE, R"( The maximum size of object to upload using singlepart upload to Azure blob storage. )", 0, \ {"25.8", 100 * 1024 * 1024, 32 * 1024 * 1024, "Align with S3"}) \ 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, \ {"24.2", 256*1024*1024, 256*1024*1024, "The maximum size of object to copy using single part copy to Azure blob storage."}) \ 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, \ {"24.1", 4, 4, "The maximum number of retries in case of unexpected errors during Azure blob storage write"}) \ 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, azure_max_redirects, S3::DEFAULT_MAX_REDIRECTS, R"( Max number of azure redirects hops allowed. )", 0, \ {"25.8", 10, 10, "New setting"}) \ DECLARE(UInt64, azure_max_get_rps, 0, R"( Limit on Azure GET request per second rate before throttling. Zero means unlimited. )", 0, \ {"25.8", 0, 0, "New setting"}) \ DECLARE(UInt64, azure_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 `azure_max_get_rps` )", 0, \ {"25.8", 0, 0, "New setting"}) \ DECLARE(UInt64, azure_max_put_rps, 0, R"( Limit on Azure PUT request per second rate before throttling. Zero means unlimited. )", 0, \ {"25.8", 0, 0, "New setting"}) \ DECLARE(UInt64, azure_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 `azure_max_put_rps` )", 0, \ {"25.8", 0, 0, "New setting"}) \ 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(Bool, azure_use_adaptive_timeouts, S3::DEFAULT_USE_ADAPTIVE_TIMEOUTS, R"( When set to `true` than for all azure 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, \ {"25.8", true, true, "New setting"}) \ DECLARE(Bool, s3_slow_all_threads_after_network_error, true, R"( When set to `true`, all threads executing S3 requests to the same backup endpoint are slowed down after any single s3 request encounters a retryable network error, such as socket timeout. When set to `false`, each thread handles S3 request backoff independently of the others. )", 0, \ {"25.5", false, true, "New setting"}) \ DECLARE(Bool, backup_slow_all_threads_after_retryable_s3_error, false, R"( When set to `true`, all threads executing S3 requests to the same backup endpoint are slowed down after any single S3 request encounters a retryable S3 error, such as 'Slow Down'. When set to `false`, each thread handles s3 request backoff independently of the others. )", 0, \ {"25.10", false, false, "Disable the setting by default"}, \ {"25.8", false, false, "New setting"}, \ {"25.6", false, false, "New setting"}) \ 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 creates a new file or fail if file exists and s3_create_new_file_on_insert is not set. - 1 — `INSERT` query replaces existing content of the file with the new data. See more details [here](/integrations/connectors/data-ingestion/AWS/integrating-s3-with-clickhouse#inserting-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 creates a new file or fail if file exists and s3_truncate_on_insert is not set. - 1 — `INSERT` query creates a new file on each insert using suffix (from the second one) if s3_truncate_on_insert is not set. See more details [here](/integrations/connectors/data-ingestion/AWS/integrating-s3-with-clickhouse#inserting-data). )", 0) \ DECLARE(Bool, s3_skip_empty_files, true, R"( Enables or disables skipping empty files in [S3](/reference/engines/table-engines/integrations/s3) 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, \ {"24.11", false, true, "We hope it will provide better UX"}) \ DECLARE(Bool, s3_skip_hidden_files, false, R"( Enables or disables skipping hidden paths when listing files by glob in [S3](/reference/engines/table-engines/integrations/s3) engine tables: objects with a path segment starting with `_` or `.` below the non-glob prefix of the path. A segment containing `=` is a partition directory (such as `_p=1` for a partition column `_p`) and is not hidden. Hive-ecosystem writers (Hive, Spark, Trino) stage in-progress output and write marker objects under such paths (`_temporary/`, `.spark-staging-/`, `_SUCCESS`), and reading them races with the writer's commit: the query can return uncommitted data or fail when the writer renames or deletes the staged object mid-read. Segments within the non-glob prefix are not checked. Tables with `partition_strategy = 'hive'` always skip hidden paths regardless of this setting. Possible values: - 0 — every object matched by the glob is read. - 1 — objects with a hidden path segment below the non-glob prefix are skipped. )", 0, \ {"26.11", false, false, "New setting: skip objects with a path segment starting with `_` or `.` below the non-glob prefix when listing files by glob, like other Hive-ecosystem readers do. Tables with `partition_strategy = 'hive'` always skip such paths."}) \ 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, s3_use_idempotency_id, true, R"( Put a unique idempotency id into the user-defined metadata (the `x-amz-meta-clickhouse-idempotency-id` header) of every object uploaded to S3. When a write is retried after its response was lost, the id lets ClickHouse recognize that the object was written by the earlier attempt of the same write and treat the write as successful instead of failing it. Disable it for S3-compatible storages that reject user-defined object metadata. Such writes lose the recovery of lost responses. Writes into the tables of a `DataLakeCatalog` database with `catalog_type = 's3tables'` (Amazon S3 Tables) don't put the id unless this setting is explicitly enabled in the query, because S3 Tables doesn't support user-defined object metadata. )", 0, \ {"26.11", true, true, "New setting to disable the idempotency id in the metadata of objects uploaded to S3."}) \ DECLARE(Bool, s3_validate_etag_on_read, true, R"( When reading an object from S3 (or an S3-compatible store such as GCS), check that every GET request returns the same ETag that was observed when the object was listed. A single file read issues many ranged GET requests; if the object is overwritten in place between them (for example by an external writer rewriting a fixed key), the reads can otherwise be stitched together from two different object generations and surface as a corrupted checksum or parse error. When a mismatch is detected the read fails with `S3_OBJECT_CHANGED_DURING_READ` instead of returning inconsistent data. Disable only for workloads that intentionally read objects that are being overwritten and can tolerate inconsistent reads. Not applied to the files of Iceberg tables that are read without an object metadata request (manifests, and Parquet and ORC data files read through a table), which are never overwritten. )", 0, \ {"26.7", false, true, "New setting to detect concurrent in-place overwrites of S3/GCS objects during a read by validating the GET response ETag against the listed one. previous_value=false so `compatibility` with versions before 26.7 restores the pre-existing behavior (no validation)."}) \ DECLARE(Bool, azure_validate_etag_on_read, true, R"( When reading a blob from Azure Blob Storage through the `azureBlobStorage` / `azureBlobStorageCluster` table functions or the `AzureBlobStorage` table engine, pin every `GET` request to the generation of the blob that was observed when it was listed by sending its `ETag` in `If-Match`, and check the `ETag` of the response. A single file read issues many ranged `GET` requests; if the blob is overwritten in place between them (for example by an external writer rewriting a fixed key), the reads can otherwise be stitched together from two different generations of the blob and surface as a corrupted checksum or parse error. The size recorded at listing time is also used as the right bound of the read, so it is only correct for the generation it was recorded for. When a mismatch is detected the read fails with `AZURE_OBJECT_CHANGED_DURING_READ` instead of returning inconsistent data. Disable only for workloads that intentionally read blobs that are being overwritten and can tolerate inconsistent reads. Not applied to the files of Iceberg tables that are read without an object metadata request (manifests, and Parquet and ORC data files read through a table), which are never overwritten. )", 0, \ {"26.10", false, true, "The validation is enabled by default again: 26.9 does not have it."}, \ {"26.9", true, false, "26.9 does not have this validation, which was backported to 26.7 and 26.8 but not to 26.9."}, \ {"26.7", false, true, "New setting to detect concurrent in-place overwrites of Azure blobs during a read by pinning every `GET` to the listed `ETag` with `If-Match` and validating the `ETag` of the response, like `s3_validate_etag_on_read` does for S3. `compatibility` with earlier versions restores the previous behavior (no validation)."}) \ 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, \ {"24.11", false, false, "Check each uploaded object in azure blob storage to be sure that upload was successful"}, \ {"24.10", false, false, "Check each uploaded object in azure blob storage to be sure that upload was successful"}) \ 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, \ {"24.4", "true", "true", "Use multiple threads for azure multipart upload."}) \ 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, \ {"24.6", false, false, "Allow to throw an error when ListObjects request cannot match any files in HDFS engine instead of empty query result"}) \ 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, \ {"24.6", false, false, "Allow to throw an error when ListObjects request cannot match any files in AzureBlobStorage engine instead of empty query result"}) \ 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, \ {"24.6", false, false, "Allow to return 0 rows when the requested files don't exist instead of throwing an exception in S3 table engine"}) \ 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, \ {"24.6", false, false, "Allow to return 0 rows when the requested files don't exist instead of throwing an exception in HDFS table engine"}) \ 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, \ {"24.6", false, false, "Allow to return 0 rows when the requested files don't exist instead of throwing an exception in AzureBlobStorage table engine"}) \ DECLARE(UInt64, azure_sdk_max_retries, 10, R"( Maximum number of retries in azure sdk )", 0, \ {"24.7", 10, 10, "Maximum number of retries in azure sdk"}) \ DECLARE(UInt64, azure_sdk_retry_initial_backoff_ms, 10, R"( Minimal backoff between retries in azure sdk )", 0, \ {"24.7", 10, 10, "Minimal backoff between retries in azure sdk"}) \ DECLARE(UInt64, azure_sdk_retry_max_backoff_ms, 1000, R"( Maximal backoff between retries in azure sdk )", 0, \ {"24.7", 1000, 1000, "Maximal backoff between retries in azure sdk"}) \ DECLARE(UInt64, azure_request_timeout_ms, S3::DEFAULT_REQUEST_TIMEOUT_MS, R"( Idleness timeout for sending and receiving data to/from azure. Fail if a single TCP read or write call blocks for this long. )", 0, \ {"25.8", 30000, 30000, "New setting"}) \ DECLARE(UInt64, azure_connect_timeout_ms, S3::DEFAULT_CONNECT_TIMEOUT_MS, R"( Connection timeout for host from azure disks. )", 0, \ {"25.8", 1000, 1000, "New setting"}) \ DECLARE(Bool, s3_validate_request_settings, true, R"( Enables s3 request settings validation. Possible values: - 1 — validate settings. - 0 — do not validate settings. )", 0, \ {"24.6", true, true, "Allow to disable S3 request settings validation"}) \ DECLARE(Bool, compatibility_s3_presigned_url_query_in_path, false, R"( Compatibility: when enabled, folds pre-signed URL query parameters (e.g. X-Amz-*) into the S3 key (legacy behavior), so '?' acts as a wildcard in the path. When disabled (default), pre-signed URL query parameters are kept in the URL query to avoid interpreting '?' as a wildcard. )", 0, \ {"25.12", false, false, "New setting."}) \ DECLARE(String, s3_upload_checksum_algorithm, "", R"( The checksum algorithm used when ClickHouse uploads data to `S3`. `CRC32` and `SHA256` are sent as flexible `x-amz-checksum-*` headers, while `MD5` is sent as a `Content-MD5` header. By default the value is empty and ClickHouse lets the AWS SDK compute `Content-MD5`. In FIPS mode `MD5` is unavailable, so the SDK silently omits it and the upload carries no checksum at all: set `CRC32` or `SHA256` to attach a flexible checksum instead. Where this setting applies, an explicit `MD5` is then rejected. It takes effect when the `S3` client is created, so it applies to query-scoped uses such as the `s3` table function and `BACKUP ... TO S3`; a later per-query `SET` does not reconfigure an already-created long-lived client such as an `S3` disk. `S3Express` buckets require a flexible checksum and do not accept `Content-MD5`: an explicit `CRC32` or `SHA256` is honored, an empty value uses `CRC32`, and an explicit `MD5` is rejected. `GCS` endpoints (`storage.googleapis.com`) ignore this setting entirely and keep the SDK's `Content-MD5` behavior, because `GCS` rejects `SigV4`-signed requests carrying the AWS `x-amz-checksum-*` headers. Server-side copies ignore this setting. )", 0, \ {"26.9", "", "", "New setting to choose the checksum algorithm for S3 uploads."}) \ 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, \ {"24.3", 1000, 1000, "Introduce new dedicated setting for s3 connection timeout"}) \ 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_migrate_old_metadata_to_buckets, false, R"( Migrate old metadata structure of S3Queue table to a new one )", 0, \ {"25.1", false, false, "New setting."}) \ 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(Float, s3queue_keeper_fault_injection_probability, 0.0, R"( Keeper fault injection probability for S3Queue. )", 0, \ {"25.10", 0, 0, "New setting."}) \ 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](/reference/engines/table-engines/integrations/hdfs) 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, hdfs_skip_hidden_files, false, R"( Enables or disables skipping hidden paths when listing files by glob in [HDFS](/reference/engines/table-engines/integrations/hdfs) engine tables: files with a path segment starting with `_` or `.` below the non-glob prefix of the path. A segment containing `=` is a partition directory (such as `_p=1` for a partition column `_p`) and is not hidden. Hive-ecosystem writers (Hive, Spark, Trino) stage in-progress output and write marker files under such paths (`_temporary/`, `.spark-staging-/`, `_SUCCESS`), and reading them races with the writer's commit. Segments within the non-glob prefix are not checked. Tables with `partition_strategy = 'hive'` always skip hidden paths regardless of this setting. Possible values: - 0 — every file matched by the glob is read. - 1 — files with a hidden path segment below the non-glob prefix are skipped. )", 0, \ {"26.11", false, false, "New setting: skip files with a path segment starting with `_` or `.` below the non-glob prefix when listing files by glob, like other Hive-ecosystem readers do. Tables with `partition_strategy = 'hive'` always skip such paths."}) \ DECLARE(Bool, enable_hdfs_pread, true, R"( Enable or disables pread for HDFS files. By default, `hdfsPread` is used. If disabled, `hdfsRead` and `hdfsSeek` will be used to read hdfs files.)", 0, \ {"25.4", true, true, "New setting."}) \ DECLARE(Bool, use_reader_executor, false, R"( Experimental. Route reads through the new pipeline `ReaderExecutor` instead of the legacy matryoshka of read buffers. Falls back to the legacy path for configurations the executor does not yet support.)", EXPERIMENTAL, \ {"26.6", false, false, "New experimental setting to route reads through the new pipeline ReaderExecutor instead of the legacy matryoshka of read buffers."}) \ DECLARE(Bool, reader_executor_use_long_connections, false, R"( Reuse a bounded long source connection across windows in the experimental `ReaderExecutor`. A long connection is one whose range exceeds the current read window; when disabled, the executor takes no connection-pool budget and every window opens a short-lived one-shot connection (the stateless path).)", EXPERIMENTAL, \ {"26.7", false, false, "New experimental ReaderExecutor setting (off by default): reuse a held source connection across sequential windows."}) \ DECLARE(UInt64, reader_executor_min_bytes_for_seek, DEFAULT_READER_EXECUTOR_MIN_BYTES_FOR_SEEK, R"( Forward-gap bound for the experimental `ReaderExecutor`: a gap up to this is skipped on the open source connection (bridged / read through) instead of issuing a separate source read or reopening. Set near the bandwidth/request cost breakeven so bridging stays cost-positive.)", EXPERIMENTAL, \ {"26.7", 2097152, 2097152, "New experimental ReaderExecutor setting: forward-gap bound for bridging on a held source connection."}) \ DECLARE(UInt64, reader_executor_max_tail_for_drain, DEFAULT_READER_EXECUTOR_MAX_TAIL_FOR_DRAIN, R"( Drain bound for the experimental `ReaderExecutor`: a long source connection dropped within this many bytes of its right bound is read out to the bound first, so it completes and returns to the connection pool reusable instead of counting as an incomplete connection.)", EXPERIMENTAL, \ {"26.7", 1048576, 1048576, "New experimental ReaderExecutor setting: drain bound for completing a dropped long connection."}) \ DECLARE(UInt64, reader_executor_window_size, DEFAULT_READER_EXECUTOR_WINDOW_SIZE, R"( Bytes served per read window by the experimental `ReaderExecutor` (the unit a read returns). Must be between 128 KiB and 40 MiB, the band shared by every `ReaderExecutor` size, and at most half of `reader_executor_plan_look_ahead`.)", EXPERIMENTAL, \ {"26.9", 4194304, 8388608, "Raised the default read window of the experimental `ReaderExecutor` from 4 MiB to 8 MiB. Under memory pressure the window is reduced from this base, floored at 128 KiB."}, \ {"26.8", 4194304, 4194304, "New experimental ReaderExecutor setting: bytes served per read window."}) \ DECLARE(UInt64, reader_executor_block_size, DEFAULT_READER_EXECUTOR_BLOCK_SIZE, R"( Buffer chunk size for the experimental `ReaderExecutor`: source reads fill nodes of at most this size. Must be between 128 KiB and 40 MiB, the band shared by every `ReaderExecutor` size.)", EXPERIMENTAL, \ {"26.8", 1048576, 1048576, "New experimental ReaderExecutor setting: buffer chunk size for source reads."}) \ DECLARE(UInt64, reader_executor_plan_look_ahead, DEFAULT_READER_EXECUTOR_PLAN_LOOK_AHEAD, R"( How far ahead the experimental `ReaderExecutor` resolves cache residency into its held read plan (a cheap probe, not a read), so one resolve serves many windows. The plan pins every cache cell it resolved until the cursor passes it, so this span drives how much memory and how much unevictable cache each concurrent reader holds. It is not an exact cap: a pin covers a whole cache segment or block, so a cell straddling either end of the range is held entire, adding up to one of them per cache tier at each end. Must be between 128 KiB and 40 MiB, the band shared by every `ReaderExecutor` size, at least `reader_executor_block_size`, and at least twice `reader_executor_window_size`, so that the plan always covers a whole fetch.)", EXPERIMENTAL, \ {"26.10", 16777216, 16777216, "New experimental ReaderExecutor setting: how far ahead cache residency is resolved into the held read plan."}) \ 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, \ {"24.6", false, false, "Allow to skip empty files in azure table engine"}) \ DECLARE(Bool, azure_skip_hidden_files, false, R"( Enables or disables skipping hidden paths when listing files by glob in [AzureBlobStorage](/reference/engines/table-engines/integrations/azureBlobStorage) engine tables: blobs with a path segment starting with `_` or `.` below the non-glob prefix of the path. A segment containing `=` is a partition directory (such as `_p=1` for a partition column `_p`) and is not hidden. Hive-ecosystem writers (Hive, Spark, Trino) stage in-progress output and write marker objects under such paths (`_temporary/`, `.spark-staging-/`, `_SUCCESS`), and reading them races with the writer's commit. Segments within the non-glob prefix are not checked. Tables with `partition_strategy = 'hive'` always skip hidden paths regardless of this setting. Possible values: - 0 — every blob matched by the glob is read. - 1 — blobs with a hidden path segment below the non-glob prefix are skipped. )", 0, \ {"26.11", false, false, "New setting: skip blobs with a path segment starting with `_` or `.` below the non-glob prefix when listing files by glob, like other Hive-ecosystem readers do. Tables with `partition_strategy = 'hive'` always skip such paths."}) \ DECLARE(ArrowFlightDescriptorType, arrow_flight_request_descriptor_type, ArrowFlightDescriptorType::Path, R"( Type of descriptor to use for Arrow Flight requests. 'path' sends the dataset name as a path descriptor. 'command' sends a SQL query as a command descriptor (required for Dremio). Possible values: - 'path' — Use FlightDescriptor::Path (default, works with most Arrow Flight servers) - 'command' — Use FlightDescriptor::Command with a SELECT query (required for Dremio) )", 0, \ {"25.11", "path", "path", "New setting. Type of descriptor to use for Arrow Flight requests: 'path' or 'command'. Dremio requires 'command'."}) \ DECLARE(UInt64, arrow_flight_request_timeout_sec, DBMS_DEFAULT_RECEIVE_TIMEOUT_SEC, R"( Timeout in seconds for a single Arrow Flight request. It bounds the whole request: for a read that is the entire result stream, not just the wait for the first record batch. Zero means no timeout, in which case a Flight server that accepts a request and never answers blocks the query until the connection is closed. )", 0, \ {"26.10", 0, 300, "New setting bounding a single Arrow Flight request. No timeout was set before, so a Flight server that accepted a request and never answered blocked the query indefinitely; 0 restores that behavior."}) \ 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_lz4_library_decompression, false, R"( Use the upstream `LZ4` library to decompress native ClickHouse blocks, including data compressed with `LZ4HC` or a codec chain containing `LZ4`. Disabled by default: ClickHouse's adaptive `LZ4` decoder is used. Both decoders read the same stored data; changing this setting does not require rewriting data parts. The setting applies to decompression performed in the query's context. Outside a query, the global context's setting is used, or ClickHouse's decoder if no context exists. )", 0, \ {"26.11", false, false, "New setting: optionally use the upstream `LZ4` library decoder instead of ClickHouse's adaptive decoder."}) \ 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](/reference/settings/server-settings/settings/uncompressed-cache#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, use_columns_cache, false, R"( Whether to use the columns cache. Accepts 0 or 1. By default, 0 (disabled). The columns cache stores deserialized columns from `MergeTree` tables, eliminating repeated decompression and deserialization for hot data. This can significantly reduce latency for repeated queries on the same data. The cache is keyed by table UUID, data part name, column name, and a stripe of consecutive granules of about 65536 rows. Because entries are keyed by table UUID, the cache is only active for tables in databases that assign UUIDs, such as `Atomic`, `Replicated`, and `Shared` (the default database engine in ClickHouse Cloud); `MergeTree` tables in legacy `Ordinary` databases have a nil UUID and silently ignore this setting. The cache applies to both wide and compact parts, including the parts of projections. An entry holds a contiguous range of granules of one stripe: a granule enters the cache only after it has been read from its first row to its last, a read is served from the cache granule by granule, and ranges written by different reads are merged, so reads that cut a part into different mark ranges share the entries. The cache also applies to `Parquet` files read from the local filesystem (the `file` table function and the `File` table engine), from object storages (`s3`, `azureBlobStorage` and their table engines), and by data lake tables. There an entry holds a chunk of 65536 rows of a column of one row group (the last chunk of a row group can be shorter), keyed by the path of the file, its version (the ETag of an object, or the modification time, inode and size of a local file), the column of the file and the type it is read as. A row group that uses the cache is read in these chunks, whatever the block size settings. A chunk is written to the cache as it is decoded, without a copy, if all its rows were read before any filter was applied to them: with `PREWHERE`, that is the case for the columns of the filter, while the other columns are read only for the rows that pass it. A column of a row group is served from the cache when all its chunks are there, so the chunks of a column that cannot all be written are taken back out of the cache. A local file is cached only once it has not been modified for a few seconds, so that its version identifies its content. )", EXPERIMENTAL, \ {"26.10", false, false, "New experimental setting to enable columns cache for MergeTree tables, disabled by default."}) \ DECLARE(Bool, enable_reads_from_columns_cache, true, R"( Whether to read from the columns cache when `use_columns_cache` is enabled. Accepts 0 or 1. By default, 1 (enabled). )", BETA, \ {"26.10", true, true, "New setting to control reading from columns cache"}) \ DECLARE(Bool, enable_writes_to_columns_cache, true, R"( Whether to write to the columns cache when `use_columns_cache` is enabled. Accepts 0 or 1. By default, 1 (enabled). )", BETA, \ {"26.10", true, true, "New setting to control writing to columns cache"}) \ DECLARE(UInt64, columns_cache_max_estimated_bytes_to_write_to_cache, 0, R"( If the estimated size of the data a query reads from `MergeTree` parts exceeds this value, writes to the columns cache are inhibited for the entire query. The estimate is made in uncompressed bytes, which is what the cache is charged for, from the size of the columns the query reads (including `PREWHERE`, mutation and patch-part columns) scaled to the selected mark ranges, and the query is charged for all of it before it reads anything. This keeps a single large scan from displacing useful data from the cache, and from copying data into the cache that cannot stay there. A value of `0` means use half of the size limit the columns cache currently has. That is the configured `columns_cache_size` while the server has memory to spare, but the cache shrinks under memory pressure (see the `ColumnsCacheSizeLimit` metric), and the default budget shrinks with it. With the default `columns_cache_size_ratio`, half of the limit is the size of the probationary segment of the cache, so the data of a query that passes the gate can be cached completely in one pass. The gate does not apply to a read that drops mark ranges while it runs, which is the case when `use_indexes_refiner_in_read_pools` is enabled: how many of the selected marks such a read really touches is decided only when each task is cut, so the estimate above would be an upper bound that charges marks the query never reads. For those reads the amount written is bounded by `columns_cache_max_bytes_to_write_to_cache` instead. )", BETA, \ {"26.10", 0, 0, "New setting: cap on the estimated uncompressed bytes a query reads to permit columns cache writes (0 = half of the current columns cache size limit, which shrinks under memory pressure)."}) \ DECLARE(UInt64, columns_cache_max_bytes_to_write_to_cache, 0, R"( Soft per-query threshold on the bytes a single query writes to the columns cache. The bytes written during the query are counted, and once the counter reaches this value, further cache writes for the rest of the query are skipped. This is an advisory threshold, not a hard cap: a reader accumulates the entries of the granules it has read and writes them to the cache in one batch, and the batch that crosses the threshold is stored in full before the counter is charged. So the actual amount written may exceed this value by up to the entries one reader accumulates between two writes - the columns it reads, one entry per stripe of about 65536 rows each - and, with several readers running at once, by that much per reader. The purpose is to keep a single large scan from displacing useful data from the cache, not to bound cache usage exactly. A value of `0` means use half of the size limit the columns cache currently has: the configured `columns_cache_size`, or less while the cache is shrunk under memory pressure (see the `ColumnsCacheSizeLimit` metric). )", BETA, \ {"26.10", 0, 0, "New setting: soft per-query threshold on bytes written to the columns cache; advisory, may be exceeded by up to the entries one reader writes in a batch (0 = half of the current columns cache size limit, which shrinks under memory pressure)."}) \ 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. The limit applies to the data read from the block devices: reads that are served from the OS page cache are not accounted for, as long as the read method can detect them (which is the case for the default `local_filesystem_read_method = 'pread_threadpool'`, for `pread`, and for the reads of the filesystem cache files). )", 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, S3Queue, AzureQueue and NATS engines. In case there are attached materialized views, SELECT query is not allowed even if this setting is enabled. If there are no attached materialized views, enabling this setting allows to read data. Be aware that usually the read data is removed from the queue. In order to avoid removing read data the related engine settings should be configured properly. )", 0, \ {"21.12", true, false, "Do not allow direct select for Kafka/RabbitMQ/FileLog by default"}) \ 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, \ {"24.7", false, false, "Validate primary key type for dictionaries. By default id type for simple layouts will be implicitly converted to UInt64."}) \ 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, \ {"24.3", false, false, "If true, INSERT into Distributed will skip read-only replicas"}) \ DECLARE_WITH_ALIAS(Bool, distributed_foreground_insert, false, R"( Enables or disables synchronous data insertion into a [Distributed](/reference/engines/table-engines/special/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](/reference/engines/table-engines/special/distributed) - [Managing Distributed Tables](/reference/statements/system#managing-distributed-tables) )", 0, insert_distributed_sync) \ DECLARE_WITH_ALIAS(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, insert_distributed_timeout) \ DECLARE_WITH_ALIAS(Milliseconds, distributed_background_insert_sleep_time_ms, 100, R"( Base interval for the [Distributed](/reference/engines/table-engines/special/distributed) table engine to send data. The actual interval grows exponentially in the event of errors. Possible values: - A positive integer number of milliseconds. )", 0, distributed_directory_monitor_sleep_time_ms) \ DECLARE_WITH_ALIAS(Milliseconds, distributed_background_insert_max_sleep_time_ms, 30000, R"( Maximum interval for the [Distributed](/reference/engines/table-engines/special/distributed) 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, distributed_directory_monitor_max_sleep_time_ms) \ DECLARE_WITH_ALIAS(Bool, distributed_background_insert_batch, false, R"( Enables/disables inserted data sending in batches. When batch sending is enabled, the [Distributed](/reference/engines/table-engines/special/distributed) 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, distributed_directory_monitor_batch_inserts) \ DECLARE_WITH_ALIAS(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. This setting also affects broken batches (that may appears because of abnormal server (machine) termination and no `fsync_after_insert`/`fsync_directories` for [Distributed](/reference/engines/table-engines/special/distributed) table engine). You should not rely on automatic batch splitting, since this may hurt performance. )", 0, distributed_directory_monitor_split_batch_on_failure) \ \ DECLARE(Bool, optimize_trivial_view_pushdown_to_distributed, true, R"( When enabled, for views over [Distributed](/reference/engines/table-engines/special/distributed) tables whose `SELECT` list contains only column references, `*`, or expressions (but no window functions or scalar subqueries), and that have no aggregation, grouping, ordering, or joins, the full outer query is pushed to each shard. This allows the shard to apply the view's filters and expressions locally, reducing the amount of data transferred over the network. Possible values: - 0 — The optimization is disabled; views over `Distributed` tables are always executed on the coordinator. - 1 — The optimization is enabled. )", 0, \ {"26.8", false, true, "New setting to push the full outer query to shards for trivial views over Distributed tables."}) \ DECLARE(Bool, optimize_move_to_prewhere, true, R"( Enables or disables automatic [PREWHERE](/reference/statements/select/prewhere) optimization in [SELECT](/reference/statements/select/index) queries. Works only for [*MergeTree](/reference/engines/table-engines/mergetree-family/index) tables. Possible values: - 0 — Automatic `PREWHERE` optimization is disabled. - 1 — Automatic `PREWHERE` optimization is enabled. )", 0) \ DECLARE(Bool, optimize_move_to_prewhere_if_final, true, R"( Enables or disables automatic [PREWHERE](/reference/statements/select/prewhere) optimization in [SELECT](/reference/statements/select/index) queries with [FINAL](/reference/statements/select/from#final-modifier) modifier. Only conditions that depend on the sorting key alone and are deterministic within the query are moved, so the result of `FINAL` is not affected. For [GraphiteMergeTree](/reference/engines/table-engines/mergetree-family/graphitemergetree), `FINAL` merges adjacent rows of one path into one row. Thus the optimization moves only conditions on the path column, and only if the path is the first column of the sorting key. Works only for [*MergeTree](/reference/engines/table-engines/mergetree-family/index) 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, \ {"26.10", false, true, "Enable the automatic PREWHERE optimization for queries with FINAL by default. Only conditions that depend on the sorting key alone and are deterministic within the query are moved, so results are not affected. `compatibility` below 26.10 restores the previous behavior."}) \ 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, \ {"24.10", true, true, "New setting"}) \ DECLARE(Bool, apply_string_filters_during_scan, true, R"( Push down substring search conditions on `String` columns from `PREWHERE` into the column scan. When a `PREWHERE` condition contains a conjunct that searches for a non-empty substring in a `String` (or `Nullable(String)`) column (`LIKE`, `position`, `startsWith`, `endsWith`, or equality with a non-empty string), the reader checks every value against this condition during deserialization and reads non-matching values as empty strings. This makes reading faster and lowers memory usage when the condition is selective, because the data of non-matching values is not copied into the column. The result of the query does not change, because the rows with non-matching values are guaranteed to be filtered out by `PREWHERE`, and such conditions never match an empty string. The filter is disabled adaptively at runtime if it turns out to be non-selective, or if the non-matching values are too short for skipping their data to pay off. Also allows the `WHERE` to `PREWHERE` optimization to move substring search conditions (`LIKE`, `position`, `startsWith`, `endsWith`) even when they use all queried columns (normally that is pointless, but with this setting the scan itself becomes cheaper). Equality with a constant string is not moved for this reason: it is still applied during the scan when it is already in `PREWHERE`. Supported for reading from `MergeTree` tables and from the `Parquet` format. In `Parquet`, the filter is applied to pages with the `PLAIN`, `DELTA_LENGTH_BYTE_ARRAY`, `DELTA_BYTE_ARRAY`, and dictionary encodings. Note that the estimation of the input bytes collected for the automatic decision about parallel replicas (`RuntimeDataflowStatisticsInputBytes`) is based on the in-memory size of the read blocks, so it underestimates the amount of data read from disk when the values are replaced by empty strings. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, \ {"26.10", false, true, "New setting to push down substring search conditions on `String` columns from `PREWHERE` into the column scan, enabled by default. `compatibility` with versions before 26.10 disables it."}) \ \ DECLARE_WITH_ALIAS(UInt64, alter_sync, 1, R"( Allows you to specify how [`ALTER`](/reference/statements/alter/index), [`OPTIMIZE`](/reference/statements/optimize), or [`TRUNCATE`](/reference/statements/truncate) queries wait for their operations to complete. Possible values: - `0` — Do not wait. - `1` — Wait for own execution. - `2` — Wait for everyone. - `3` - Only wait for active replicas. Inactive replicas apply the change when they become active. Cloud default value: `0`. `alter_sync` applies to `ALTER` queries on `MergeTree`-family tables. Values `2` and `3` wait for replicas only on `ReplicatedMergeTree` and `SharedMergeTree` tables. )", 0, 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`](/reference/statements/alter/index), [`OPTIMIZE`](/reference/statements/optimize) or [`TRUNCATE`](/reference/statements/truncate) 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) - [Hostname longest common prefix](#load_balancing-hostname_longest_common_prefix) - [Hostname longest common suffix](#load_balancing-hostname_longest_common_suffix) - [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 ``` ### Hostname longest common prefix {#load_balancing-hostname_longest_common_prefix} ```sql load_balancing = hostname_longest_common_prefix ``` Just like `nearest_hostname`, but the replica whose hostname shares the longest common prefix with the local hostname is preferred (the longer the common prefix, the higher the priority). Unlike `nearest_hostname`, which counts differing characters position by position, this strategy is not confused by hostnames whose numeric segments have different lengths. For example, for the local hostname `sfe301`: ```text sfe301 sde301 1 sfe301 sfe10101 3 sfe301 sde505 1 ``` Here `sfe10101` is preferred because it shares the longest common prefix (`sfe`, length 3) with `sfe301`. Replicas with equal common prefix length are chosen at random. In particular, when no replica shares any prefix with the local hostname (all common prefix lengths are zero), this strategy behaves exactly like `random`. ### Hostname longest common suffix {#load_balancing-hostname_longest_common_suffix} ```sql load_balancing = hostname_longest_common_suffix ``` Just like `hostname_longest_common_prefix`, but the longest common *suffix* is compared instead of the prefix. This is useful when the data center identity is encoded as a suffix of the hostname. For example, for the local hostname `et46gtghn.qc.localdomain`: ```text et46gtghn.qc.localdomain tr676ddgh.td.localdomain 12 et46gtghn.qc.localdomain ab999.qc.localdomain 15 ``` Here `ab999.qc.localdomain` is preferred because it shares the longest common suffix (`.qc.localdomain`, length 15) with `et46gtghn.qc.localdomain`. Replicas with equal common suffix length are chosen at random. In particular, when no replica shares any suffix with the local hostname (all common suffix lengths are zero), this strategy behaves exactly like `random`. ### 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](/reference/data-types/lowcardinality) 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](/reference/engines/table-engines/mergetree-family/mergetree)-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_WITH_ALIAS(Bool, allow_suspicious_indexes, false, R"( Reject primary/secondary indexes and sorting keys with identical expressions )", 0, allow_suspicious_indices, \ {"26.11", false, false, "Added an alias for setting `allow_suspicious_indices`."}, \ {"23.4", true, false, "If true, index can defined with identical expressions"}) \ DECLARE(Bool, allow_minmax_index_for_json, false, R"( Allow creating minmax skip indexes on JSON (Object) columns. Disabled by default because the minmax index serialization path cannot handle heterogeneous Field values that JSON columns may contain. )", 0, \ {"26.7", true, false, "Forbid creating minmax skip index on JSON columns by default because the index serialization cannot handle heterogeneous Field values"}) \ 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, \ {"23.12", true, false, "It is a new setting, and in previous versions the behavior was equivalent to allowing."}) \ 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, \ {"24.2", true, false, "Don't allow creating Variant type with suspicious variants by default"}) \ DECLARE(Bool, allow_suspicious_primary_key, false, R"( Allow suspicious `PRIMARY KEY`/`ORDER BY` for MergeTree (i.e. SimpleAggregateFunction). )", 0, \ {"24.3", true, false, "Forbid suspicious PRIMARY KEY/ORDER BY for MergeTree (i.e. SimpleAggregateFunction)"}) \ DECLARE(Bool, allow_reserved_column_names, false, R"( Allow a column of a `MergeTree`-family table to have the name of one of the table's virtual columns (for example `_part`, `_part_offset` or `_table`) in `CREATE TABLE`, `ATTACH TABLE` with a full definition, and `ALTER TABLE ... ADD COLUMN` and `RENAME COLUMN`. Such a column hides the virtual column. Tables that already have such a column are loaded regardless of this setting. Names of persistent virtual columns are always rejected. )", 0, \ {"26.11", true, false, "Reject columns named like a virtual column of a MergeTree table"}) \ DECLARE(Bool, allow_suspicious_types_in_group_by, false, R"( Allows or restricts using [Variant](/reference/data-types/variant) and [Dynamic](/reference/data-types/dynamic) types in GROUP BY keys. )", 0, \ {"24.11", true, false, "Don't allow Variant/Dynamic types in GROUP BY by default"}) \ DECLARE(Bool, allow_suspicious_types_in_order_by, false, R"( Allows or restricts using [Variant](/reference/data-types/variant) and [Dynamic](/reference/data-types/dynamic) types in ORDER BY keys. )", 0, \ {"24.11", true, false, "Don't allow Variant/Dynamic types in ORDER BY by default"}) \ DECLARE(Bool, validate_group_by_all_key_types, true, R"( Controls whether the grouping keys that `GROUP BY ALL` expands the `SELECT` expressions into are checked against [allow_suspicious_types_in_group_by](#allow_suspicious_types_in_group_by). Disable it to restore the behavior of versions before 26.7, which accepted a [Variant](/reference/data-types/variant) or [Dynamic](/reference/data-types/dynamic) key written as `GROUP BY ALL`, for example a grouping key that is an untyped JSON subpath. Takes effect only when the analyzer is enabled (`enable_analyzer = 1`, the default); with the old analyzer such a key was rejected before 26.7 as well, so there is nothing to restore there. An explicit `GROUP BY` is unaffected and keeps rejecting such a key either way, so this is narrower than setting `allow_suspicious_types_in_group_by`, which also permits them in an explicit `GROUP BY`. Possible values: - 0 - The key types `GROUP BY ALL` expands into are not validated. - 1 - They are validated, as an explicit `GROUP BY` validates its own keys. )", 0, \ {"26.9", true, true, "The validation of the key types that `GROUP BY ALL` expands the `SELECT` expressions into is kept under `compatibility` with 26.7 or 26.8: the previous value is deliberately equal to the new one, because those versions already rejected such a key and only a version before 26.7 restores the earlier acceptance."}, \ {"26.7", false, true, "New setting gating the validation of the key types that `GROUP BY ALL` expands the `SELECT` expressions into. 26.7 started rejecting a `Variant`/`Dynamic` key there, which earlier versions accepted with the analyzer enabled (`enable_analyzer = 1`, the default; the old analyzer rejected such a key before 26.7 as well), so the previous value is `false` and `compatibility` with a version before 26.7 restores the earlier acceptance."}) \ DECLARE(Bool, use_variant_default_implementation_for_comparisons, true, R"( Enables or disables default implementation for Variant type in comparison functions. )", 0, \ {"26.1", false, true, "Enable default implementation for Variant type in comparison functions"}) \ DECLARE(Bool, variant_throw_on_type_mismatch, true, R"( When applying a function to a [Variant](/reference/data-types/variant) column using the default implementation, controls what happens for rows whose actual type is incompatible with the function: - `true` (default) — throw an exception. - `false` — return `NULL` for those rows instead. )", 0, \ {"26.4", true, true, "New setting to control type mismatch behavior in default Variant implementation"}) \ DECLARE(Bool, dynamic_throw_on_type_mismatch, true, R"( When applying a function to a [Dynamic](/reference/data-types/dynamic) column using the default implementation, controls what happens for rows whose actual type is incompatible with the function: - `true` (default) — throw an exception. - `false` — return `NULL` for those rows instead. )", 0, \ {"26.4", true, true, "New setting to control type mismatch behavior in default Dynamic implementation"}) \ DECLARE(Bool, compile_expressions, true, R"( Compile some scalar functions and operators to native code. )", 0, \ {"25.5", false, true, "We believe that the LLVM infrastructure behind the JIT compiler is stable enough to enable this setting by default."}) \ DECLARE(UInt64, min_count_to_compile_expression, 3, R"( Minimum count of executing same expression before it is get compiled. )", 0) \ DECLARE(Bool, compile_regular_expressions, true, R"( Compile simple regular expressions used in functions like `match` and `extract` to native code. Patterns outside the supported subset transparently fall back to the general engine. )", 0, \ {"26.7", false, true, "New setting to enable JIT compilation of simple regular expressions in functions like `match` and `extract`."}) \ DECLARE(UInt64, min_count_to_compile_regular_expression, 3, R"( Minimum count of executing same regular expression before it is get compiled. )", 0, \ {"26.7", 3, 3, "New setting controlling how many times a regular expression must be used before it is JIT-compiled."}) \ 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, use_aggregation_memory_tracker, true, R"( Measure the size of the aggregation state compared with `group_by_two_level_threshold_bytes` with the memory tracker dedicated to the aggregation. When disabled, the size is measured as the growth of the memory usage of the whole query since the aggregation was created, so an aggregation with a small state can be converted to two-level. )", 0, \ {"26.10", true, true, "New setting to choose how the two-level conversion of `GROUP BY` measures the aggregation memory. The change it gates shipped in 26.7 and its memory regression is fixed in 26.9."}, \ {"26.9", false, true, "The two-level conversion of `GROUP BY` compares `group_by_two_level_threshold_bytes` with the memory of the aggregation state only, measured by a dedicated memory tracker (https://github.com/ClickHouse/ClickHouse/pull/107490). Before 26.7 it used the growth of the memory usage of the whole query."}) \ 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](/reference/statements/select/group-by), [LIMIT BY](/reference/statements/select/limit-by), [ORDER BY](/reference/statements/select/order-by) 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, \ {"22.7", false, true, "Enable positional arguments feature by default"}) \ DECLARE(Bool, enable_positional_arguments_for_projections, false, R"( Enables or disables supporting positional arguments in PROJECTION definitions. See also [enable_positional_arguments](#enable_positional_arguments) setting. This is an expert-level setting, and you shouldn't change it if you're just getting started with ClickHouse. Possible values: - 0 — Positional arguments aren't supported. - 1 — Positional arguments are supported: column numbers can use instead of column names. )", 0, \ {"25.12", true, false, "New setting to control positional arguments in projections."}, \ {"25.11", true, false, "New setting to control positional arguments in projections."}, \ {"25.10", true, false, "New setting to control positional arguments in projections."}) \ 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`) or `DateTime64` with extended range (compared to type `DateTime`). 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. The table below shows the behavior of this setting for various date-time functions. | Function | `enable_extended_results_for_datetime_functions = 0` | `enable_extended_results_for_datetime_functions = 1` | |----------|---------------------------------------------------|---------------------------------------------------| | `toStartOfYear` | Returns `Date` or `DateTime` | Returns `Date`/`DateTime` for `Date`/`DateTime` input
Returns `Date32`/`DateTime64` for `Date32`/`DateTime64` input | | `toStartOfISOYear` | Returns `Date` or `DateTime` | Returns `Date`/`DateTime` for `Date`/`DateTime` input
Returns `Date32`/`DateTime64` for `Date32`/`DateTime64` input | | `toStartOfQuarter` | Returns `Date` or `DateTime` | Returns `Date`/`DateTime` for `Date`/`DateTime` input
Returns `Date32`/`DateTime64` for `Date32`/`DateTime64` input | | `toStartOfMonth` | Returns `Date` or `DateTime` | Returns `Date`/`DateTime` for `Date`/`DateTime` input
Returns `Date32`/`DateTime64` for `Date32`/`DateTime64` input | | `toStartOfWeek` | Returns `Date` or `DateTime` | Returns `Date`/`DateTime` for `Date`/`DateTime` input
Returns `Date32`/`DateTime64` for `Date32`/`DateTime64` input | | `toLastDayOfWeek` | Returns `Date` or `DateTime` | Returns `Date`/`DateTime` for `Date`/`DateTime` input
Returns `Date32`/`DateTime64` for `Date32`/`DateTime64` input | | `toLastDayOfMonth` | Returns `Date` or `DateTime` | Returns `Date`/`DateTime` for `Date`/`DateTime` input
Returns `Date32`/`DateTime64` for `Date32`/`DateTime64` input | | `toMonday` | Returns `Date` or `DateTime` | Returns `Date`/`DateTime` for `Date`/`DateTime` input
Returns `Date32`/`DateTime64` for `Date32`/`DateTime64` input | | `toStartOfDay` | Returns `DateTime`
*Note: Wrong results for values outside 1970-2149 range* | Returns `DateTime` for `Date`/`DateTime` input
Returns `DateTime64` for `Date32`/`DateTime64` input | | `toStartOfHour` | Returns `DateTime`
*Note: Wrong results for values outside 1970-2149 range* | Returns `DateTime` for `Date`/`DateTime` input
Returns `DateTime64` for `Date32`/`DateTime64` input | | `toStartOfFifteenMinutes` | Returns `DateTime`
*Note: Wrong results for values outside 1970-2149 range* | Returns `DateTime` for `Date`/`DateTime` input
Returns `DateTime64` for `Date32`/`DateTime64` input | | `toStartOfTenMinutes` | Returns `DateTime`
*Note: Wrong results for values outside 1970-2149 range* | Returns `DateTime` for `Date`/`DateTime` input
Returns `DateTime64` for `Date32`/`DateTime64` input | | `toStartOfFiveMinutes` | Returns `DateTime`
*Note: Wrong results for values outside 1970-2149 range* | Returns `DateTime` for `Date`/`DateTime` input
Returns `DateTime64` for `Date32`/`DateTime64` input | | `toStartOfMinute` | Returns `DateTime`
*Note: Wrong results for values outside 1970-2149 range* | Returns `DateTime` for `Date`/`DateTime` input
Returns `DateTime64` for `Date32`/`DateTime64` input | | `timeSlot` | Returns `DateTime`
*Note: Wrong results for values outside 1970-2149 range* | Returns `DateTime` for `Date`/`DateTime` input
Returns `DateTime64` for `Date32`/`DateTime64` input | )", 0) \ DECLARE(Bool, to_start_of_interval_preserves_argument_type, true, R"( Makes the function `toStartOfInterval` (and its aliases `time_bucket` and `date_bin`) return a value of the same type as its first argument: `Date` for `Date`, `Date32` for `Date32`, `DateTime` for `DateTime` and `DateTime64` with the same scale for `DateTime64`, regardless of the interval unit. The only exception is a subsecond unit finer than the scale of a `DateTime64` argument, for example `INTERVAL 1500 MILLISECOND` for a `DateTime64(0)`: the result has the scale of the unit, because the scale of the argument cannot represent the bucket boundaries. Possible values: - `1` — The result has the type of the first argument. The setting `enable_extended_results_for_datetime_functions` does not affect the function. - `0` — Legacy behavior: the result type depends on the interval unit. The units `WEEK` and longer produce a `Date`, `DAY` down to `SECOND` produce a `DateTime`, and the subsecond units produce a `DateTime64` with the scale of the unit (for `Date32` and `DateTime64` arguments, `Date32` and `DateTime64` instead of `Date` and `DateTime` with `enable_extended_results_for_datetime_functions = 1`). A value that does not fit the range of the narrower result type is wrapped: for example, `toStartOfInterval(toDate32('1900-01-01'), INTERVAL 1 DAY)` returns `2036-02-07 06:28:16`. This describes the overload without `origin`. The overload with `origin` keeps the type of the argument even in the legacy behavior, except that for a `DateTime64` argument and a subsecond unit the result has the scale of the unit. )", 0, \ {"26.11", false, true, "The function `toStartOfInterval` returns a value of the same type as its argument instead of a type determined by the interval unit, which wrapped values outside the range of the narrower type"}) \ DECLARE(Bool, allow_nonconst_timezone_arguments, false, R"( Allow non-const timezone arguments in certain time-related functions like toTimeZone(), fromUnixTimestamp*(), snowflakeIDToDateTime*(). This setting exists only for compatibility reasons. In ClickHouse, the time zone is a property of the data type, respectively of the column. Enabling this setting gives the wrong impression that different values within a column can have different timezones. Therefore, please do not enable this setting. )", 0, \ {"23.4", true, false, "Allow non-const timezone arguments in certain time-related functions like toTimeZone(), fromUnixTimestamp*(), snowflakeToDateTime*()."}) \ DECLARE(Bool, use_legacy_to_time, false, R"( When enabled, the name `toTime` refers to the legacy [`toTime`](/reference/functions/regular-functions/date-time-functions#toTimeWithFixedDate) function, which converts a date with time to a certain fixed date, while preserving the time. Otherwise, the name refers to the new [`toTime`](/reference/functions/regular-functions/type-conversion-functions#toTime) function, which converts values of different types into the [`Time`](/reference/data-types/time) type. The legacy function is also unconditionally accessible as `toTimeWithFixedDate`, regardless of this setting. While this setting is enabled, use `CAST(x AS Time)` or `x::Time` to convert to the `Time` type. )", 0, \ {"26.7", true, false, "Use the new `toTime` function (converting values to the `Time` data type) by default instead of the legacy `toTime` (which is still available as `toTimeWithFixedDate`)."}, \ {"25.6", true, true, "New setting. Allows for user to use the old function logic for toTime, which works as toTimeWithFixedDate."}) \ DECLARE_WITH_ALIAS(Bool, enable_time_time64_type, true, R"( Allows creation of [Time](/reference/data-types/time) and [Time64](/reference/data-types/time64) data types. )", 0, allow_experimental_time_time64_type, \ {"25.12", false, true, "Enable Time and Time64 type by default. This also applies to the alias `allow_experimental_time_time64_type`."}, \ {"25.6", false, false, "New settings. Allows to use a new experimental Time and Time64 data types. This also applies to the alias `allow_experimental_time_time64_type`."}) \ DECLARE(Bool, function_locate_has_mysql_compatible_argument_order, true, R"( Controls the order of arguments in function [locate](/reference/functions/regular-functions/string-search-functions#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, \ {"24.3", false, true, "Increase compatibility with MySQL's locate function."}) \ \ DECLARE(Bool, group_by_use_nulls, false, R"( Changes the way the [GROUP BY clause](/reference/statements/select/group-by) 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](/reference/data-types/nullable). Columns for corresponding aggregation keys are filled with [NULL](/reference/syntax#null) for rows that didn't use it. See also: - [GROUP BY clause](/reference/statements/select/group-by) )", 0) \ \ DECLARE(Bool, skip_unavailable_shards, false, R"( Enables or disables silently skipping of unavailable shards. The behavior of this setting is controlled by the `skip_unavailable_shards_mode` parameter. Possible values: - 1 — skipping enabled. If a shard is unavailable, ClickHouse returns a result based on partial data and does not report node availability issues. On a read, if *every* shard was skipped before returning any data there is no partial data left to return, so the query throws `ALL_CONNECTION_TRIES_FAILED` instead of returning an empty result. This check covers reads only; `INSERT` has its own handling of a fully unavailable destination cluster. - 0 — skipping disabled. If a shard is unavailable, ClickHouse throws an exception. )", 0) \ \ DECLARE(SkipUnavailableShardsMode, skip_unavailable_shards_mode, SkipUnavailableShardsMode::UNAVAILABLE_OR_TABLE_MISSING, R"( Controls which exceptions from a remote shard are silently ignored when `skip_unavailable_shards` is enabled. The setting has no effect when `skip_unavailable_shards = 0`. Possible values: - `unavailable` — Only connection-related errors are ignored. A shard is considered unavailable when ClickHouse cannot connect to any of its replicas, or when a replica's hostname cannot be resolved through DNS. - `unavailable_or_table_missing` — In addition to `unavailable`, errors caused by a missing table or database on the shard are ignored. This is useful while a table is being created or dropped across a cluster. This is the default and matches the historical behavior of `skip_unavailable_shards`, which also treated a shard whose table does not exist as unavailable. - `unavailable_or_exception_before_processing` — In addition to `unavailable`, any exception received from a shard before it returned any data block to the initiator is ignored. An exception that arrives after the shard already returned some data is always rethrown. Note that "before it returned any data" is checked at the initiator: a shard that performs a blocking computation (for example an aggregation, sort, or `LIMIT BY`) may process rows and fail before emitting any block, in which case its partial work is silently discarded and the query returns a result built from the remaining shards. This is therefore the most permissive mode and should be used with care. )", 0, \ {"26.7", "unavailable_or_table_missing", "unavailable_or_table_missing", "New setting to control which exceptions from a remote shard are ignored when `skip_unavailable_shards` is enabled. The default matches the historical behavior: a shard whose table is missing is treated as unavailable."}) \ \ DECLARE(UInt64, max_skip_unavailable_shards_num, 0, R"( When `skip_unavailable_shards` is enabled, limits the maximum number of shards that can be silently skipped. If the number of unavailable shards exceeds this value, an exception is thrown instead of silently skipping. A value of 0 means no limit on the count. On a read, skipping *every* shard before any of them returned data still throws `ALL_CONNECTION_TRIES_FAILED`, because such a query has no partial result to return. This limit applies to reads only. )", 0, \ {"26.3", 0, 0, "New setting to limit the number of shards that can be silently skipped when skip_unavailable_shards is enabled."}) \ \ DECLARE(Float, max_skip_unavailable_shards_ratio, 0, R"( When `skip_unavailable_shards` is enabled, limits the maximum ratio (0 to 1) of shards that can be silently skipped. If the ratio of unavailable shards to total shards exceeds this value, an exception is thrown instead of silently skipping. A value of 0 means no limit on the ratio. On a read, skipping *every* shard before any of them returned data still throws `ALL_CONNECTION_TRIES_FAILED`, because such a query has no partial result to return. This limit applies to reads only. )", 0, \ {"26.3", 0, 0, "New setting to limit the ratio of shards that can be silently skipped when skip_unavailable_shards is enabled."}) \ \ DECLARE(UInt64, parallel_distributed_insert_select, 2, R"( Enables parallel distributed `INSERT ... SELECT` query. 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](/reference/engines/table-engines/mergetree-family/replication) or non-replicated, then this query is processed locally on every shard. Possible values: - `0` — Disabled. - `1` — `SELECT` will be executed on each shard from the underlying table of the distributed engine. - `2` — `SELECT` and `INSERT` will be executed on each shard from/to the underlying table of the distributed engine. Since v25.4, `INSERT ... SELECT` from a `ReplicatedMergeTree` or `SharedMergeTree` source can also be parallelized across replicas. To enable it: - `parallel_distributed_insert_select = 2` - `enable_parallel_replicas = 1` The rewritten query, including every expression of the `SELECT` (subqueries, UDFs, and so on), is executed on the shards under the credentials of the cluster configuration — the same trust model as other shard-side processing, such as the subqueries of a non-`GLOBAL` `IN`. Configure an interserver secret (the `secret` element of the cluster configuration) if shard-side reads must be authorized as the calling user. )", 0, \ {"25.7", 0, 2, "Enable parallel distributed insert select by default"}) \ DECLARE(UInt64, distributed_group_by_no_merge, 0, R"( 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 completely processed on the shard, initiator only proxy the data), can be used in case it is for certain that there are different keys on different shards. - `2` - Same as `1` but applies `ORDER BY` and `LIMIT` (it is not possible when the query processed completely on the remote node, like for `distributed_group_by_no_merge=1`) 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 │ └───────┘ ``` )", 0) \ DECLARE(UInt64, distributed_push_down_limit, 1, R"( Enables or disables [LIMIT](#limit) applying on each shard separately. This will allow to avoid: - Sending extra rows over network; - Processing rows behind the limit on the initiator. Starting from 21.9 version you cannot get inaccurate results anymore, since `distributed_push_down_limit` changes query execution only if at least one of the conditions met: - [distributed_group_by_no_merge](#distributed_group_by_no_merge) > 0. - Query **does not have** `GROUP BY`/`DISTINCT`/`LIMIT BY`, but it has `ORDER BY`/`LIMIT`. - Query **has** `GROUP BY`/`DISTINCT`/`LIMIT BY` with `ORDER BY`/`LIMIT` and: - [optimize_skip_unused_shards](#optimize_skip_unused_shards) is enabled. - [optimize_distributed_group_by_sharding_key](#optimize_distributed_group_by_sharding_key) is enabled. Possible values: - 0 — Disabled. - 1 — Enabled. See also: - [distributed_group_by_no_merge](#distributed_group_by_no_merge) - [optimize_skip_unused_shards](#optimize_skip_unused_shards) - [optimize_distributed_group_by_sharding_key](#optimize_distributed_group_by_sharding_key) )", 0) \ DECLARE(Bool, optimize_distributed_group_by_sharding_key, true, R"( 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. See also: - [distributed_group_by_no_merge](#distributed_group_by_no_merge) - [distributed_push_down_limit](#distributed_push_down_limit) - [optimize_skip_unused_shards](#optimize_skip_unused_shards) 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). )", 0) \ DECLARE(UInt64, optimize_skip_unused_shards_limit, 1000, R"( Limit for number of sharding key values, turns off `optimize_skip_unused_shards` if the limit is reached. Too many values may require significant amount for processing, while the benefit is doubtful, since if you have huge number of values in `IN (...)`, then most likely the query will be sent to all shards anyway. )", 0) \ DECLARE(Bool, optimize_skip_unused_shards, false, R"( Enables or disables skipping of unused shards for [SELECT](/reference/statements/select/index) queries that have sharding key condition in `WHERE/PREWHERE`, and activates related optimizations for distributed queries (e.g. aggregation by sharding key). Assumes that the data is distributed by sharding key, otherwise a query yields incorrect result. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0) \ DECLARE(Bool, optimize_skip_unused_shards_rewrite_in, true, R"( Rewrite IN in query for remote shards to exclude values that does not belong to the shard (requires optimize_skip_unused_shards). Possible values: - 0 — Disabled. - 1 — Enabled. )", 0) \ DECLARE(Bool, allow_nondeterministic_optimize_skip_unused_shards, false, R"( Allow nondeterministic (like `rand` or `dictGet`, since later has some caveats with updates) functions in sharding key. Possible values: - 0 — Disallowed. - 1 — Allowed. )", 0) \ DECLARE(UInt64, force_optimize_skip_unused_shards, 0, R"( 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. Possible values: - 0 — Disabled. ClickHouse does not throw an exception. - 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. )", 0) \ DECLARE(UInt64, optimize_skip_unused_shards_nesting, 0, R"( 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). Possible values: - 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. )", 0) \ DECLARE(UInt64, force_optimize_skip_unused_shards_nesting, 0, R"( 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). Possible values: - 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. )", 0) \ \ DECLARE(NonZeroUInt64, min_chunk_bytes_for_parallel_parsing, (10 * 1024 * 1024), R"( The minimum chunk size in bytes, which each thread will parse in parallel. )", 0) \ DECLARE(Bool, allow_special_serialization_kinds_in_output_formats, true, R"( Allows to output columns with special serialization kinds like Sparse and Replicated without converting them to full column representation. It helps to avoid unnecessary data copy during formatting. )", 0, \ {"25.11", false, true, "Enable direct output of special columns representations like Sparse/Replicated in some output formats"}, \ {"25.10", false, false, "Add a setting to allow output of special columns representations like Sparse/Replicated without converting them to full columns"}) \ DECLARE(Bool, enable_parsing_to_custom_serialization, true, R"( If true then data can be parsed directly to columns with custom serialization (e.g. Sparse) according to hints for serialization got from the table. )", 0, \ {"24.10", false, true, "New setting"}) \ DECLARE(Bool, ignore_format_null_for_explain, true, R"( If enabled, `FORMAT Null` will be ignored for `EXPLAIN` queries and default output format will be used instead. When disabled, `EXPLAIN` queries with `FORMAT Null` will produce no output (backward compatible behavior). )", 0, \ {"26.2", false, true, "FORMAT Null is now ignored for EXPLAIN queries by default"}) \ \ DECLARE(Bool, merge_tree_use_v1_object_and_dynamic_serialization, false, R"( When enabled, V1 serialization version of JSON and Dynamic types will be used in MergeTree instead of V2. Changing this setting takes affect only after server restart. )", 0, \ {"24.11", true, false, "Add new serialization V2 version for JSON and Dynamic types"}) \ DECLARE(UInt64, merge_tree_min_rows_for_concurrent_read, (20 * 8192), R"( If the number of rows to be read from a file of a [MergeTree](/reference/engines/table-engines/mergetree-family/mergetree) table exceeds `merge_tree_min_rows_for_concurrent_read` then ClickHouse tries to perform a concurrent reading from this file on several threads. Possible values: - Positive integer. )", 0) \ DECLARE(UInt64, merge_tree_min_bytes_for_concurrent_read, (24 * 10 * 1024 * 1024), R"( If the number of bytes to read from one file of a [MergeTree](/reference/engines/table-engines/mergetree-family/mergetree)-engine table exceeds `merge_tree_min_bytes_for_concurrent_read`, then ClickHouse tries to concurrently read from this file in several threads. Possible value: - Positive integer. )", 0) \ DECLARE(UInt64, merge_tree_min_bytes_per_read_stream, (64 * 1024), R"( Per-stream overhead cost expressed as byte-equivalent. Controls the maximum number of read streams created for ordinary local unordered `MergeTree` scans. Ordered, `FINAL`, layered, and parallel-replica reads are not changed. The volume-based cap is `ceil(sqrt(estimated_read_bytes / this_setting))`. ClickHouse also preserves at least 16 streams and at least one quarter of the streams requested before this cap, so the effective stream count is `min(requested_streams, max(volume_based_cap, 16, floor(requested_streams / 4)))`. These lower bounds preserve downstream parallelism for CPU-heavy expressions and aggregations, whose cost is not represented by `estimated_read_bytes`. `estimated_read_bytes` is the uncompressed size of the columns being read over the mark ranges left after index and partition pruning. Uncompressed size is used because per-stream overhead is traded against the work done per stream, which scales with the number of values processed rather than with how well they compress. The cap is not applied when the read volume cannot be estimated conservatively, for example when an old part needs other physical columns to evaluate a newly added `DEFAULT` column, or when a selected range reads only part of a variable-width column. The default of 64 KB is derived from the cost model `T(N) = W/N + F + V·N`, where `W` is useful work, `F` is fixed pipeline overhead, and `V` is per-stream variable cost. The optimal stream count is `sqrt(W/V)`. Expressing `W` in bytes via throughput gives `C = throughput · V ≈ 400 MB/s · 0.17 ms ≈ 64 KB`. Increasing this value reduces the number of streams (more conservative); decreasing it allows more streams. Set to 0 to disable this optimization. Possible values: - Non-negative integer. )", 0, \ {"26.8", 0, (64 * 1024), "New setting to cap the number of streams for ordinary local unordered `MergeTree` narrow-column scans using a sqrt cost model, reducing per-stream overhead on high-core-count machines. previous_value=0 (disabled) so `compatibility` with versions before 26.8 restores the pre-existing stream count."}) \ DECLARE(UInt64, merge_tree_min_rows_for_seek, 0, R"( 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. Possible values: - Any positive integer. )", 0) \ DECLARE(UInt64, merge_tree_min_bytes_for_seek, 0, R"( 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. Possible values: - Any positive integer. )", 0) \ DECLARE(UInt64, merge_tree_coarse_index_granularity, 8, R"( 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. Possible values: - Any positive even integer. )", 0) \ DECLARE(UInt64, merge_tree_generic_exclusion_search_max_steps, 0, R"( When a filter cannot be evaluated as a single continuous range of the primary key, for example when it uses key columns other than the first one, ClickHouse runs an iterative generic exclusion search algorithm over the index marks. The same algorithm is used for the analysis of the text index. This setting limits the number of steps (index checks) the algorithm spends on each data part. The budget is spent on the largest remaining mark ranges first. When it is exhausted, the ranges that were not fully analyzed are accepted as a whole, so the query stays correct but may read more granules than an unlimited search would select. A lower budget speeds up index analysis at the cost of reading more data. The limit is approximate rather than a strict cap on the analysis cost: the search can exceed it by roughly one round of splitting, and when the part is already divided into many ranges (for example, by the query condition cache), each of them is checked at least once regardless of the limit. The number of steps the search made for each data part is reported in the trace level log messages of the query, and the `IndexGenericExclusionSearchStepLimitReached` and `TextIndexGenericExclusionSearchStepLimitReached` profile events count how many times the budget was exhausted. The (default) value 0 means unlimited steps. Possible values: - 0 for unlimited steps, or any positive integer. )", 0, \ {"26.7", 0, 0, "New setting to limit the number of steps of the generic exclusion search over the primary key index."}) \ DECLARE(UInt64, merge_tree_max_rows_to_use_cache, (128 * 8192), R"( If ClickHouse should read more than `merge_tree_max_rows_to_use_cache` rows in one query, it does not use the cache of uncompressed blocks. 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](/reference/settings/server-settings/settings/uncompressed-cache#uncompressed_cache_size) server setting defines the size of the cache of uncompressed blocks. Possible values: - Any positive integer. )", 0) \ DECLARE(UInt64, merge_tree_max_bytes_to_use_cache, (192 * 10 * 1024 * 1024), R"( If ClickHouse should read more than `merge_tree_max_bytes_to_use_cache` bytes in one query, it does not use the cache of uncompressed blocks. 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](/reference/settings/server-settings/settings/uncompressed-cache#uncompressed_cache_size) server setting defines the size of the cache of uncompressed blocks. Possible values: - Any positive integer. )", 0) \ DECLARE(Bool, merge_tree_use_deserialization_prefixes_cache, true, R"( Enables caching of columns metadata from the file prefixes during reading from remote disks in MergeTree. )", 0, \ {"25.2", true, true, "A new setting to control the usage of deserialization prefixes cache in MergeTree"}) \ DECLARE(Bool, merge_tree_use_prefixes_deserialization_thread_pool, true, R"( Enables usage of the thread pool for parallel prefixes reading in Wide parts in MergeTree. Size of that thread pool is controlled by server setting `max_prefixes_deserialization_thread_pool_size`. )", 0, \ {"25.2", true, true, "A new setting controlling the usage of the thread pool for parallel prefixes deserialization in MergeTree"}) \ DECLARE(Bool, merge_tree_prefetch_json_shared_data_substreams, true, R"( Enables prefetching of JSON shared data substreams in Wide parts that are read by seeking to a mark, the data substream of the `SHARED` typed paths included. Such a prefetch reads from the beginning of the granule, which is usually not the position the substream is read from, so it can be wasted. Disable to skip these prefetches. )", 0, \ {"26.8", true, true, "New setting to control prefetching of JSON shared data substreams that are read by seeking to a mark in Wide parts."}) \ DECLARE(Bool, do_not_merge_across_partitions_select_final, false, R"( Improve FINAL queries by avoiding merges across different partitions. When enabled, during SELECT FINAL queries, parts from different partitions will not be merged together. Instead, merging will only occur within each partition separately. This can significantly improve query performance when working with partitioned tables. )", 0) \ DECLARE(Bool, enable_automatic_decision_for_merging_across_partitions_for_final, true, R"( If set, ClickHouse will automatically enable this optimization when the partition key expression is deterministic and all columns used in the partition key expression are included in the primary key. This automatic derivation ensures that rows with the same primary key values will always belong to the same partition, making it safe to avoid cross-partition merges. Floating-point key columns are excluded from this derivation. The `FINAL` comparator is coarser than value identity for `Float32`, `Float64` and `BFloat16`: `-0.0` compares equal to `0.0`, and every `NaN` bit pattern compares equal to every other. A partition expression can tell exactly those values apart, so rows the comparator treats as one key can land in different partitions, and skipping the cross-partition merge would return all of them. The exclusion also applies when a float is nested inside a key column, for example `Tuple(Float64, UInt8)` or `Array(Float64)`. )", 0, \ {"26.2", true, true, "New setting"}) \ DECLARE(Bool, split_parts_ranges_into_intersecting_and_non_intersecting_final, true, R"( Split parts ranges into intersecting and non intersecting during FINAL optimization )", 0, \ {"24.2", true, true, "Allow to split parts ranges into intersecting and non intersecting during FINAL optimization"}, \ {"24.1", false, true, "Allow to split parts ranges into intersecting and non intersecting during FINAL optimization"}) \ DECLARE(Bool, split_intersecting_parts_ranges_into_layers_final, true, R"( Split intersecting parts ranges into layers during FINAL optimization )", 0, \ {"24.2", true, true, "Allow to split intersecting parts ranges into layers during FINAL optimization"}, \ {"24.1", true, true, "Allow to split intersecting parts ranges into layers during FINAL optimization"}) \ DECLARE(Bool, apply_row_policy_after_final, true, R"( When enabled, row policies are applied after FINAL processing for *MergeTree tables. (Especially for ReplacingMergeTree) When the policy is deferred this way, PREWHERE is deferred with it so that the policy is still applied first (see `apply_prewhere_after_final` for deferring PREWHERE unconditionally). When disabled, row policies are applied before FINAL, which can cause different results when the policy filters out rows that should be used for deduplication in ReplacingMergeTree or similar engines. If the row policy expression is deterministic and depends only on non-floating-point columns in ORDER BY, it will still be applied before FINAL as an optimization, since such filtering cannot affect the deduplication result. A value computed once for the whole query, such as `currentUser()`, `now()` or the set of `IN (subquery)`, does not prevent this optimization; the set of a `Set` table, which can change while the query runs, does. Floating-point columns or columns containing floating-point (such as `Tuple(Float64, ...)`, `Array(Float64)`, `Nullable(Float64)`, etc.) are excluded because `-0.0` and `0.0` deduplicate as one key while a policy condition can tell them apart. `GraphiteMergeTree` rolls up rows with different times into one row, so for it only the path column counts, and only when it is the first `ORDER BY` column. Possible values: - 0 — Row policy is applied before FINAL. - 1 — Row policy is applied after FINAL (default). )", 0, \ {"25.10", true, true, "Setting was added as a fix for the post-#87303 regression where row policies and PREWHERE were applied before FINAL. PR #91065 introduced the setting and PR #97279 made the correctness-safe true the default. Recorded as {true, true} so compatibility never reverts to the pre-fix false behavior."}) \ DECLARE(Bool, apply_prewhere_after_final, false, R"( When enabled, PREWHERE conditions are applied after FINAL processing for ReplacingMergeTree and similar engines. This can be useful when PREWHERE references columns that may have different values across duplicate rows, and you want FINAL to select the winning row before filtering. When disabled, PREWHERE is applied during reading. Note: PREWHERE is also deferred, regardless of this setting, whenever a row policy is deferred by `apply_row_policy_after_final`, because the row policy must be applied before PREWHERE. That happens when the policy expression is non-deterministic, or reads a column that is not in ORDER BY, or reads an ORDER BY column whose type is or contains a floating-point type. Possible values: - 0 — PREWHERE is applied before FINAL, unless a deferred row policy defers it too (default). - 1 — PREWHERE is applied after FINAL. )", 0, \ {"25.12", false, false, "New setting. When enabled, PREWHERE conditions are applied after FINAL processing."}) \ DECLARE(Bool, defer_partition_pruning_after_final, true, R"( When enabled (default), partition pruning is skipped for `FINAL` queries on tables whose partition-key columns are not part of the sorting key. This is the correctness-safe behavior introduced in 26.3: `FINAL` may need to deduplicate rows that share a primary key but live in different partitions, and partition pruning would silently exclude such rows from the deduplication input. When disabled, partition pruning is applied even with `FINAL`, restoring the pre-26.3 behavior. This can be substantially faster for queries with `WHERE` predicates on the partition column, but is only correct when rows with the same primary key cannot exist in different partitions — e.g. event-log tables whose partition column is set at insert time and never changes. This setting only affects partitioned tables whose partition-key columns are not contained in the sorting key; for other tables partition pruning is always applied. Possible values: - 0 — Apply partition pruning before `FINAL` (pre-26.3 behavior, faster but unsafe in the general case). - 1 — Defer partition pruning to after `FINAL` (default, correctness-safe). )", 0, \ {"26.5", true, true, "Setting newly added in 26.5 to gate the FINAL partition-pruning behavior that shipped silently in 26.3 (https://github.com/ClickHouse/ClickHouse/pull/98242). The meaningful semantic change is registered under the 26.3 block so `compatibility = '26.2'` reverts it; this entry exists so the upgrade-from-26.4 check accepts the newly-introduced name."}, \ {"26.3", false, true, "Gates the FINAL planner's unconditional skipping of partition pruning when the partition-key column is not in the sorting key. The behavior change itself shipped silently in 26.3 via https://github.com/ClickHouse/ClickHouse/pull/98242; this entry retroactively documents it so `compatibility = '26.2'` restores the pre-regression behavior (0 = prune before FINAL, fast; 1 = defer pruning, correctness-safe)."}) \ \ DECLARE(UInt64, mysql_max_rows_to_insert, 65536, R"( The maximum number of rows in MySQL batch insertion of the MySQL storage engine )", 0) \ DECLARE(Bool, mysql_map_string_to_text_in_show_columns, true, R"( When enabled, [String](/reference/data-types/string) ClickHouse data type will be displayed as `TEXT` in [SHOW COLUMNS](/reference/statements/show#show_columns). Has an effect only when the connection is made through the MySQL wire protocol. - 0 - Use `BLOB`. - 1 - Use `TEXT`. )", 0, \ {"24.2", false, true, "Reduce the configuration effort to connect ClickHouse with BI tools."}) \ DECLARE(Bool, mysql_map_fixed_string_to_text_in_show_columns, true, R"( When enabled, [FixedString](/reference/data-types/fixedstring) ClickHouse data type will be displayed as `TEXT` in [SHOW COLUMNS](/reference/statements/show#show_columns). Has an effect only when the connection is made through the MySQL wire protocol. - 0 - Use `BLOB`. - 1 - Use `TEXT`. )", 0, \ {"24.2", false, true, "Reduce the configuration effort to connect ClickHouse with BI tools."}) \ \ DECLARE(UInt64, optimize_min_equality_disjunction_chain_length, 3, R"( The minimum length of the expression `expr = x1 OR ... expr = xN` for optimization )", 0) \ DECLARE(UInt64, optimize_min_inequality_conjunction_chain_length, 3, R"( The minimum length of the expression `expr <> x1 AND ... expr <> xN` for optimization )", 0) \ \ DECLARE(UInt64, min_bytes_to_use_direct_io, 0, R"( The minimum data volume required for using direct I/O access to the storage disk. 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. Possible values: - 0 — Direct I/O is disabled. - Positive integer. )", 0) \ DECLARE(UInt64, min_bytes_to_use_mmap_io, 0, R"( This is an experimental setting. Sets the minimum amount of memory for reading large files without copying data from the kernel to userspace. Recommended threshold is about 64 MB, because [mmap/munmap](https://en.wikipedia.org/wiki/Mmap) is slow. It makes sense only for large files and helps only if data reside in the page cache. Possible values: - Positive integer. - 0 — Big files read with only copying data from kernel to userspace. )", 0) \ DECLARE(Bool, checksum_on_read, true, R"( Validate checksums on reading. It is enabled by default and should be always enabled in production. Please do not expect any benefits in disabling this setting. It may only be used for experiments and benchmarks. The setting is only applicable for tables of MergeTree family. Checksums are always validated for other table engines and when receiving data over the network. )", 0) \ \ DECLARE(Bool, use_lightweight_primary_key_index_analysis, true, R"( Optimize primary key index analysis for `MergeTree` tables with long primary keys. When enabled, the run time of index analysis mainly depends on the complexity of the query's filter (the key columns it actually uses), not on the length of the primary key — so extending the sorting key has negligible extra overhead on index analysis for queries that filter on only a few of its columns. Possible values: - 0 — Disabled. All primary key columns are processed during index analysis. - 1 — Enabled. )", 0, \ {"26.6", false, true, "New setting to optimize primary key index analysis for tables with long primary keys"}) \ DECLARE_WITH_ALIAS(Bool, use_partition_pruning, true, R"( Use partition key to prune partitions during query execution for MergeTree tables. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, use_partition_key, \ {"26.3", true, true, "New setting controlling whether MergeTree uses partition key for pruning. 'use_partition_key' is an alias for this setting."}) \ DECLARE(Bool, force_index_by_date, false, R"( Disables query execution if the index can't be used by date. Works with tables in the MergeTree family. 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](/reference/engines/table-engines/mergetree-family/mergetree). )", 0) \ DECLARE(Bool, use_primary_key, true, R"( Use the primary key to prune granules during query execution for MergeTree tables. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, \ {"26.1", true, true, "New setting controlling whether MergeTree uses the primary key for granule-level pruning."}) \ DECLARE(Bool, optimize_mutations_with_partition_pruning, true, R"( When enabled, ClickHouse automatically detects partition key conditions in the WHERE clause of `ALTER TABLE UPDATE`/`DELETE` mutations and lightweight `UPDATE`/`DELETE` statements on tables of the `ReplicatedMergeTree` family and only processes the affected partitions instead of all partitions. This automatic pruning currently applies only to replicated tables. On non-replicated `MergeTree` tables, use an explicit `IN PARTITION` clause to limit a mutation to specific partitions. Possible values: - 0 — Disabled. Mutations and lightweight updates will process all partitions. - 1 — Enabled. Mutations and lightweight updates will only process partitions that match the WHERE condition. )", 0, \ {"26.9", false, true, "New setting to automatically prune partitions for mutations based on WHERE clause"}) \ DECLARE(Bool, use_constant_folding_in_index_analysis, false, R"( Substitute partition-level constants into the filter predicate when analyzing per-part primary key and skip indexes. When the partition key appears in the filter together with primary-key or skip-index columns, this lets index analysis fold the partition value separately within each part. It is most useful for disjunctive filters whose branches target different partitions. For example, with `PARTITION BY a` and `ORDER BY b`: ```sql SELECT * FROM t WHERE (a = 1 AND b >= 1) OR (a = 2 AND b > 10) OR (a = 3 AND b > 10) ``` For the part in partition `a = 1` the condition folds to `b >= 1`, while for partitions `a = 2` and `a = 3` it folds to `b > 10`, so each part is analyzed with the predicate that actually applies to it. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, \ {"26.7", false, false, "New setting to fold partition-level constants into the filter predicate per part during MergeTree index analysis, improving pruning for filters whose branches depend on partition values."}) \ DECLARE(Bool, use_partition_minmax_for_primary_key_pruning, true, R"( Use partition minmax index bounds to prune more granules during primary key analysis for `MergeTree` tables, when a primary key column is also an input column of the partition key. For example, in a `MergeTree` table with `ORDER BY (id, event_time)` and `PARTITION BY toYYYYMM(event_time)`, ClickHouse will use the partition minmax index on `event_time` during primary key index analysis to make more informed granule-pruning decisions. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, \ {"26.7", false, true, "New setting to use the part's partition minmax to prune more granules during primary key analysis for `MergeTree` tables, when a primary key column is also an input column of the partition key."}) \ DECLARE(Bool, force_primary_key, false, R"( Disables query execution if indexing by the primary key is not possible. Works with tables in the MergeTree family. 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](/reference/engines/table-engines/mergetree-family/mergetree). The check applies to the primary key of the table itself. A projection serves the query only when the query also restricts data ranges by that projection's own key; otherwise the projection is skipped and the table is read instead. A projection forced with [force_optimize_projection](#force_optimize_projection) whose key is not used makes the query throw an exception. )", 0) \ DECLARE(Bool, use_skip_indexes, true, R"( Use data skipping indexes during query execution. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0) \ DECLARE(Bool, use_skip_indexes_if_final, true, R"( Controls whether skipping indexes are used when executing a query with the FINAL modifier. Skip indexes may exclude rows (granules) containing the latest data, which could lead to incorrect results from a query with the `FINAL` modifier. When this setting is enabled, skipping indexes are applied even with the `FINAL` modifier, potentially improving performance. Correct results still depend on setting `use_skip_indexes_if_final_exact_mode`, which is enabled by default and scans the additional parts that overlap the ranges returned by the skip index. The risk of missing recent updates applies only if that setting is disabled. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, \ {"25.6", 0, 1, "Change in default value of setting"}) \ DECLARE(Bool, use_skip_indexes_if_final_exact_mode, true, R"( Controls whether granules returned by a skipping index are expanded in newer parts to return correct results when executing a query with the FINAL modifier. Using skip indexes may exclude rows (granules) containing the latest data which could lead to incorrect results. This setting can ensure that correct results are returned by scanning newer parts that have overlap with the ranges returned by the skip index. This setting should be disabled only if approximate results based on looking up the skip index are okay for an application. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, \ {"25.6", 0, 1, "Change in default value of setting"}, \ {"25.5", 0, 0, "This setting was introduced to help FINAL query return correct results with skip indexes"}) \ DECLARE(Bool, use_skip_indexes_on_data_read, true, R"( Enable using data skipping indexes during data reading. When enabled, skip indexes are evaluated dynamically at the time each data granule is being read, rather than being analyzed in advance before query execution begins. This can reduce query startup latency. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, \ {"26.1", false, true, "Default enable"}, \ {"25.9", false, false, "New setting"}) \ DECLARE(Bool, use_skip_indexes_for_disjunctions, true, R"( Evaluate WHERE filters with mixed AND and OR conditions using skip indexes. Example: WHERE A = 5 AND (B = 5 OR C = 5). If disabled, skip indexes are still used to evaluate WHERE conditions but they must only contain AND-ed clauses. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, \ {"25.12", false, true, "New setting"}) \ DECLARE(UInt64, use_skip_indexes_for_disjunctions_max_rpn_elements, 128, R"( Maximum number of elements in the internal representation (RPN) of a WHERE filter for which `use_skip_indexes_for_disjunctions` is applied. Roughly, every condition and every `AND`, `OR` and `NOT` counts as one element: for example, `A = 5 OR B = 5 OR C = 5` has 5 elements. The elements are counted after the filter is rewritten for index analysis: for example, `A = 1 OR A = 2 OR A = 3` becomes `A IN (1, 2, 3)`, which is one element (see `optimize_min_equality_disjunction_chain_length`), and `coalesce(A, B) = 5` is expanded into several conditions (see `allow_key_condition_coalesce_rewrite`). For filters with more elements, each skip index is evaluated on its own and cannot skip granules for conditions on different columns connected by `OR`. During index analysis, the partial results take one bit per element per granule of each data part, and combining them takes time proportional to the number of elements for every granule. Keep this in mind when setting 0 (no limit). Possible values: - 0 — No limit. - Positive integer — Maximum number of elements. )", 0, \ {"26.11", 32, 128, "New setting, previously the limit was hard-coded to 32"}) \ DECLARE(Bool, use_skip_indexes_for_top_k, true, R"( Enable using data skipping indexes for TopK filtering. When enabled, if a minmax skip index exists on the column in `ORDER BY LIMIT n` query, optimizer will attempt to use the minmax index to skip granules that are not relevant for the final result . This can reduce query latency. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, \ {"26.5", false, true, "Enable using data skipping indexes for TopK filtering by default"}, \ {"25.12", false, false, "New setting."}) \ DECLARE(Bool, use_statistics_for_part_pruning, true, R"( Use statistics to filter out parts during query execution. When enabled, pruning in SELECT queries will use column statistics (e.g. MinMax statistics) to eliminate parts that cannot contain matching data before reading any data. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, \ {"26.4", false, true, "New setting to use statistics for part pruning during query execution."}) \ DECLARE(UInt64, min_marks_per_part_to_load_statistics, 64, R"( The minimum number of marks left to read after the primary key analysis, per data part whose statistics are not in memory yet, for column statistics to be loaded for pruning parts and for ordering the conditions of `PREWHERE`. Loading statistics costs a few reads per data part, and on a cold start it can take longer than reading the data itself when the primary key already narrows the read to a small number of granules. If fewer marks than this setting multiplied by the number of parts whose statistics would be loaded are left to read, statistics are not loaded for these optimizations: parts are not pruned by statistics, and `PREWHERE` conditions are ordered by the sizes of their columns, as for tables without statistics. Statistics that are already in memory are used regardless of the size of the read. Answering `min`, `max` and `count` from statistics (see `use_statistics_for_min_max_aggregation`) replaces the read and is not affected by this setting. Possible values: - 0 — Load statistics regardless of the size of the read. - Positive integer — The number of marks per data part. )", 0, \ {"26.11", 0, 64, "New setting to skip loading statistics when the primary key leaves only a small read."}) \ DECLARE(Bool, use_statistics_for_min_max_aggregation, true, R"( Answer `min`, `max` and `count` aggregations from per-part column statistics instead of reading data. When enabled, a query of the form `SELECT min(column), max(column), count() FROM table` without `GROUP BY` and filters is answered from column statistics (e.g. MinMax statistics, see the `auto_statistics_types` MergeTree setting) for the data parts that have them materialized, and only the remaining parts are read. `count()` is also answered together with the aggregations of `use_statistics_for_sum_avg_aggregation`. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, \ {"26.9", false, true, "New setting to answer `min`, `max` and `count` aggregations without `GROUP BY` and filters from per-part column statistics for parts that have them materialized, reading only the remaining parts. previous_value=false so `compatibility` with versions before 26.9 keeps the optimization disabled and restores the pre-existing plan."}) \ DECLARE(Bool, use_statistics_for_sum_avg_aggregation, true, R"( Answer `sum`, `avg` and `sumCount` aggregations over integer and `Decimal` columns that are not `Nullable` or `LowCardinality`, without `GROUP BY` and filters, from per-part column statistics (the `basic` statistics type, see the `auto_statistics_types` `MergeTree` setting) for the data parts that have them materialized, and read only the remaining parts. `count(column)` of a column that is not `Nullable` or `LowCardinality` is answered there from the number of rows. The result is exactly the same as when reading the data. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, \ {"26.11", false, true, "New setting to answer `sum`, `avg`, `sumCount` and `count(column)` aggregations without `GROUP BY` and filters from per-part column statistics. previous_value=false so `compatibility` with versions before 26.11 keeps the optimization disabled and restores the pre-existing plan."}) \ DECLARE(Bool, use_top_k_dynamic_filtering, true, R"( Enable dynamic filtering optimization when executing a `ORDER BY LIMIT n` query. When enabled, the query executor will try to skip granules and rows that will not be part of the final `top N` rows in the resultset. This optimization is dynamic in nature and latency improvements depends on data distribution and presence of other predicates in the query. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, \ {"26.5", false, true, "Enable dynamic filtering optimization for TopK queries by default"}, \ {"25.12", false, false, "New setting."}) \ DECLARE(Bool, enable_group_by_top_k_optimization, true, R"( Enable TopK filtering optimization during aggregation in `GROUP BY keys ORDER BY LIMIT K` queries, and in `GROUP BY keys LIMIT K` queries without `ORDER BY` (any `K` groups are a valid result there, so a sort over all keys is synthesized). When enabled, the aggregator maintains a bounded heap of the top `K` keys seen so far and skips inserting new rows into the hash table when their grouping key cannot make it into the final result. This avoids aggregating rows that would be discarded by the subsequent `ORDER BY ... LIMIT`, and when the heap ranks the full `GROUP BY` key it also prunes evicted groups out of the intermediate hash table, bounding its size by the `LIMIT` instead of the number of distinct keys. When the `ORDER BY` covers only a proper prefix of the `GROUP BY` keys, the ranking cannot identify a full group, so only row skipping applies: the hash table keeps every admitted group and can still grow with the cardinality of the remaining key columns. The optimization is disabled when the requested `LIMIT` is higher than [query_plan_max_limit_for_top_k_optimization](#query_plan_max_limit_for_top_k_optimization) or than the hard cap of `100000`, because the memory and CPU cost of the heap grows with the requested `LIMIT`. The optimization is skipped for query shapes where pruning groups could change the result, including `WITH TOTALS`, `HAVING`, `QUALIFY`, window functions, `ROLLUP`/`CUBE`/`GROUPING SETS`, `LIMIT WITH TIES`, a `COLLATE` on any of the matched `GROUP BY` keys (a `COLLATE` on a later `ORDER BY` column past the full key prefix cannot affect which groups qualify, so it does not disable the optimization), `ORDER BY` on an aggregate or on anything that is not a leading prefix of the `GROUP BY` keys, and when `max_rows_to_group_by` or `exact_rows_before_limit` is set. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, \ {"26.8", false, true, "New setting to control the TopK filtering optimization during aggregation in `GROUP BY key ORDER BY key LIMIT N` queries."}) \ DECLARE(UInt64, group_by_top_k_optimization_observation_rows, 65536, R"( For `enable_group_by_top_k_optimization`: the number of rows each aggregation stream observes before freezing a full top-K heap that skipped less than 10% of input rows and evicted fewer keys than its capacity. A frozen heap means aggregation continues as if the optimization were disabled. The effective window is at least twice the heap's reserved size, so a heap always gets a chance to fill before being judged. `0` disables this freeze (the heap still freezes when a boundary tie-set overgrows it). This has no effect on `GROUP BY keys LIMIT K` queries without `ORDER BY`, where the freeze is always disabled: that shape's plan contains a synthesized sort that only pays off while the heap bounds the hash table, so freezing the heap would leave a plan slower than the un-optimized one. )", EXPERIMENTAL, \ {"26.8", 65536, 65536, "New experimental setting: rows each aggregation stream observes before declaring a full top-K heap that never rejected anything pure overhead and freezing it."}) \ DECLARE(Bool, group_by_top_k_optimization_shared_boundary, true, R"( For `enable_group_by_top_k_optimization`: share the tightest skip boundary between the aggregation threads. Each thread publishes the boundary of its own top-K set once per processed block when it has tightened, and every thread skips rows against the best published boundary instead of only its own. A set of `K` keys strictly better than a row proves the row cannot reach the final result regardless of which thread holds them, so the sharing does not change the result; it only lets threads whose local keys rank poorly (e.g. when the key values are clustered across the table) skip rows they would otherwise aggregate for nothing. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, \ {"26.10", false, true, "New setting: share the tightest top-K skip boundary between aggregation threads, so threads whose local keys rank poorly can skip rows against a boundary published by another thread. previous_value=false so `compatibility` with versions before 26.10 restores per-thread boundaries."}) \ DECLARE(Bool, use_top_k_dynamic_filtering_for_variable_length_types, false, R"( Allow `use_top_k_dynamic_filtering` to apply when the sort column has a variable-length data type (e.g. `String`, `Array`, `Map`, `Tuple` containing variable-length elements). For such types, the per-row threshold comparison performed by the dynamic filter can outweigh its savings when the column's lexicographic minimum dominates (e.g. mostly empty strings) and few granules can be skipped. In that case the dynamic filter degrades query latency rather than improving it. When this setting is `0`, dynamic filtering is restricted to columns whose values have a fixed maximum size in memory (numbers, `Date`, `DateTime`, `FixedString`, `Enum`, `Nullable` of such types, `Tuple` of such types). When set to `1`, dynamic filtering applies to variable-length types as well. Reads of Parquet files still skip whole row groups by the statistics of a `String` sort column when this setting is `0`; the setting only controls the per-row filter. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, \ {"26.5", true, false, "Disable `use_top_k_dynamic_filtering` for variable-length sort columns (e.g. `String`) by default; the previous behavior had the optimization apply unconditionally and is preserved under `compatibility`."}) \ DECLARE(Bool, use_top_k_dynamic_filtering_for_single_string_sort_column, true, R"( Apply `use_top_k_dynamic_filtering` to a `MergeTree` table when `ORDER BY` has a single `String` column (also inside `Nullable`), even if `use_top_k_dynamic_filtering_for_variable_length_types` is `0`. For such a column, the filter also drops the rows equal to the threshold once most rows of a block are equal to it (for example, a column of mostly empty strings). Each threshold value is checked on one block: the first one in which most rows pass the filter. Other sources, such as Parquet files, are not affected. Possible values: - 0 - Disabled. - 1 - Enabled. )", 0, \ {"26.11", false, true, "New setting: TopN dynamic filtering for a single `String` `ORDER BY` column of a `MergeTree` table."}) \ DECLARE(Bool, enable_group_by_top_k_dynamic_filtering, true, R"( For [enable_group_by_top_k_optimization](#enable_group_by_top_k_optimization): when the first ranked `GROUP BY` key is a column read from a `MergeTree` table, the aggregation publishes the boundary of its top-K heap to the reading step as soon as the heap holds `LIMIT` keys. The reading step then drops rows whose key lies beyond the boundary before the other columns are read (`PREWHERE`), and skips whole granules that lie beyond it using the primary key or a `minmax` skip index on that column. This applies to `GROUP BY key ORDER BY key LIMIT n` and to `GROUP BY key LIMIT n` without `ORDER BY`, where any `n` groups are a valid answer. It is not applied to a read with `FINAL` or with parallel replicas: `FINAL` must see every version of a row, and the boundary is not carried to the reads on remote replicas. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, \ {"26.10", false, true, "New setting: `GROUP BY key [ORDER BY key] LIMIT n` publishes the top-K heap boundary to the `MergeTree` reading step, which filters rows and skips granules by it. `compatibility` below 26.10 disables it."}) \ DECLARE(UInt64, query_plan_max_limit_for_top_k_optimization, 1000, R"(Control maximum limit value that allows to evaluate query plan for TopK optimization by using minmax skip index and dynamic threshold filtering. If zero, there is no limit. This setting also controls the behavior of [enable_group_by_top_k_optimization](#enable_group_by_top_k_optimization). )", 0, \ {"25.12", 0, 1000, "New setting."}) \ DECLARE(Bool, materialize_skip_indexes_on_insert, true, R"( If INSERTs build and store skip indexes. If disabled, skip indexes will only be built and stored [during merges](/reference/settings/merge-tree-settings/materialize#materialize_skip_indexes_on_merge) or by explicit [MATERIALIZE INDEX](/reference/statements/alter/skipping-index#materialize-index). See also [exclude_materialize_skip_indexes_on_insert](#exclude_materialize_skip_indexes_on_insert). )", 0, \ {"24.6", true, true, "Added new setting to allow to disable materialization of skip indexes on insert"}) \ DECLARE(String, exclude_materialize_skip_indexes_on_insert, "", R"( Excludes specified skip indexes from being built and stored during INSERTs. The excluded skip indexes will still be built and stored [during merges](/reference/settings/merge-tree-settings/materialize#materialize_skip_indexes_on_merge) or by an explicit [MATERIALIZE INDEX](/reference/statements/alter/skipping-index#materialize-index) query. Has no effect if [materialize_skip_indexes_on_insert](#materialize_skip_indexes_on_insert) is false. Example: ```sql CREATE TABLE tab ( a UInt64, b UInt64, INDEX idx_a a TYPE minmax, INDEX idx_b b TYPE set(3) ) ENGINE = MergeTree ORDER BY tuple(); SET exclude_materialize_skip_indexes_on_insert='idx_a'; -- idx_a will be not be updated upon insert --SET exclude_materialize_skip_indexes_on_insert='idx_a, idx_b'; -- neither index would be updated on insert INSERT INTO tab SELECT number, number / 50 FROM numbers(100); -- only idx_b is updated -- since it is a session setting it can be set on a per-query level INSERT INTO tab SELECT number, number / 50 FROM numbers(100, 100) SETTINGS exclude_materialize_skip_indexes_on_insert='idx_b'; ALTER TABLE tab MATERIALIZE INDEX idx_a; -- this query can be used to explicitly materialize the index SET exclude_materialize_skip_indexes_on_insert = DEFAULT; -- reset setting to default ``` )", 0, \ {"25.10", "", "", "New setting."}) \ DECLARE(Bool, per_part_index_stats, false, R"( Logs index statistics per part )", 0, \ {"25.8", false, false, "New setting."}) \ DECLARE(Bool, materialize_statistics_on_insert, true, R"( If statistics are build and materialized for newly inserted parts. Even if disabled, statistics are still be build and stored during merges or by explicit MATERIALIZE STATISTICS. Only tables whose current size plus the size of the block being written, does not exceed `materialize_statistics_on_insert_max_table_size` are affected. )", 0, \ {"26.8", false, true, "Materialize column statistics on INSERT by default for tables below `materialize_statistics_on_insert_max_table_size`, so cost-based join reordering has good estimates on freshly-loaded dimension tables."}, \ {"26.4", true, false, "Disable building statistics on INSERT by default, rely on merges instead"}, \ {"24.6", true, true, "Added new setting to allow to disable materialization of statistics on insert"}) \ DECLARE(UInt64, materialize_statistics_on_insert_max_table_size, 26843545600, R"( Only build and store column statistics for newly inserted parts (see `materialize_statistics_on_insert`) for tables whose current size plus the block being written, does not exceed this value. `0` means no size limit. )", 0, \ {"26.8", 0, 26843545600, "New setting."}) \ DECLARE_WITH_ALIAS(String, ignore_data_skipping_indexes, "", R"( Ignores the skipping indexes specified if used by the query. Consider the following example: ```sql CREATE TABLE data ( key Int, x Int, y Int, INDEX x_idx x TYPE minmax GRANULARITY 1, INDEX y_idx y TYPE minmax GRANULARITY 1, INDEX xy_idx (x,y) TYPE minmax GRANULARITY 1 ) Engine=MergeTree() ORDER BY key; INSERT INTO data VALUES (1, 2, 3); SELECT * FROM data; SELECT * FROM data SETTINGS ignore_data_skipping_indices=''; -- query will produce CANNOT_PARSE_TEXT error. SELECT * FROM data SETTINGS ignore_data_skipping_indices='x_idx'; -- Ok. SELECT * FROM data SETTINGS ignore_data_skipping_indices='na_idx'; -- Ok. SELECT * FROM data WHERE x = 1 AND y = 1 SETTINGS ignore_data_skipping_indices='xy_idx',force_data_skipping_indices='xy_idx' ; -- query will produce INDEX_NOT_USED error, since xy_idx is explicitly ignored. SELECT * FROM data WHERE x = 1 AND y = 2 SETTINGS ignore_data_skipping_indices='xy_idx'; ``` The query without ignoring any indexes: ```sql EXPLAIN indexes = 1 SELECT * FROM data WHERE x = 1 AND y = 2; Expression ((Projection + Before ORDER BY)) Filter (WHERE) ReadFromMergeTree (default.data) Indexes: PrimaryKey Condition: true Parts: 1/1 Granules: 1/1 Skip Name: x_idx Description: minmax GRANULARITY 1 Parts: 0/1 Granules: 0/1 Skip Name: y_idx Description: minmax GRANULARITY 1 Parts: 0/0 Granules: 0/0 Skip Name: xy_idx Description: minmax GRANULARITY 1 Parts: 0/0 Granules: 0/0 ``` Ignoring the `xy_idx` index: ```sql EXPLAIN indexes = 1 SELECT * FROM data WHERE x = 1 AND y = 2 SETTINGS ignore_data_skipping_indices='xy_idx'; Expression ((Projection + Before ORDER BY)) Filter (WHERE) ReadFromMergeTree (default.data) Indexes: PrimaryKey Condition: true Parts: 1/1 Granules: 1/1 Skip Name: x_idx Description: minmax GRANULARITY 1 Parts: 0/1 Granules: 0/1 Skip Name: y_idx Description: minmax GRANULARITY 1 Parts: 0/0 Granules: 0/0 ``` Works with tables in the MergeTree family. )", 0, ignore_data_skipping_indices, \ {"26.10", "", "", "Added an alias for setting `ignore_data_skipping_indices`."}) \ \ DECLARE_WITH_ALIAS(String, force_data_skipping_indexes, "", R"( Disables query execution if passed data skipping indices wasn't used. 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. ``` )", 0, force_data_skipping_indices, \ {"26.10", "", "", "Added an alias for setting `force_data_skipping_indices`."}) \ DECLARE_WITH_ALIAS(Bool, secondary_indexes_enable_bulk_filtering, true, R"( Enable the bulk filtering algorithm for indices. It is expected to be always better, but we have this setting for compatibility and control. )", 0, secondary_indices_enable_bulk_filtering, \ {"26.10", true, true, "Added an alias for setting `secondary_indices_enable_bulk_filtering`."}, \ {"25.5", false, true, "A new algorithm for filtering by data skipping indices"}) \ DECLARE(Float, max_streams_to_max_threads_ratio, 1, R"( Allows you to use more sources than the number of threads - to more evenly distribute work across threads. It is assumed that this is a temporary solution since it will be possible in the future to make the number of sources equal to the number of threads, but for each source to dynamically select available work for itself. )", 0) \ DECLARE(Float, max_streams_multiplier_for_merge_tables, 5, R"( Ask more streams when reading from Merge table. Streams will be spread across tables that Merge table will use. This allows more even distribution of work across threads and is especially helpful when merged tables differ in size. The number of streams that read simultaneously is capped by this multiplier as well - except for a `Merge` table read with plan-based parallel replicas ([parallel_replicas_allow_merge_tables](#parallel_replicas_allow_merge_tables)), which is expanded into a union of the reads from its underlying tables and is therefore capped by [max_streams_for_union_step](#max_streams_for_union_step), like any other union. )", 0) \ \ DECLARE(String, network_compression_method, "ZSTD", R"( The codec for compressing the client/server and server/server communication over the native protocol and the response of an HTTP request made with `compress=1`, which uses the same frame format. The streaming exchange between the tasks of a distributed query plan (`make_distributed_plan`) uses [distributed_plan_exchange_compression_method](#distributed_plan_exchange_compression_method) instead. Possible values: - `NONE` — no compression. - `LZ4` — use the LZ4 codec. - `LZ4HC` — use the LZ4HC codec. - `ZSTD` — use the ZSTD codec. **See Also** - [network_zstd_compression_level](#network_zstd_compression_level) )", 0, \ {"26.9", "LZ4", "ZSTD", "Switched the default compression method for client/server and server/server communication from `LZ4` to `ZSTD` to reduce network traffic."}) \ \ DECLARE(Int64, network_zstd_compression_level, 3, R"( Adjusts the level of ZSTD compression. Used only when [network_compression_method](#network_compression_method) is set to `ZSTD`. The streaming exchange of a distributed query plan uses it only when [distributed_plan_exchange_compression_method](#distributed_plan_exchange_compression_method) is empty. Possible values: - Positive integer from 1 to 15. )", 0, \ {"26.9", 1, 3, "Aligned the default network `ZSTD` compression level with the new default on-disk `ZSTD(3)` compression."}) \ \ DECLARE(Int64, zstd_window_log_max, 0, R"( Allows you to select the max window log of ZSTD (it will not be used for MergeTree family) )", 0) \ \ DECLARE(UInt64, priority, 0, R"( Priority of the query. 1 - the highest, higher value - lower priority; 0 - do not use priorities. )", 0) \ DECLARE(Bool, log_queries, true, R"( Setting up query logging. Queries sent to ClickHouse with this setup are logged according to the rules in the [query_log](/reference/settings/server-settings/settings/query#query_log) server configuration parameter. Example: ```text log_queries=1 ``` )", 0) \ DECLARE(Bool, log_formatted_queries, false, R"( Allows to log formatted queries to the [system.query_log](/reference/system-tables/query_log) system table (populates `formatted_query` column in the [system.query_log](/reference/system-tables/query_log)). Possible values: - 0 — Formatted queries are not logged in the system table. - 1 — Formatted queries are logged in the system table. )", 0) \ DECLARE(LogQueriesType, log_queries_min_type, QueryLogElementType::QUERY_START, R"( `query_log` minimal type to log. Possible values: - `QUERY_START` (`=1`) - `QUERY_FINISH` (`=2`) - `EXCEPTION_BEFORE_START` (`=3`) - `EXCEPTION_WHILE_PROCESSING` (`=4`) Can be used to limit which entities will go to `query_log`, say you are interested only in errors, then you can use `EXCEPTION_WHILE_PROCESSING`: ```text log_queries_min_type='EXCEPTION_WHILE_PROCESSING' ``` )", 0) \ DECLARE(Milliseconds, log_queries_min_query_duration_ms, 0, R"( If enabled (non-zero), queries faster than the value of this setting will not be logged (you can think about this as a `long_query_time` for [MySQL Slow Query Log](https://dev.mysql.com/doc/refman/5.7/slow-query-log.html)), and this basically means that you will not find them in the following tables: - `system.query_log` - `system.query_thread_log` Only the queries with the following type will get to the log: - `QUERY_FINISH` - `EXCEPTION_WHILE_PROCESSING` - Type: milliseconds - Default value: 0 (any query) )", 0) \ DECLARE(UInt64, log_queries_cut_to_length, 100000, R"( If query length is greater than a specified threshold (in bytes), then cut query when writing to query log. Also limit the length of printed query in ordinary text log. )", 0) \ DECLARE(Float, log_queries_probability, 1., R"( Allows a user to write to [query_log](/reference/system-tables/query_log), [query_thread_log](/reference/system-tables/query_thread_log), and [query_views_log](/reference/system-tables/query_views_log) system tables only a sample of queries selected randomly with the specified probability. It helps to reduce the load with a large volume of queries in a second. Possible values: - 0 — Queries are not logged in the system tables. - Positive floating-point number in the range [0..1]. For example, if the setting value is `0.5`, about half of the queries are logged in the system tables. - 1 — All queries are logged in the system tables. )", 0) \ DECLARE(UInt64, session_query_ids_history_size, 1000, R"( The maximum number of query ids kept in the session-local history exposed through the [`system.session_query_ids`](/reference/system-tables/session_query_ids) system table. The query id of every non-internal query executed in the session is recorded there at query start; when the history exceeds this size, the oldest entries are evicted first. The value is read at query start, before the query is parsed, so a `SETTINGS` clause of the query itself does not affect whether that query is recorded; use `SET`, an HTTP URL parameter, or a settings profile instead. Possible values: - Positive integer. - 0 — Recording is disabled; entries recorded earlier stay in the table. )", 0, \ {"26.9", 0, 1000, "New setting limiting the size of the session-local query id history exposed through the new `system.session_query_ids` system table. The previous value `0` (recording disabled) reproduces the pre-26.9 behavior."}) \ \ DECLARE(Bool, log_processors_profiles, true, R"( Write time that processor spent during execution/waiting for data to `system.processors_profile_log` table. See also: - [`system.processors_profile_log`](/reference/system-tables/processors_profile_log) - [`EXPLAIN PIPELINE`](/reference/statements/explain#explain-pipeline) )", 0, \ {"24.3", false, true, "Enable by default"}) \ DECLARE(Bool, log_query_plans, false, R"( Write the query plan that was executed, together with its per-step runtime statistics, to the `query_plan` column of [`system.query_log`](/reference/system-tables/query_log). The column has the `JSON` type, so the statistics are stored as numbers and can be aggregated by a query rather than only read. The plan carries the same information [`EXPLAIN ANALYZE`](/reference/statements/explain#explain-analyze) shows — the tree of steps, what each step does, and per-step rows, bytes, wall-clock time and parallelism. Only `SELECT` queries executed with the analyzer (`enable_analyzer = 1`, the default) are captured, and only where the row itself is written, so [`log_queries`](/reference/settings/session-settings/log#log_queries) must also be enabled. A query that failed during execution is captured with the plan it was running but without statistics. The column is empty on `QueryStart` rows, because no plan exists yet when they are written. Enabling this setting makes the captured query collect per-processor timings, which is the same instrumentation [`log_processors_profiles`](/reference/settings/session-settings/log#log_processors_profiles) uses, so it is not free. Queries that are not captured are unaffected. That cost is decided before the query runs, so a captured query pays it even where its row is dropped afterwards by [`log_queries_min_type`](/reference/settings/session-settings/log#log_queries_min_type) or [`log_queries_min_query_duration_ms`](/reference/settings/session-settings/log#log_queries_min_query_duration_ms) — neither is knowable that early. A query answered from the [query cache](/concepts/features/performance/caches/query-cache) executes no plan and so has none to store. It also causes step descriptions produced by plan optimizations (for example merged expressions) to be retained rather than discarded, which makes them visible in `system.processors_profile_log.plan_step_description` as well. See also: - [`system.query_log`](/reference/system-tables/query_log) - [`EXPLAIN PLAN`](/reference/statements/explain#explain-plan) )", EXPERIMENTAL, \ {"26.11", false, false, "New setting to capture the query plan actually executed, together with per-step runtime statistics."}) \ DECLARE(DistributedProductMode, distributed_product_mode, DistributedProductMode::DENY, R"( Changes the behaviour of [distributed subqueries](/reference/statements/in). 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. Restrictions: - 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. - Not used for a table-valued [remote](/reference/functions/table-functions/remote) function. Possible values: - `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. )", IMPORTANT) \ \ DECLARE(UInt64, max_concurrent_queries_for_all_users, 0, R"( Throw exception if the current number of simultaneously processed queries reaches or exceeds this setting's value. Example: `max_concurrent_queries_for_all_users` can be set to 99 for all users and database administrator can set it to 100 for themselves to run queries for investigation even when the server is overloaded. Modifying the setting for one query or user does not affect other queries. Possible values: - Positive integer. - 0 — No limit. **Example** ```xml 99 ``` **See Also** - [max_concurrent_queries](/reference/settings/server-settings/settings/max-concurrent#max_concurrent_queries) Cloud default value: `1000`. )", 0) \ DECLARE(UInt64, max_concurrent_queries_for_user, 0, R"( The maximum number of simultaneously processed queries per user. Possible values: - Positive integer. - 0 — No limit. **Example** ```xml 5 ``` )", 0) \ \ DECLARE(DeduplicateInsertMode, deduplicate_insert, DeduplicateInsertMode::ENABLE, R"( Enables or disables block deduplication of `INSERT INTO` (for Replicated\* tables). The setting applies to both synchronous and asynchronous inserts, and it supersedes the `insert_deduplicate` and `async_insert_deduplicate` settings. That setting has three possible values: - disable — Deduplication is disabled for `INSERT INTO` query. - enable — Deduplication is enabled for `INSERT INTO` query. - backward_compatible_choice — Deduplication is enabled if `insert_deduplicate` or `async_insert_deduplicate` are enabled for specific insert type. For `INSERT SELECT` queries, [`deduplicate_insert_select`](#deduplicate_insert_select) is consulted first. Deduplication also requires the destination table to keep a deduplication log, see [replicated_deduplication_window](/reference/settings/merge-tree-settings/replicated-deduplication-window#replicated_deduplication_window) and [non_replicated_deduplication_window](/reference/settings/merge-tree-settings/other#non_replicated_deduplication_window). )", 0, \ {"26.2", "backward_compatible_choice", "enable", "Enable deduplication for all sync and async inserts by default."}) \ \ DECLARE(DeduplicateInsertSelectMode, deduplicate_insert_select, DeduplicateInsertSelectMode::ENABLE_WHEN_POSSIBLE, R"( Enables or disables block deduplication of `INSERT SELECT` (for Replicated\* tables). For `INSERT SELECT` queries this setting is consulted before [`deduplicate_insert`](#deduplicate_insert). A `SELECT` is stable when it carries `ORDER BY ALL` and its pipeline ends in a single stream. A non-empty [`insert_deduplication_token`](#insert_deduplication_token) is an equivalent substitute for stability. That setting has four possible values: - disable — Deduplication is disabled for `INSERT SELECT` query. - force_enable — Deduplication is enabled for `INSERT SELECT` query, regardless of `deduplicate_insert`. If select result is not stable and no token is provided, exception is thrown. - enable_when_possible — Deduplication is enabled if it is enabled by `deduplicate_insert` and the select result is stable, otherwise disabled. - enable_even_for_bad_queries - Deduplication is enabled if it is enabled by `deduplicate_insert`, regardless of whether the select result is stable. If select result is not stable, a message is logged, but query is executed with deduplication. This option is for backward compatibility. Consider to use other options instead as it may lead to unexpected results. )", 0, \ {"26.1", "enable_even_for_bad_queries", "enable_when_possible", "change the default behavior of deduplicate_insert_select to ENABLE_WHEN_POSSIBLE"}, \ {"25.12", "enable_even_for_bad_queries", "enable_even_for_bad_queries", "New setting, replace insert_select_deduplicate"}) \ \ DECLARE(Bool, insert_deduplicate, true, R"( Enables or disables block deduplication of `INSERT` (for Replicated\* tables). This setting only takes effect when [`deduplicate_insert`](#deduplicate_insert) is set to `backward_compatible_choice`. Possible values: - 0 — Disabled. - 1 — Enabled. By default, blocks inserted into replicated tables by the `INSERT` statement are deduplicated (see [Data Replication](/reference/engines/table-engines/mergetree-family/replication)). For the replicated tables by default the only 100 of the most recent blocks for each partition are deduplicated (see [replicated_deduplication_window](/reference/settings/merge-tree-settings/replicated-deduplication-window#replicated_deduplication_window), [replicated_deduplication_window_seconds](/reference/settings/merge-tree-settings/replicated-deduplication-window#replicated_deduplication_window_seconds)). For not replicated tables see [non_replicated_deduplication_window](/reference/settings/merge-tree-settings/other#non_replicated_deduplication_window). )", 0) \ DECLARE(Bool, async_insert_deduplicate, false, R"( For async INSERT queries in the replicated table, specifies that deduplication of inserting blocks should be performed. This setting only takes effect when [`deduplicate_insert`](#deduplicate_insert) is set to `backward_compatible_choice`. )", 0) \ \ DECLARE(UInt64Auto, insert_quorum, 0, R"( This setting is not applicable to SharedMergeTree, see [SharedMergeTree consistency](/products/cloud/features/infrastructure/shared-merge-tree#consistency) for more information. Enables the quorum writes. - If `insert_quorum < 2`, the quorum writes are disabled. - If `insert_quorum >= 2`, the quorum writes are enabled. - If `insert_quorum = 'auto'`, use majority number (`number_of_replicas / 2 + 1`) as quorum number. Quorum writes `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. When `insert_quorum_parallel` is disabled, all replicas in the quorum are consistent, i.e. they contain data from all previous `INSERT` queries (the `INSERT` sequence is linearized). When reading data written using `insert_quorum` and `insert_quorum_parallel` is disabled, you can turn on sequential consistency for `SELECT` queries using [select_sequential_consistency](#select_sequential_consistency). ClickHouse generates an exception: - If the number of available replicas at the time of the query is less than the `insert_quorum`. - When `insert_quorum_parallel` is disabled and an attempt to write data is made when the previous block has not yet been inserted in `insert_quorum` of replicas. This situation may occur if the user tries to perform another `INSERT` query to the same table before the previous one with `insert_quorum` is completed. See also: - [insert_quorum_timeout](#insert_quorum_timeout) - [insert_quorum_parallel](#insert_quorum_parallel) - [select_sequential_consistency](#select_sequential_consistency) )", 0) \ DECLARE(Milliseconds, insert_quorum_timeout, 600000, R"( Write to a 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. See also: - [insert_quorum](#insert_quorum) - [insert_quorum_parallel](#insert_quorum_parallel) - [select_sequential_consistency](#select_sequential_consistency) )", 0) \ DECLARE(Bool, insert_quorum_parallel, true, R"( This setting is not applicable to SharedMergeTree, see [SharedMergeTree consistency](/products/cloud/features/infrastructure/shared-merge-tree#consistency) for more information. Enables or disables parallelism for quorum `INSERT` queries. If enabled, additional `INSERT` queries can be sent while previous queries have not yet finished. If disabled, additional writes to the same table will be rejected. Possible values: - 0 — Disabled. - 1 — Enabled. See also: - [insert_quorum](#insert_quorum) - [insert_quorum_timeout](#insert_quorum_timeout) - [select_sequential_consistency](#select_sequential_consistency) )", 0, \ {"21.1", false, true, "Use parallel quorum inserts by default. It is significantly more convenient to use than sequential quorum inserts"}) \ DECLARE(UInt64, select_sequential_consistency, 0, R"( This setting differ in behavior between SharedMergeTree and ReplicatedMergeTree, see [SharedMergeTree consistency](/products/cloud/features/infrastructure/shared-merge-tree#consistency) for more information about the behavior of `select_sequential_consistency` in SharedMergeTree. Enables or disables sequential consistency for `SELECT` queries. Requires `insert_quorum_parallel` to be disabled (enabled by default). Possible values: - 0 — Disabled. - 1 — Enabled. Usage 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. When `insert_quorum_parallel` is enabled (the default), then `select_sequential_consistency` does not work. This is because parallel `INSERT` queries can be written to different sets of quorum replicas so there is no guarantee a single replica will have received all writes. See also: - [insert_quorum](#insert_quorum) - [insert_quorum_timeout](#insert_quorum_timeout) - [insert_quorum_parallel](#insert_quorum_parallel) )", 0) \ DECLARE(Bool, update_sequential_consistency, true, R"( If true set of parts is updated to the latest version before execution of update. )", 0, \ {"25.5", true, true, "A new setting"}) \ DECLARE(UpdateParallelMode, update_parallel_mode, UpdateParallelMode::AUTO, R"( Determines the behavior of concurrent update queries. Possible values: - `sync` - run sequentially all `UPDATE` queries. - `auto` - run sequentially only `UPDATE` queries with dependencies between columns updated in one query and columns used in expressions of another query. - `async` - do not synchronize update queries. )", 0, \ {"25.5", "auto", "auto", "A new setting"}) \ DECLARE(UInt64, table_function_remote_max_addresses, 1000, R"( Sets the maximum number of addresses generated from patterns for the [remote](/reference/functions/table-functions/remote) function. Possible values: - Positive integer. )", 0) \ DECLARE(Milliseconds, read_backoff_min_latency_ms, 1000, R"( Setting to reduce the number of threads in case of slow reads. Pay attention only to reads that took at least that much time. )", 0) \ DECLARE(UInt64, read_backoff_max_throughput, 1048576, R"( Settings to reduce the number of threads in case of slow reads. Count events when the read bandwidth is less than that many bytes per second. )", 0) \ DECLARE(Milliseconds, read_backoff_min_interval_between_events_ms, 1000, R"( Settings to reduce the number of threads in case of slow reads. Do not pay attention to the event, if the previous one has passed less than a certain amount of time. )", 0) \ DECLARE(UInt64, read_backoff_min_events, 2, R"( Settings to reduce the number of threads in case of slow reads. The number of events after which the number of threads will be reduced. )", 0) \ \ DECLARE(UInt64, read_backoff_min_concurrency, 1, R"( Settings to try keeping the minimal number of threads in case of slow reads. )", 0) \ \ DECLARE(Float, memory_tracker_fault_probability, 0., R"( For testing of `exception safety` - throw an exception every time you allocate memory with the specified probability. )", 0) \ DECLARE(Float, merge_tree_read_split_ranges_into_intersecting_and_non_intersecting_injection_probability, 0.0, R"( For testing of `PartsSplitter` - split read ranges into intersecting and non intersecting every time you read from MergeTree with the specified probability. )", 0, \ {"24.3", 0.0, 0.0, "For testing of `PartsSplitter` - split read ranges into intersecting and non intersecting every time you read from MergeTree with the specified probability."}) \ \ DECLARE(Bool, enable_http_compression, true, R"( Enables or disables data compression in the response to an HTTP request. For more information, read the [HTTP interface description](/concepts/features/interfaces/http). Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, \ {"25.10", false, true, "It should be beneficial in general"}) \ DECLARE(Int64, http_zlib_compression_level, 3, R"( Sets the level of data compression in the response to an HTTP request if [enable_http_compression = 1](#enable_http_compression). The setting applies only to the zlib-based methods: `gzip` and `deflate`. The level for other methods (such as `zstd`, `lz4`, `br`, `xz`) is set by [output_format_compression_level](/reference/settings/formats/output-format#output_format_compression_level). Possible values: Numbers from 1 to 12. Levels above `9` require the default build with `libdeflate`; a build without `libdeflate` supports levels 1 to 9. )", 0) \ DECLARE(SnappyMode, snappy_mode, SnappyMode::Basic, R"( Controls the wire format used for snappy compression for generic file I/O paths such as `file` and `url`. HTTP `Content-Encoding: snappy` always uses the framing format and ignores this setting. Note that the raw snappy block format produced by a single `snappy::Compress` call (for example, the Prometheus remote protocol payloads handled by `SnappyBasicReadBuffer`) is a separate, protocol-specific wire format and is not controlled by this setting. Possible values: - `basic` — Hadoop snappy block format. Compatible with files read and written by Hadoop. Supports both reading and writing. - `framed` — Snappy framing format, the standard streaming format defined by Google. Supports both reading and writing. )", 0, \ {"26.7", "basic", "basic", "New setting to control the wire format used for snappy compression in generic file/URL I/O. The default `basic` preserves backward-compatible Hadoop snappy block format reads; HTTP `Content-Encoding: snappy` always uses the framing format independently of this setting."}) \ \ DECLARE(Bool, http_native_compression_disable_checksumming_on_decompress, false, R"( 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`). For more information, read the [HTTP interface description](/concepts/features/interfaces/http). Possible values: - 0 — Disabled. - 1 — Enabled. )", 0) \ DECLARE(Map, http_response_headers, "", R"( Allows to add or override HTTP headers which the server will return in the response with a successful query result. This only affects the HTTP interface. If the header is already set by default, the provided value will override it. If the header was not set by default, it will be added to the list of headers. Headers that are set by the server by default and not overridden by this setting, will remain. The setting allows you to set a header to a constant value. Currently there is no way to set a header to a dynamically calculated value. Neither names nor values can contain ASCII control characters. If you implement a UI application which allows users to modify settings but at the same time makes decisions based on the returned headers, it is recommended to restrict this setting to readonly. Example: `SET http_response_headers = $${'Content-Type': 'image/png'}$$` )", 0, \ {"24.12", "", "", "New setting."}) \ \ DECLARE(String, count_distinct_implementation, "uniqExact", R"( Specifies which of the `uniq*` functions should be used to perform the [COUNT(DISTINCT ...)](/reference/functions/aggregate-functions/count) construction. Possible values: - [uniq](/reference/functions/aggregate-functions/uniq) - [uniqCombined](/reference/functions/aggregate-functions/uniqCombined) - [uniqCombined64](/reference/functions/aggregate-functions/uniqCombined64) - [uniqHLL12](/reference/functions/aggregate-functions/uniqHLL12) - [uniqExact](/reference/functions/aggregate-functions/uniqExact) )", 0) \ \ DECLARE(Bool, add_http_cors_header, false, R"( Write add http CORS header. )", 0) \ \ DECLARE(UInt64, max_http_get_redirects, 0, R"( Max number of HTTP GET redirects hops allowed. Ensures additional security measures are in place to prevent a malicious server from redirecting your requests to unexpected services.\n\nIt is the case when an external server redirects to another address, but that address appears to be internal to the company's infrastructure, and by sending an HTTP request to an internal server, you could request an internal API from the internal network, bypassing the auth, or even query other services, such as Redis or Memcached. When you don't have an internal infrastructure (including something running on your localhost), or you trust the server, it is safe to allow redirects. Although keep in mind, that if the URL uses HTTP instead of HTTPS, and you will have to trust not only the remote server but also your ISP and every network in the middle. Cloud default value: `10`. )", 0) \ \ DECLARE(Bool, use_client_time_zone, false, R"( Use client timezone for interpreting DateTime string values, instead of adopting server timezone. )", 0) \ \ DECLARE(Bool, send_profile_events, true, R"( Enables or disables sending of [ProfileEvents](/resources/develop-contribute/native-protocol/protocol#profileevents) packets to the client. This can be disabled to reduce network traffic for clients that do not require profile events. Possible values: - 0 — Disabled. - 1 — Enabled. )", 0, \ {"25.11", true, true, "New setting. Whether to send profile events to the clients."}) \ \ DECLARE(Bool, send_progress_in_http_headers, false, R"( Enables or disables `X-ClickHouse-Progress` HTTP response headers in `clickhouse-server` responses. For more information, read the [HTTP interface description](/concepts/features/interfaces/http). Possible values: - 0 — Disabled. - 1 — Enabled. )", 0) \ \ DECLARE(UInt64, http_headers_progress_interval_ms, 100, R"( Do not send HTTP headers X-ClickHouse-Progress more frequently than at each specified interval. )", 0) \ DECLARE(Bool, http_wait_end_of_query, false, R"( Enable HTTP response buffering on the server-side. )", 0) \ DECLARE(Bool, http_write_exception_in_output_format, false, R"( Write exception in output format to produce valid output. Works with JSON and XML formats. )", 0, \ {"25.11", true, false, "Changed for consistency across formats"}, \ {"23.9", false, true, "Output valid JSON/XML on exception in HTTP streaming."}) \ DECLARE(UInt64, http_response_buffer_size, 0, R"( The number of bytes to buffer in the server memory before sending a HTTP response to the client or flushing to disk (when http_wait_end_of_query is enabled). )", 0) \ DECLARE(String, framing_output_format, "None", R"( Allows to multiplex different parts of the query response in a single stream: chunks of data, totals and extremes, progress packets, profile events (metrics), and server logs - everything that the native protocol supports. Framing formats are independent of output formats: they encapsulate bytes produced by any output format, by separating and potentially encoding these chunks of bytes. The concatenation of the payloads of all `data`, `totals` and `extremes` packets is exactly what the output format would have produced without framing. Auxiliary packets (progress, logs, profile events, exceptions) are represented as JSON. One deliberate exception: an output format that drops totals and extremes in its plain output because it cannot represent them (the `JSONCompactEachRow` family) does emit them under framing, into the `totals` and `extremes` packets. For such formats the concatenation of the `data` packets alone is exactly the unframed output, and the `totals` and `extremes` packets carry additional rows that the unframed output does not contain. Server logs are included if the `send_logs_level` setting is set, and profile events are included if the `send_profile_events` setting is enabled (they are sent at most once in `interactive_delay` microseconds, and progress packets are also throttled by `interactive_delay`). A successful stream ends with a final `progress` packet carrying the final counters (`result_rows`, `result_bytes`, `memory_usage`), written after the trailing `log` and `profile_events` packets emitted by the query-finish logging, like the final progress packet of the native protocol. On failure, the `exception` packet is the last packet instead - with one exception: when the failure happens after part of the packet stream has already been produced into the response and can no longer be discarded (a packet write fails partway through, the delivery of the `exception` packet itself fails, or the response stream fails while being flushed or closed), the framing fails closed - the stream is terminated without a terminal `exception` packet, and the client observes a truncated response and an aborted HTTP connection instead of a parseable terminal packet. Nothing is ever appended after a partial packet stream, so a plain HTTP error body is never mixed into it. Anything a query enables only through its own `SETTINGS` clause - a framing format, `send_logs_level`, or `send_profile_events` - is not known until the query has been parsed, so the corresponding logs and profile events are captured only from query execution onwards. The logs and profile events of the parse, plan, and analysis phase are captured only when the setting comes from the session or the URL. For example, a query that fails during analysis (such as a reference to an unknown table) and enables `send_logs_level` only in its `SETTINGS` clause delivers just the `exception` packet, not the analysis-phase logs; set `send_logs_level` on the session or the URL to capture those. The same late-discovery caveat applies to `send_logs_source_regexp`: the log queue filters entries by source at the moment each entry is captured, so a regexp set only in the query's own `SETTINGS` clause takes effect from query execution onwards. The `log` packets of the parse, plan, and analysis phase are filtered by the session or URL value of the setting (they are unfiltered when it is not set there), so they may include sources that do not match the query-level regexp; conversely, entries dropped by a narrower session or URL regexp are not recovered by a broader query-level one. Set `send_logs_source_regexp` on the session or the URL to filter the whole query lifecycle. The setting currently applies to the HTTP protocol and is ignored for other interfaces. Possible values: - `None` - transparently routes everything applicable (data, totals, extremes, progress) to the output format, and ignores everything that is not applicable (metrics, logs), so everything works as it is by default. - `EventStream` - frames packets as HTTP server-sent events (`text/event-stream`). Every packet is sent as an event with the corresponding name: `data`, `totals`, `extremes`, `progress`, `log`, `profile_events`, `exception`. Progress and other auxiliary packets are sent as JSON. Because server-sent events are a text protocol that treats line breaks (including carriage returns, `\r`) as delimiters, a block of formatted data is base64-encoded into a single `data` field of the event, which decodes to the fully formatted payload with all of its newlines; the `Content-Type` carries a `payload=base64` parameter to say so. Any output format can be carried this way byte-exactly, text and binary alike. - `JSONEachPacketBase64` - every packet is a JSON object on a separate line, and the formatted data is base64-encoded, e.g. `{"packet":"data","data":"eyJ4IjoxfQo="}`. Suitable for binary output formats. - `JSONEachPacketString` - every packet is a JSON object on a separate line, and the formatted data is put into a string, e.g. `{"packet":"data","data":"{\"x\":1}\n"}`. `JSONEachPacketString` puts the payload bytes into a JSON string without validating or re-encoding them. `String` and `FixedString` columns can hold arbitrary bytes, so text output formats (such as `JSONEachRow`, `TSV`, or `CSV`) may emit invalid UTF-8 for such values - just as ClickHouse's own `JSONEachRow` does with the default `output_format_json_validate_utf8 = 0` - and then the resulting NDJSON stream is not guaranteed to be valid UTF-8. Use `JSONEachPacketBase64` for byte-exact transport of arbitrary bytes. Example: ```bash curl "http://localhost:8123/?framing_output_format=JSONEachPacketString" -d "SELECT number FROM numbers(3) FORMAT JSONEachRow" ``` Result: ```text {"packet":"data","data":"{\"number\":\"0\"}\n{\"number\":\"1\"}\n{\"number\":\"2\"}\n"} {"packet":"profile_events","profile_events":[{"host_name":"localhost","current_time":"2026-07-11 00:00:00","thread_id":"0","type":"increment","name":"SelectedRows","value":"3"}]} {"packet":"progress","progress":{"read_rows":"3","read_bytes":"24","total_rows_to_read":"3","result_rows":"3","result_bytes":"24","elapsed_ns":"1265958"}} ``` )", BETA, \ {"26.8", "None", "None", "New setting to select a framing format that multiplexes data, totals, extremes, progress, logs, and profile events packets in a single output stream over HTTP."}) \ \ DECLARE(Bool, fsync_metadata, true, R"( Enables or disables [fsync](http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html) when writing `.sql` files. Enabled by default. It makes sense to disable it if the server has millions of tiny tables that are constantly being created and destroyed. )", 0) \ \ DECLARE(Bool, join_use_nulls, false, R"( Sets the type of [JOIN](/reference/statements/select/join) behaviour. When merging tables, empty cells may appear. ClickHouse fills them differently based on this setting. Possible values: - 0 — The empty cells are filled with the default value of the corresponding field type. - 1 — `JOIN` behaves the same way as in standard SQL. The type of the corresponding field is converted to [Nullable](/reference/data-types/nullable), and empty cells are filled with [NULL](/reference/syntax). )", IMPORTANT) \ \ DECLARE(UInt64, join_output_by_rowlist_perkey_rows_threshold, 5, R"( The lower limit of per-key average rows in the right table to determine whether to output by row list in hash join. )", 0, \ {"24.9", 0, 5, "The lower limit of per-key average rows in the right table to determine whether to output by row list in hash join."}) \ DECLARE(JoinStrictness, join_default_strictness, JoinStrictness::All, R"( Sets default strictness for [JOIN clauses](/reference/statements/select/join). Possible values: - `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. )", 0) \ DECLARE(Bool, any_join_distinct_right_table_keys, false, R"( Enables legacy ClickHouse server behaviour in `ANY INNER|LEFT JOIN` operations. Use this setting only for backward compatibility if your use cases depend on legacy `JOIN` behaviour. When the legacy behaviour is enabled: - 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. When the legacy behaviour is disabled: - 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 the left and right tables. Possible values: - 0 — Legacy behaviour is disabled. - 1 — Legacy behaviour is enabled. See also: - [JOIN strictness](/reference/statements/select/join#settings) )", IMPORTANT, \ {"19.14", true, false, "Disable ANY RIGHT and ANY FULL JOINs by default to avoid inconsistency"}) \ DECLARE(Bool, single_join_prefer_left_table, true, R"( For single JOIN in case of identifier ambiguity prefer left table )", IMPORTANT) \ \ DECLARE(BoolAuto, query_plan_join_swap_table, Field("auto"), R"( Determine which side of the join should be the build table (also called inner, the one inserted into the hash table for a hash join) in the query plan. This setting is supported only for `ALL` join strictness with the `JOIN ON` clause. Possible values are: - 'auto': Let the planner decide which table to use as the build table. - 'false': Never swap tables (the right table is the build table). - 'true': Always swap tables (the left table is the build table). )", 0, \ {"24.12", "false", "auto", "New setting. Right table was always chosen before."}) \ DECLARE(UInt64, query_plan_optimize_join_order_limit, 10, R"( Optimize the order of joins within the same subquery. Currently only supported for very limited cases. Value is the maximum number of tables to optimize. )", 0, \ {"25.12", 1, 10, "Allow JOIN reordering with more tables by default"}, \ {"25.9", 1, 1, "New setting"}) \ DECLARE(UInt64, query_plan_optimize_join_order_max_searched_plans, 100000, R"( Maximum number of partial plans the join order optimizer may enumerate before giving up and falling back to the next algorithm in `query_plan_optimize_join_order_algorithm`. This bounds optimization time deterministically (independent of wall-clock) on dense join graphs such as cliques or stars, where the search space grows exponentially. Set to 0 to disable the limit. Has no effect on the default `query_plan_optimize_join_order_limit`, where the search always stays well below this bound. )", EXPERIMENTAL, \ {"26.6", 0, 100000, "New setting to bound the number of partial plans the join order optimizer enumerates before falling back to the next algorithm."}) \ DECLARE(UInt64, query_plan_optimize_join_order_randomize, 0, R"( When non-zero, the join order optimizer uses randomly generated cardinalities and NDVs instead of real statistics. When set to 1, a random seed is generated, when set to a value > 1, that value is used as the seed directly. This is intended for testing to find errors caused by different join orderings. )", EXPERIMENTAL, \ {"26.4", 0, 0, "New setting to randomize join order statistics for testing."}) \ \ DECLARE(Bool, enable_join_transitive_predicates, true, R"( Infer transitive equi-join predicates from existing join conditions. For example, given `A.x = B.x` and `B.x = C.x`, a synthetic `A.x = C.x` predicate is added so the join order optimizer can consider direct (A JOIN C) plans. )", BETA, \ {"26.6", false, true, "Turn on enable_join_transitive_predicates by default"}, \ {"26.4", false, false, "New setting to infer transitive equi-join predicates for join order optimization."}) \ \ DECLARE(Bool, query_plan_join_shard_by_pk_ranges, true, R"( Execute a JOIN of two MergeTree tables as independent joins over primary-key ranges when the join keys contain a prefix of the primary key of both tables. Both tables are split into the same ranges by the values of that prefix (the same way `FINAL` splits parts into non-intersecting layers), so equal keys land in the same range, and each range is joined on its own thread. For `full_sorting_merge` and `parallel_full_sorting_merge`, this replaces a single-threaded merge join over both tables with one streaming merge join per range, running in parallel, which is typically several times faster and uses several times less memory. For `hash` and `parallel_hash`, each range gets its own hash table. It applies only when neither join runtime filters (`enable_join_runtime_filters`) nor spilling to disk (`max_bytes_ratio_before_external_join`, `max_bytes_before_external_join`) are in effect, since both make the join opaque to this optimization; then it usually does not speed up queries but may lower memory consumption. Ranges are assigned to threads statically, so a filter that is selective only in some part of the primary key range leaves some threads idle. Not applied to `FINAL`, `ASOF`, joins with several disjuncts in `ON`, or when reading with parallel replicas. )", 0, \ {"26.10", false, true, "Enabled by default. A `full_sorting_merge` or `parallel_full_sorting_merge` JOIN of two MergeTree tables whose keys contain a prefix of both primary keys now runs as independent merge joins over primary-key ranges in parallel, instead of a single-threaded merge join. Hash joins are affected only when neither join runtime filters nor spilling to disk are in effect."}, \ {"25.4", false, false, "New setting"}) \ \ DECLARE(Bool, query_plan_display_internal_aliases, false, R"( Show internal aliases (such as __table1) in EXPLAIN PLAN instead of those specified in the original query. )", 0, \ {"25.9", false, false, "New setting"}) \ \ DECLARE(ExplainQueryPlanDefault, explain_query_plan_default, ExplainQueryPlanDefault::PRETTY, R"( Default format used by `EXPLAIN PLAN`. Possible values: - `pretty` (default since 26.7) — `actions`, `compact`, and `pretty` default to `true`, producing a compact, pretty, action-annotated plan. - `legacy` — pre-26.7 output. Specifying the `actions`, `compact`, or `pretty` options explicitly in the `EXPLAIN` statement (for example, `EXPLAIN actions = 0, compact = 0, pretty = 0 SELECT ...`) always overrides this setting. `EXPLAIN PLAN` with `json = 1` or `distributed = 1` keeps the legacy (pre-26.7) defaults regardless of this setting, unless `actions`, `compact`, or `pretty` are set explicitly. The pretty output cannot represent JSON results or per-shard distributed plans, so those modes are only rendered correctly in legacy form. )", 0, \ {"26.7", "legacy", "pretty", "From 26.7, `EXPLAIN PLAN` defaults to `actions=1, compact=1, pretty=1`. Set this to `legacy` to restore the pre-26.7 output."}) \ \ DECLARE(Bool, explain_syntax_single_record, true, R"( Return `EXPLAIN SYNTAX` output as a single record (with embedded newlines) instead of one record per line, so the result is a single, recoverable row (for example, `SELECT count() FROM (EXPLAIN SYNTAX ...)` returns `1`). Specifying the `single_record` option explicitly in the `EXPLAIN SYNTAX` statement (for example, `EXPLAIN SYNTAX single_record = 0 SELECT ...`) always overrides this setting. Set to `false` to restore the pre-26.8 one-record-per-line output, or set `compatibility` to any version older than `26.8`. )", 0, \ {"26.8", false, true, "From 26.8, `EXPLAIN SYNTAX` returns the reformatted query as a single record (with embedded newlines) instead of one record per line. Set this to `false` to restore the pre-26.8 one-record-per-line output."}) \ \ DECLARE(UInt64, query_plan_max_step_description_length, 500, R"( Maximum length, in bytes, of a query plan step description. Longer descriptions are truncated to this length wherever they are exposed. )", 0, \ {"25.9", 1000000000, 500, "New setting"}) \ \ DECLARE(UInt64, log_query_plans_max_size, 1048576, R"( Maximum size, in bytes, of the document written to the `query_plan` column of [`system.query_log`](/reference/system-tables/query_log) by [`log_query_plans`](/reference/settings/session-settings/log#log_query_plans). A query decides how much text its own plan contains: a large `IN` list, a long alias or a folded constant are all rendered into it. This bounds what one query can store on its row, and the document is written into a buffer of this size, so it also bounds what rendering one plan can allocate. A plan that does not fit is not stored truncated, because half a document is not a plan. The column holds the reason instead, as `{"Error": ...}`. `0` means no limit. )", EXPERIMENTAL, \ {"26.11", 1048576, 1048576, "New setting to bound the size of the query plan stored in `system.query_log`. The limit is kept under `compatibility` with earlier versions: the column itself is new, so there is no earlier behaviour to restore, and it guards a server resource."}) \ \ DECLARE(UInt64, preferred_block_size_bytes, 1000000, R"( This setting adjusts the data block size for query processing and represents additional fine-tuning to the more rough 'max_block_size' setting. If the columns are large and with 'max_block_size' rows the block size is likely to be larger than the specified amount of bytes, its size will be lowered for better CPU cache locality. )", 0) \ \ DECLARE(UInt64, max_replica_delay_for_distributed_queries, 300, R"( Disables lagging replicas for distributed queries. See [Replication](/reference/engines/table-engines/mergetree-family/replication). Sets the time in seconds. If a replica's lag is greater than or equal to the set value, this replica is not used. Possible values: - Positive integer. - 0 — Replica lags are not checked. To prevent the use of any replica with a non-zero lag, set this parameter to 1. Used when performing `SELECT` from a distributed table that points to replicated tables. )", 0) \ DECLARE(Bool, fallback_to_stale_replicas_for_distributed_queries, true, R"( Forces a query to an out-of-date replica if updated data is not available. See [Replication](/reference/engines/table-engines/mergetree-family/replication). ClickHouse selects the most relevant from the outdated replicas of the table. Used when performing `SELECT` from a distributed table that points to replicated tables. By default, 1 (enabled). )", 0) \ DECLARE(UInt64, preferred_max_column_in_block_size_bytes, 0, R"( Limit on max column size in block while reading. Helps to decrease cache misses count. Should be close to L2 cache size. )", 0) \ \ DECLARE(UInt64, parts_to_delay_insert, 0, R"( If the destination table contains at least that many active parts in a single partition, artificially slow down insert into table. )", 0) \ DECLARE(UInt64, parts_to_throw_insert, 0, R"( If more than this number active parts in a single partition of the destination table, throw 'Too many parts ...' exception. )", 0) \ DECLARE(UInt64, dead_blobs_to_delay_insert, 0, R"( If the dead blobs queues of the destination table's disks contain at least that many blobs pending removal, artificially slow down insert into table. 0 - use the table setting. )", 0, \ {"26.7", 0, 0, "New setting to override the `MergeTree` setting with the same name per query."}) \ DECLARE(UInt64, dead_blobs_to_throw_insert, 0, R"( If the dead blobs queues of the destination table's disks contain more than this number of blobs pending removal, throw 'Too many dead blobs ...' exception. 0 - use the table setting. )", 0, \ {"26.7", 0, 0, "New setting to override the `MergeTree` setting with the same name per query."}) \ DECLARE(UInt64, number_of_mutations_to_delay, 0, R"( If the mutated table contains at least that many unfinished mutations, artificially slow down mutations of table. 0 - disabled )", 0) \ DECLARE(UInt64, number_of_mutations_to_throw, 0, R"( If the mutated table contains at least that many unfinished mutations, throw 'Too many mutations ...' exception. 0 - disabled )", 0) \ DECLARE(Int64, distributed_ddl_task_timeout, 180, R"( Sets timeout for DDL query responses from all hosts in cluster. If a DDL request has not been performed on all hosts, a response will contain a timeout error and a request will be executed in an async mode. Negative value means infinite. Possible values: - Positive integer. - 0 — Async mode. - Negative integer — infinite timeout. )", 0) \ DECLARE(Milliseconds, stream_flush_interval_ms, 7500, R"( Works for tables with streaming in the case of a timeout, or when a thread generates [max_insert_block_size](#max_insert_block_size) rows. 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. )", 0) \ DECLARE(Milliseconds, stream_poll_timeout_ms, 500, R"( Timeout for polling data from/to streaming storages. )", 0) \ DECLARE(UInt64, min_free_disk_bytes_to_perform_insert, 0, R"( Minimum free disk space bytes to perform an insert. )", 0, \ {"24.10", 0, 0, "New setting."}, \ {"24.9", 0, 0, "Maintain some free disk space bytes from inserts while still allowing for temporary writing."}) \ DECLARE(Float, min_free_disk_ratio_to_perform_insert, 0.0, R"( Minimum free disk space ratio to perform an insert. )", 0, \ {"24.10", 0.0, 0.0, "New setting."}, \ {"24.9", 0.0, 0.0, "Maintain some free disk space bytes expressed as ratio to total disk space from inserts while still allowing for temporary writing."}) \ \ DECLARE(Bool, final, false, R"( Automatically applies [FINAL](/reference/statements/select/from#final-modifier) modifier to all tables in a query, to tables where [FINAL](/reference/statements/select/from#final-modifier) is applicable, including joined tables and tables in sub-queries, and distributed tables. Possible values: - 0 - disabled - 1 - enabled Example: ```sql CREATE TABLE test ( key Int64, some String ) ENGINE = ReplacingMergeTree ORDER BY key; INSERT INTO test FORMAT Values (1, 'first'); INSERT INTO test FORMAT Values (1, 'second'); SELECT * FROM test; ┌─key─┬─some───┐ │ 1 │ second │ └─────┴────────┘ ┌─key─┬─some──┐ │ 1 │ first │ └─────┴───────┘ SELECT * FROM test SETTINGS final = 1; ┌─key─┬─some───┐ │ 1 │ second │ └─────┴────────┘ SET final = 1; SELECT * FROM test; ┌─key─┬─some───┐ │ 1 │ second │ └─────┴────────┘ ``` )", 0) \ \ DECLARE(Bool, partial_result_on_first_cancel, false, R"( Allows query to return a partial result after cancel. )", 0) \ \ DECLARE(Bool, discard_query_data, false, R"( If enabled, the server skips sending query result rows to the client. The query is still executed and logged fully on the server, and the client still receives the remaining packets. Used for shadow traffic, benchmarks, and fuzzing. Has no effect for secondary queries. Affects only the native TCP protocol. )", 0, \ {"26.7", false, false, "New setting to skip sending query result rows to the client over the native TCP protocol."}) \ DECLARE(Bool, run_query_in_background, false, R"( If enabled, the server schedules the query in the background, waits until the query has passed its checks (for example, that the tables exist and the user has the required grants) and is about to start its main work, returns an empty successful result, and runs the query to completion regardless of what happens to the connection. An error raised before that point is returned to the client; a later one is recorded only in `system.query_log`. A background query does not survive a server restart. On shutdown it obeys the same server settings as a foreground query: `shutdown_wait_unfinished_queries` chooses between cancelling it and waiting for it (queued entries are discarded either way, without a `system.query_log` entry), and `shutdown_wait_unfinished` limits how long the server waits. Track the query by its `query_id`: in `system.processes` while it is running and in `system.query_log` after it finishes and the query log entry is flushed. Applies to queries received over the native TCP and HTTP protocols. Over HTTP, pass the setting as a URL parameter. It cannot be changed with `SET`; enable it per query, or at the user or profile level. The main use case is a long `INSERT ... SELECT` that must not be lost when the client connection drops. )", 0, \ {"26.8", false, false, "New setting to run a query in the background, detached from the connection that submitted it, discarding the result."}) \ \ DECLARE(Bool, ignore_on_cluster_for_replicated_udf_queries, false, R"( Ignore ON CLUSTER clause for replicated UDF management queries. )", 0) \ DECLARE(Bool, ignore_on_cluster_for_replicated_access_entities_queries, false, R"( Ignore ON CLUSTER clause for replicated access entities management queries. )", 0) \ DECLARE(Bool, ignore_on_cluster_for_replicated_named_collections_queries, false, R"( Ignore ON CLUSTER clause for replicated named collections management queries. )", 0, \ {"24.7", false, false, "Ignore ON CLUSTER clause for replicated named collections management queries."}) \ DECLARE(Bool, ignore_on_cluster_for_replicated_handler_queries, false, R"( Ignore ON CLUSTER clause for replicated handler management queries. )", 0, \ {"26.8", false, false, "New setting to ignore the ON CLUSTER clause for handler management queries when handlers are backed by replicated (Keeper) storage."}) \ /** Settings for testing hedged requests */ \ DECLARE(Milliseconds, sleep_in_send_tables_status_ms, 0, R"( Time to sleep in sending tables status response in TCPHandler )", 0) \ DECLARE(Milliseconds, sleep_in_send_data_ms, 0, R"( Time to sleep in sending data in TCPHandler )", 0) \ DECLARE(Milliseconds, sleep_after_receiving_query_ms, 0, R"( Time to sleep after receiving query in TCPHandler )", 0) \ DECLARE(UInt64, unknown_packet_in_send_data, 0, R"( Send unknown packet instead of data Nth data packet )", 0) \ \ DECLARE(Bool, insert_allow_materialized_columns, false, R"( If setting is enabled, Allow materialized columns in INSERT. )", 0) \ DECLARE(Seconds, http_connection_timeout, DEFAULT_HTTP_READ_BUFFER_CONNECTION_TIMEOUT, R"( HTTP connection timeout (in seconds). Possible values: - Any positive integer. - 0 - Disabled (infinite timeout). )", 0) \ DECLARE(Seconds, http_send_timeout, DEFAULT_HTTP_READ_BUFFER_TIMEOUT, R"( HTTP send timeout (in seconds). Possible values: - Any positive integer (seconds). `0` is **not** an infinite timeout and can cause connection setup failures (POSIX socket timeouts require a positive interval). It's applicable only to the default profile. A server reboot is required for the changes to take effect. )", 0, \ {"23.6", 180, 30, "3 minutes seems crazy long. Note that this is timeout for a single network write call, not for the whole upload operation."}) \ DECLARE(Seconds, http_receive_timeout, DEFAULT_HTTP_READ_BUFFER_TIMEOUT, R"( HTTP receive timeout (in seconds). Possible values: - Any positive integer (seconds). `0` is **not** an infinite timeout and can cause connection setup failures (POSIX socket timeouts require a positive interval). )", 0, \ {"23.6", 180, 30, "See http_send_timeout."}) \ DECLARE(UInt64, http_max_uri_size, 1048576, R"( Sets the maximum URI length of an HTTP request. Possible values: - Positive integer. )", 0) \ DECLARE(UInt64, http_max_fields, 1000, R"( Maximum number of fields in HTTP request headers, query parameters, and form data. Also limits the number of fields in the headers of the HTTP responses that ClickHouse reads as a client, for example in the `url` table function. )", 0, \ {"26.4", 1000, 1000, "The change was backported to 26.1 and is recorded there."}, \ {"26.1", 1000000, 1000, "Reduce default to limit pre-authentication memory usage by HTTP connections."}) \ DECLARE(UInt64, http_max_field_name_size, 4 * 1024, R"( Maximum length of a field name in HTTP request headers, query parameters, and form data. Also limits the length of a field name in the headers of the HTTP responses that ClickHouse reads as a client, for example in the `url` table function. )", 0, \ {"26.4", 4096, 4096, "The change was backported to 26.1 and is recorded there."}, \ {"26.1", 131072, 4096, "Reduce default to limit pre-authentication memory usage by HTTP connections."}) \ DECLARE(UInt64, http_max_field_value_size, 128 * 1024, R"( Maximum length of a field value in HTTP request headers, query parameters, and form data. Also limits the length of a field value in the headers of the HTTP responses that ClickHouse reads as a client, for example in the `url` table function. )", 0) \ DECLARE(UInt64, http_max_request_header_size, 10 * 1024 * 1024, R"( Maximum total size of all HTTP request headers (names and values combined) in bytes. )", 0, \ {"26.4", 10485760, 10485760, "The change was backported to 26.1 and is recorded there."}, \ {"26.1", 0, 10485760, "New setting to limit total HTTP request header size before authentication."}) \ DECLARE(Seconds, http_headers_read_timeout, 30, R"( Maximum time in seconds to read all HTTP request headers. This is a total deadline for the entire header parsing phase, not a per-read timeout. Protects against slowloris-style attacks where a client trickles header data slowly to hold connections open. )", 0, \ {"26.4", 30, 30, "The change was backported to 26.1 and is recorded there."}, \ {"26.1", 0, 30, "New setting to limit total time for reading HTTP request headers, protecting against slowloris attacks."}) \ DECLARE(Bool, http_skip_not_found_url_for_globs, true, R"( Skip URLs for globs with HTTP_NOT_FOUND error )", 0) \ DECLARE(Bool, http_make_head_request, true, R"( The `http_make_head_request` setting allows the execution of a `HEAD` request while reading data from HTTP to retrieve information about the file to be read, such as its size. Since it's enabled by default, it may be desirable to disable this setting in cases where the server does not support `HEAD` requests. )", 0) \ DECLARE(Bool, optimize_throw_if_noop, false, R"( Enables or disables throwing an exception if an [OPTIMIZE](/reference/statements/optimize) query didn't perform a merge. 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. Possible values: - 1 — Throwing an exception is enabled. - 0 — Throwing an exception is disabled. )", 0) \ DECLARE(Bool, optimize_dry_run_check_part, true, R"( When enabled, `OPTIMIZE ... DRY RUN` validates the resulting merged part using `checkDataPart`. If the check fails, an exception is thrown. )", 0, \ {"26.2", true, true, "New setting"}) \ DECLARE(Bool, use_index_for_in_with_subqueries, true, R"( Try using an index if there is a subquery or a table expression on the right side of the IN operator. )", 0) \ DECLARE(UInt64, use_index_for_in_with_subqueries_max_values, 0, R"( The maximum size of the set in the right-hand side of the IN operator to use table index for filtering. It allows to avoid performance degradation and higher memory usage due to the preparation of additional data structures for large queries. Zero means no limit. )", 0) \ DECLARE(UInt64, statistics_max_set_size_for_exact_selectivity_estimation, 10000, R"( The maximum size of the set in the right-hand side of the `IN` operator for which the selectivity estimator derives the exact ranges covered by the set. Deriving them costs a `Field` per element, a sort, and one statistics probe per element, which for a large set dominates query planning. Above this limit the estimator instead derives the selectivity from the size of the set and its bounding range, which is a single linear pass over the set without the sort or the per-element statistics probes. Zero means no limit. )", 0, \ {"26.9", 10000, 10000, "The bound on the cost of estimating the selectivity of `IN` with a large set is kept under `compatibility` with an earlier version: the previous value is deliberately equal to the new one, so that the uncapped estimation, which could add hundreds of milliseconds to the planning of a single query, is not restored."}, \ {"26.8", 10000, 10000, "New setting to bound the cost of estimating the selectivity of `IN` with a large set: above the limit the estimator uses the size of the set and its bounding range instead of the exact ranges. The previous value is deliberately equal to the new one, so that `compatibility` with an earlier version keeps the bound instead of restoring the uncapped estimation, which could add hundreds of milliseconds to the planning of a single query."}, \ {"26.7", 10000, 10000, "The bound on the cost of estimating the selectivity of `IN` with a large set is kept under `compatibility` with an earlier version: the previous value is deliberately equal to the new one, so that the uncapped estimation, which could add hundreds of milliseconds to the planning of a single query, is not restored."}, \ {"26.6", 10000, 10000, "The bound on the cost of estimating the selectivity of `IN` with a large set is kept under `compatibility` with an earlier version: the previous value is deliberately equal to the new one, so that the uncapped estimation, which could add hundreds of milliseconds to the planning of a single query, is not restored."}) \ DECLARE(Bool, analyze_index_with_multiple_key_columns_per_condition, true, R"( Allow one atomic condition of the `WHERE`/`PREWHERE` expression (a single comparison, `IN`, `has`, etc.) to constrain multiple key columns during index analysis. For example, if a table has `ORDER BY (toDate(ts), ts)` and the query has `WHERE ts = '2026-01-10 00:00:00' AND user_id = 42`, the first of the two conditions constrains both key columns: it is analyzed as if `toDate(ts) = '2026-01-10' AND ts = '2026-01-10 00:00:00'` were written. When the setting is disabled, this predicate constrains only `ts`. Tuple membership predicates such as `(a, b) IN ((1, 2), (3, 4))` can still constrain multiple key columns. )", 0, \ {"26.10", false, true, "New setting to allow a single condition to constrain multiple key columns during index analysis."}) \ DECLARE(Bool, analyze_index_with_space_filling_curves, true, R"( If a table has a space-filling curve in its index, e.g. `ORDER BY mortonEncode(x, y)` or `ORDER BY hilbertEncode(x, y)`, and the query has conditions on its arguments, e.g. `x >= 10 AND x <= 20 AND y >= 20 AND y <= 30`, use the space-filling curve for index analysis. Currently, 2D analysis skips curves with `UInt64` arguments because the curve implementations use only 32 bits per argument. )", 0) \ DECLARE(Bool, allow_key_condition_coalesce_rewrite, true, R"( Rewrite predicates of the form `coalesce(a_1, ..., a_N) const` (and equivalently `ifNull`, or with the constant on the left) into the disjunction `(a_1 const) OR (a_1 IS NULL AND a_2 const) OR ... OR (a_1 IS NULL AND ... AND a_{N-1} IS NULL AND a_N const)` before index analysis, so per-column primary key and skip indexes on each `a_i` can be used. Partial-constant forms such as `coalesce(a, 42, b)` and `coalesce(a, b, 42)` are handled: the argument list is normalized like `coalesce` itself (`NULL` literals dropped, arguments after the first non-`Nullable` one dropped), and a trailing non-`NULL` constant, if any, is emitted as the final branch. The rewrite is strictly additive for index pruning; runtime filtering still uses the original predicate. Additionally, exact equality predicates of the form `nullIf(key, sentinel) = const` (where `sentinel != const` and types match exactly) are rewritten to `key = const` so primary key, partition, and skip indexes on `key` can prune granules directly. Range and disjunctive nullIf pruning is not supported. )", 0, \ {"26.5", false, true, "New setting to rewrite predicates of the form `coalesce(a_1, ..., a_N) const` (and equivalently `ifNull`, or with the constant on the left) into a disjunction before index analysis, so per-column primary key and skip indexes on each `a_i` can be used. Partial-constant forms such as `coalesce(a, 42, b)` and `coalesce(a, b, 42)` are also handled."}) \ DECLARE(Bool, joined_subquery_requires_alias, true, R"( Force joined subqueries and table functions to have aliases for correct name qualification. )", 0) \ DECLARE(Bool, empty_result_for_aggregation_by_empty_set, false, R"( Return empty result when aggregating without keys on empty set. )", 0) \ DECLARE(Bool, empty_result_for_aggregation_by_constant_keys_on_empty_set, true, R"( Return empty result when aggregating by constant keys on empty set. )", 0) \ DECLARE(Bool, allow_distributed_ddl, true, R"( If it is set to true, then a user is allowed to executed distributed DDL queries. )", 0) \ DECLARE(Bool, allow_suspicious_codecs, false, R"( If it is set to true, allow to specify meaningless compression codecs. )", 0, \ {"20.5", true, false, "Don't allow to specify meaningless compression codecs"}) \ DECLARE(UInt64, query_profiler_real_time_period_ns, default_query_profiler_period_ns, R"( Sets the period for a real clock timer of the [query profiler](/concepts/features/performance/troubleshoot/sampling-query-profiler). Real clock timer counts wall-clock time. Possible values: - Positive integer number, in nanoseconds. Recommended values: - 10000000 (100 times a second) nanoseconds and less for single queries. - 1000000000 (once a second) for cluster-wide profiling. - 0 for turning off the timer. Defaults to 0 in MemorySanitizer builds, where the sampling profiler is disabled. See also: - System table [trace_log](/reference/system-tables/trace_log) Cloud default value: `3000000000`. )", 0) \ DECLARE(UInt64, query_profiler_cpu_time_period_ns, default_query_profiler_period_ns, R"( Sets the period for a CPU clock timer of the [query profiler](/concepts/features/performance/troubleshoot/sampling-query-profiler). This timer counts only CPU time. Possible values: - A positive integer number of nanoseconds. Recommended values: - 10000000 (100 times a second) nanoseconds and more for single queries. - 1000000000 (once a second) for cluster-wide profiling. - 0 for turning off the timer. Defaults to 0 in MemorySanitizer builds, where the sampling profiler is disabled. See also: - System table [trace_log](/reference/system-tables/trace_log) )", 0) \ DECLARE(Bool, metrics_perf_events_enabled, false, R"( If enabled, some of the perf events will be measured throughout queries' execution. )", 0) \ DECLARE(String, metrics_perf_events_list, "", R"( Comma separated list of perf metrics that will be measured throughout queries' execution. Empty means all events. See PerfEventInfo in sources for the available events. )", 0) \ DECLARE(Float, opentelemetry_start_trace_probability, 0., R"( Sets the probability that the ClickHouse can start a trace for executed queries (if no parent [trace context](https://www.w3.org/TR/trace-context/) is supplied). Possible values: - 0 — The trace for all executed queries is disabled (if no parent trace context is supplied). - Positive floating-point number in the range [0..1]. For example, if the setting value is `0,5`, ClickHouse can start a trace on average for half of the queries. - 1 — The trace for all executed queries is enabled. )", 0) \ DECLARE(FloatAuto, opentelemetry_start_keeper_trace_probability, Field("auto"), R"( Probability to start a trace for ZooKeeper request - whether there is a parent trace or not. Possible values: - 'auto' - Equals the opentelemetry_start_trace_probability setting - 0 — Tracing is disabled - 0 to 1 — Probability (e.g., 1.0 = always enable) )", 0, \ {"26.2", "auto", "auto", "New setting"}) \ DECLARE(Bool, opentelemetry_trace_processors, false, R"( Collect OpenTelemetry spans for processors. )", 0) \ DECLARE(Bool, opentelemetry_trace_cpu_scheduling, false, R"( Collect OpenTelemetry spans for workload preemptive CPU scheduling. )", 0, \ {"25.8", false, false, "New setting to trace `cpu_slot_preemption` feature."}) \ DECLARE(Bool, opentelemetry_trace_stateless_worker_discovery, false, R"( Only has an effect in ClickHouse Cloud. For a query that is itself being traced, collect OpenTelemetry spans for the stateless-worker discovery-service requests it makes to provision (lease) workers. The spans are named `StatelessWorkerDiscovery.` and carry the attributes `clickhouse.discovery.action` and `clickhouse.discovery.status`. )", 0, \ {"26.10", false, false, "New setting to collect OpenTelemetry spans for the stateless-worker discovery-service requests a query makes to provision workers."}) \ DECLARE(Bool, prefer_column_name_to_alias, false, R"( Enables or disables using the original column names instead of aliases in query expressions and clauses. It especially matters when alias is the same as the column name, see [Expression Aliases](/reference/syntax#notes-on-usage). Enable this setting to make aliases syntax rules in ClickHouse more compatible with most other database engines. Possible values: - 0 — The column name is substituted with the alias. - 1 — The column name is not substituted with the alias. If the column name is ambiguous between joined tables and an alias with the same name exists, the alias is used: ```sql SET prefer_column_name_to_alias = 1; SELECT t1.id + 10 AS id, id AS x FROM (SELECT 1 AS id) AS t1, (SELECT 1 AS k) AS t2, (SELECT 2 AS id) AS t3; ``` ```text ┌─id─┬──x─┐ │ 11 │ 11 │ └────┴────┘ ``` Here `id` in `id AS x` is a column of both `t1` and `t3`, so it resolves to the alias `t1.id + 10`. **Example** The difference between enabled and disabled: Query: ```sql SET prefer_column_name_to_alias = 0; SELECT avg(number) AS number, max(number) FROM numbers(10); ``` Result: ```text Received exception from server (version 21.5.1): Code: 184. DB::Exception: Received from localhost:9000. DB::Exception: Aggregate function avg(number) is found inside another aggregate function in query: While processing avg(number) AS number. ``` Query: ```sql SET prefer_column_name_to_alias = 1; SELECT avg(number) AS number, max(number) FROM numbers(10); ``` Result: ```text ┌─number─┬─max(number)─┐ │ 4.5 │ 9 │ └────────┴─────────────┘ ``` )", 0) \ \ DECLARE(Bool, skip_redundant_aliases_in_udf, false, R"( Redundant aliases are not used (substituted) in user-defined functions in order to simplify it's usage. Possible values: - 1 — The aliases are skipped (substituted) in UDFs. - 0 — The aliases are not skipped (substituted) in UDFs. **Example** The difference between enabled and disabled: Query: ```sql SET skip_redundant_aliases_in_udf = 0; CREATE FUNCTION IF NOT EXISTS test_03274 AS ( x ) -> ((x + 1 as y, y + 2)); EXPLAIN SYNTAX SELECT test_03274(4 + 2); ``` Result: ```text SELECT ((4 + 2) + 1 AS y, y + 2) ``` Query: ```sql SET skip_redundant_aliases_in_udf = 1; CREATE FUNCTION IF NOT EXISTS test_03274 AS ( x ) -> ((x + 1 as y, y + 2)); EXPLAIN SYNTAX SELECT test_03274(4 + 2); ``` Result: ```text SELECT ((4 + 2) + 1, ((4 + 2) + 1) + 2) ``` )", 0, \ {"24.12", false, false, "When enabled, this allows you to use the same user defined function several times for several materialized columns in the same table."}) \ DECLARE(Bool, prefer_global_in_and_join, false, R"( Enables the replacement of `IN`/`JOIN` operators with `GLOBAL IN`/`GLOBAL JOIN`. Possible values: - 0 — Disabled. `IN`/`JOIN` operators are not replaced with `GLOBAL IN`/`GLOBAL JOIN`. - 1 — Enabled. `IN`/`JOIN` operators are replaced with `GLOBAL IN`/`GLOBAL JOIN`. **Usage** Although `SET distributed_product_mode=global` can change the queries behavior for the distributed tables, it's not suitable for local tables or tables from external resources. Here is when the `prefer_global_in_and_join` setting comes into play. For example, we have query serving nodes that contain local tables, which are not suitable for distribution. We need to scatter their data on the fly during distributed processing with the `GLOBAL` keyword — `GLOBAL IN`/`GLOBAL JOIN`. Another use case of `prefer_global_in_and_join` is accessing tables created by external engines. This setting helps to reduce the number of calls to external sources while joining such tables: only one call per query. **See also:** - [Distributed subqueries](/reference/statements/in#distributed-subqueries) for more information on how to use `GLOBAL IN`/`GLOBAL JOIN` )", 0) \ DECLARE(Bool, enable_vertical_final, true, R"( If enable, remove duplicated rows during FINAL by marking rows as deleted and filtering them later instead of merging rows )", 0, \ {"24.6", false, true, "Enable vertical final by default again after fixing bug"}, \ {"24.1", false, true, "Use vertical final by default"}) \ \ \ /** Limits during query execution are part of the settings. \ * Used to provide a more safe execution of queries from the user interface. \ * Basically, limits are checked for each block (not every row). That is, the limits can be slightly violated. \ * Almost all limits apply only to SELECTs. \ * Almost all limits apply to each stream individually. \ */ \ \ DECLARE(UInt64, max_rows_to_read, 0, R"( The maximum number of rows that can be read from a table when running a query. The restriction is checked for each processed chunk of data, applied only to the deepest table expression and when reading from a remote server, checked only on the remote server. )", 0) \ DECLARE(UInt64, max_bytes_to_read, 0, R"( The maximum number of bytes (of uncompressed data) that can be read from a table when running a query. The restriction is checked for each processed chunk of data, applied only to the deepest table expression and when reading from a remote server, checked only on the remote server. )", 0) \ DECLARE(OverflowMode, read_overflow_mode, OverflowMode::THROW, R"( What to do when the limit is exceeded. )", 0) \ \ DECLARE(UInt64, max_rows_to_read_leaf, 0, R"( The maximum number of rows that can be read from a local table on a leaf node when running a distributed query. While distributed queries can issue multiple sub-queries to each shard (leaf) - this limit will be checked only on the read stage on the leaf nodes and ignored on the merging of results stage on the root node. For example, a cluster consists of 2 shards and each shard contains a table with 100 rows. The distributed query which is supposed to read all the data from both tables with setting `max_rows_to_read=150` will fail, as in total there will be 200 rows. A query with `max_rows_to_read_leaf=150` will succeed, since leaf nodes will read at max 100 rows. The restriction is checked for each processed chunk of data. This setting is unstable with `prefer_localhost_replica=1`. )", 0) \ DECLARE(UInt64, max_bytes_to_read_leaf, 0, R"( The maximum number of bytes (of uncompressed data) that can be read from a local table on a leaf node when running a distributed query. While distributed queries can issue a multiple sub-queries to each shard (leaf) - this limit will be checked only on the read stage on the leaf nodes and will be ignored on the merging of results stage on the root node. For example, a cluster consists of 2 shards and each shard contains a table with 100 bytes of data. A distributed query which is supposed to read all the data from both tables with setting `max_bytes_to_read=150` will fail as in total it will be 200 bytes. A query with `max_bytes_to_read_leaf=150` will succeed since leaf nodes will read 100 bytes at max. The restriction is checked for each processed chunk of data. This setting is unstable with `prefer_localhost_replica=1`. )", 0) \ DECLARE(OverflowMode, read_overflow_mode_leaf, OverflowMode::THROW, R"( Sets what happens when the volume of data read exceeds one of the leaf limits. Possible options: - `throw`: throw an exception (default). - `break`: stop executing the query and return the partial result. )", 0) \ \ DECLARE(UInt64, max_rows_to_group_by, 0, R"( The maximum number of unique keys received from aggregation. This setting lets you limit memory consumption when aggregating. If aggregation during GROUP BY is generating more than the specified number of rows (unique GROUP BY keys), the behavior will be determined by the 'group_by_overflow_mode' which by default is `throw`, but can be also switched to an approximate GROUP BY mode. )", 0) \ DECLARE(OverflowModeGroupBy, group_by_overflow_mode, OverflowMode::THROW, R"( Sets what happens when the number of unique keys for aggregation exceeds the limit: - `throw`: throw an exception - `break`: stop executing the query and return the partial result - `any`: continue aggregation for the keys that got into the set, but do not add new keys to the set. Using the 'any' value lets you run an approximation of GROUP BY. The quality of this approximation depends on the statistical nature of the data. )", 0) \ DECLARE(UInt64, max_bytes_before_external_group_by, 0, R"( Cloud default value: half the memory amount per replica. Enables or disables execution of `GROUP BY` clauses in external memory. (See [GROUP BY in external memory](/reference/statements/select/group-by#group-by-in-external-memory)) Possible values: - Maximum volume of RAM (in bytes) that can be used by the single [GROUP BY](/reference/statements/select/group-by) operation. - `0` — `GROUP BY` in external memory disabled. If memory usage during GROUP BY operations is exceeding this threshold in bytes, activate the 'external aggregation' mode (spill data to disk). The recommended value is half of the available system memory. )", 0) \ DECLARE(Double, max_bytes_ratio_before_external_group_by, 0.5, R"( The ratio of available memory that is allowed for `GROUP BY`. Once reached, external memory is used for aggregation. For example, if set to `0.6`, `GROUP BY` will allow using 60% of the available memory (to server/user/merges) at the beginning of the execution, after that, it will start using external aggregation. )", 0, \ {"25.1", 0.0, 0.5, "Enable automatic spilling to disk by default."}, \ {"24.12", 0., 0., "New setting."}) \ DECLARE(UInt64, min_bytes_before_external_group_by, 0, R"( The minimum size in bytes of the aggregation state of one thread before external `GROUP BY` writes it to disk. When the memory of the query is over `max_bytes_before_external_group_by` or `max_bytes_ratio_before_external_group_by` because of other operators, for example a hash join that holds a large table, each thread would otherwise write every block it aggregates to disk as a separate small file. Reading many small files back costs more memory than the writes saved. With this setting a thread keeps aggregating until its own state reaches the given size, and only then writes it out as one file. The memory used above the threshold is bounded by this value multiplied by the number of threads. Possible values: - A positive integer, the size in bytes. - `0` — no minimum, the state is written as soon as the threshold is reached. )", 0, \ {"26.11", 0, 0, "New setting: the minimum size of the aggregation state of one thread before external `GROUP BY` writes it to disk, so that a query that is already over the threshold does not write every block as a separate file."}) \ \ DECLARE(UInt64, max_rows_to_sort, 0, R"( The maximum number of rows before sorting. This allows you to limit memory consumption when sorting. If more than the specified amount of records have to be processed for the ORDER BY operation, the behavior will be determined by the `sort_overflow_mode` which by default is set to `throw`. )", 0) \ DECLARE(UInt64, max_bytes_to_sort, 0, R"( The maximum number of bytes before sorting. If more than the specified amount of uncompressed bytes have to be processed for ORDER BY operation, the behavior will be determined by the `sort_overflow_mode` which by default is set to `throw`. )", 0) \ DECLARE(OverflowMode, sort_overflow_mode, OverflowMode::THROW, R"( Sets what happens if the number of rows received before sorting exceeds one of the limits. Possible values: - `throw`: throw an exception. - `break`: stop executing the query and return the partial result. )", 0) \ DECLARE(UInt64, prefer_external_sort_block_bytes, DEFAULT_BLOCK_SIZE * 256, R"( Preferred block size in bytes for spill files used by external `ORDER BY` and `DISTINCT`. Smaller blocks reduce memory usage when merging spill files. The block size is estimated from average row size, so blocks with unusually large rows can exceed this target. Set to `0` to size blocks by the row limit only. )", 0, \ {"24.5", 0, DEFAULT_BLOCK_SIZE * 256, "Prefer maximum block bytes for external sort, reduce the memory usage during merging."}) \ DECLARE(UInt64, max_bytes_before_external_sort, 0, R"( Cloud default value: half the memory amount per replica. Enables or disables execution of `ORDER BY` clauses in external memory. See [ORDER BY Implementation Details](/reference/statements/select/order-by#implementation-details) If memory usage during ORDER BY operation exceeds this threshold in bytes, the 'external sorting' mode (spill data to disk) is activated. Possible values: - Maximum volume of RAM (in bytes) that can be used by the single [ORDER BY](/reference/statements/select/order-by) operation. The recommended value is half of available system memory - `0` — `ORDER BY` in external memory disabled. )", 0) \ DECLARE(Double, max_bytes_ratio_before_external_sort, 0.5, R"( The ratio of available memory that is allowed for `ORDER BY`. Once reached, external sort is used. For example, if set to `0.6`, `ORDER BY` will allow using `60%` of available memory (to server/user/merges) at the beginning of the execution, after that, it will start using external sort. Note, that `max_bytes_before_external_sort` is still respected, spilling to disk will be done only if the sorting block is bigger then `max_bytes_before_external_sort`. )", 0, \ {"25.1", 0.0, 0.5, "Enable automatic spilling to disk by default."}, \ {"24.12", 0., 0., "New setting."}) \ DECLARE(UInt64, max_bytes_before_remerge_sort, 1000000000, R"( In case of `ORDER BY` with `LIMIT`, when the memory used by the blocks accumulated since the previous such step is higher than specified threshold, perform additional steps of merging blocks before final merge to keep just top `LIMIT` rows. Before spilling to disk because of `max_bytes_before_external_sort`, all accumulated blocks are counted. )", 0) \ DECLARE(Float, remerge_sort_lowered_memory_bytes_ratio, 2., R"( If memory usage after remerge does not reduced by this ratio, remerge will be disabled. )", 0) \ \ DECLARE(UInt64, max_bytes_before_external_distinct, 0, R"( Query memory threshold, in bytes, for spilling `DISTINCT` data to disk. Actual memory usage can exceed this threshold. `0` disables this threshold. If `max_bytes_ratio_before_external_distinct` also provides a threshold, the smaller is used. Set both settings to `0` to disable spilling. See [DISTINCT in external memory](/reference/statements/select/distinct#distinct-in-external-memory). )", 0, \ {"26.9", 0, 0, "New setting to enable spilling of `DISTINCT` to disk when memory usage exceeds the given threshold in bytes. If 0, only `max_bytes_ratio_before_external_distinct` applies."}) \ DECLARE(Double, max_bytes_ratio_before_external_distinct, 0.5, R"( Fraction of available server or user memory used to calculate the external `DISTINCT` threshold at the start of execution. For example, `0.5` uses half of the available memory. Values must be at least `0` and less than `1`. `0` disables this threshold. Without an applicable server or user memory limit, the ratio has no effect. `max_memory_usage` does not affect this calculation. To configure spilling relative to that limit, use `max_bytes_before_external_distinct`, leaving room for additional memory usage. )", 0, \ {"26.9", 0., 0.5, "New setting to enable spilling of `DISTINCT` to disk when memory usage exceeds the given ratio of available memory. If 0, only `max_bytes_before_external_distinct` applies."}) \ \ DECLARE(UInt64, max_bytes_before_external_set, 0, R"( Query memory threshold, in bytes, for spilling the set of `IN` with a subquery to disk, while the set is being built or while the query uses it. Actual memory usage can exceed this threshold. A set that takes less memory than this threshold or 16 MiB, whichever is smaller, stays in memory. `0` disables this threshold. If `max_bytes_ratio_before_external_set` also provides a threshold, the smaller is used. Set both settings to `0` to disable spilling. See [IN in external memory](/reference/statements/in#in-in-external-memory). )", 0, \ {"26.10", 0, 0, "New setting to enable spilling of the set of `IN` with a subquery to disk when memory usage exceeds the given threshold in bytes. If 0, only `max_bytes_ratio_before_external_set` applies."}) \ DECLARE(Double, max_bytes_ratio_before_external_set, 0.5, R"( Fraction of available server or user memory used to calculate the threshold for spilling the set of `IN` with a subquery to disk, at the start of execution. For example, `0.5` uses half of the available memory. Values must be at least `0` and less than `1`. `0` disables this threshold. Without an applicable server or user memory limit, the ratio has no effect. `max_memory_usage` does not affect this calculation. To configure spilling relative to that limit, use `max_bytes_before_external_set`, leaving room for additional memory usage. )", 0, \ {"26.11", 0.5, 0.5, "The default change to 0.5 was backported to 26.10."}, \ {"26.10", 0., 0.5, "New setting to enable spilling of the set of `IN` with a subquery to disk when memory usage exceeds the given ratio of available memory. If 0, only `max_bytes_before_external_set` applies."}) \ DECLARE(UInt64, max_bytes_for_external_set_bloom_filter, 128_MiB, R"( Memory budget, in bytes, for the Bloom filter that each set of `IN` written to disk keeps in memory. The filter lets lookups of values that are not in the set skip reading the disk. It does not speed up lookups of values that are in the set. A set takes about 1 byte per key for its filter, or the budget, whichever is smaller, where the keys of a set are its distinct values, or its distinct tuples for `IN` with several columns: - If the budget is at least 1 byte per key, the set gets the full filter, and about 97% of the lookups of values that are not in the set skip the disk. For example, a set of 1 million keys takes about 1 MiB. - If the budget is smaller, the set gets a weaker filter that fits in the budget, and fewer lookups of values that are not in the set skip the disk. For example, with a quarter of a byte per key, about 60% of such lookups skip the disk instead of 97%. - If the budget is less than about 1/7 of a byte per key, the set gets no filter, because such a filter would let too few lookups skip the disk to pay for building it. With the default budget of 128 MiB, sets of up to about 130 million keys get the full filter, and sets of more than about 950 million keys get none. Raise the budget for larger sets when most of the looked-up values are not in the set. Lower it when memory is short, or when most of the looked-up values are in the set, where the filter does not help. `0` disables the filter. The filter counts towards the memory usage of the query, such as `max_memory_usage`, but not towards `max_bytes_in_set`. The budget applies to each set, not to the query. See [IN in external memory](/reference/statements/in#in-in-external-memory). )", 0, \ {"26.11", 128_MiB, 128_MiB, "The setting was backported to 26.10."}, \ {"26.10", 0, 128 * 1024 * 1024, "New setting to limit the memory of the Bloom filter that a set of `IN` on disk keeps to skip reading the disk for values that are not in the set."}) \ DECLARE(UInt64, max_bytes_for_external_set_cache, 128_MiB, R"( Memory budget, in bytes, for the cache of blocks that each set of `IN` written to disk keeps in memory. A lookup that needs a block already read by an earlier lookup gets it from the cache instead of reading it from disk again. The cache helps when lookups repeatedly need the same blocks, such as lookups of a few frequent values or many lookups into a set that fits in the cache. It helps little when lookups spread evenly over a set much larger than the cache. `0` disables the cache. The budget applies per set. The cache counts towards the memory usage of the query, such as `max_memory_usage`, but not towards `max_bytes_in_set`. See [IN in external memory](/reference/statements/in#in-in-external-memory). )", 0, \ {"26.11", 128_MiB, 128_MiB, "The setting was backported to 26.10."}, \ {"26.10", 0, 128 * 1024 * 1024, "New setting to limit the memory of the cache of blocks that a set of `IN` on disk keeps, so that its lookups do not read the same blocks from the disk again."}) \ \ DECLARE(UInt64, max_result_rows, 0, R"( Limits the number of rows in the result. Also checked for subqueries, and on remote servers when running parts of a distributed query. No limit is applied when the value is `0`. The query will stop after processing a block of data if the threshold is met, but it will not cut the last block of the result, therefore the result size can be larger than the threshold. )", 0) \ DECLARE(UInt64, max_result_bytes, 0, R"( Limits the result size in bytes (uncompressed). The query will stop after processing a block of data if the threshold is met, but it will not cut the last block of the result, therefore the result size can be larger than the threshold. **Caveats** The result size in memory is taken into account for this threshold. Even if the result size is small, it can reference larger data structures in memory, representing dictionaries of LowCardinality columns, and Arenas of AggregateFunction columns, so the threshold can be exceeded despite the small result size. The setting is fairly low level and should be used with caution )", 0) \ DECLARE(OverflowMode, result_overflow_mode, OverflowMode::THROW, R"( Sets what to do if the volume of the result exceeds one of the limits. Possible values: - `throw`: throw an exception (default). - `break`: stop executing the query and return the partial result, as if the source data ran out. Using 'break' is similar to using LIMIT. `Break` interrupts execution only at the block level. This means that amount of returned rows is greater than [`max_result_rows`](/reference/settings/session-settings/max-result#max_result_rows), multiple of [`max_block_size`](/reference/settings/session-settings/max#max_block_size) and depends on [`max_threads`](/reference/settings/session-settings/max-threads#max_threads). **Example** ```sql title="Query" SET max_threads = 3, max_block_size = 3333; SET max_result_rows = 3334, result_overflow_mode = 'break'; SELECT * FROM numbers_mt(100000) FORMAT Null; ``` ```text title="Result" 6666 rows in set. ... ``` )", 0) \ \ /* TODO: Check also when merging and finalizing aggregate functions. */ \ DECLARE(Seconds, max_execution_time, 0, R"( The maximum query execution time in seconds. If query runtime exceeds the specified number of seconds, the behavior will be determined by the 'timeout_overflow_mode', which by default is set to `throw`. The timeout is checked and the query can stop only in designated places during data processing. It currently cannot stop during merging of aggregation states, nor during most of query analysis (establishing a connection to a remote replica is one place where it can), and the actual run time will be higher than the value of this setting. )", 0) \ DECLARE(OverflowMode, timeout_overflow_mode, OverflowMode::THROW, R"( Sets what to do if the query is run longer than the `max_execution_time` or the estimated running time is longer than `max_estimated_execution_time` (the estimate is only checked with `throw`). Possible values: - `throw`: throw an exception (default). - `break`: stop executing the query and return the partial result, as if the source data ran out. Some operations cannot return a partial result safely, so instead of a smaller result they stop without producing one. A function computing a single value stops without producing that value; whether the stop also reaches the client as a `TIMEOUT_EXCEEDED` error, or only as a missing result, depends on where the query was interrupted. A `Memory`-table mutation left incomplete by the timeout keeps the table unchanged and reports `TIMEOUT_EXCEEDED`. An `INSERT` may report `QUERY_WAS_CANCELLED`. Some operations that wait for other replicas or for background work do not stop at `max_execution_time` at all: a quorum write keeps waiting until its quorum is satisfied, or reports `UNKNOWN_STATUS_OF_INSERT` if `insert_quorum_timeout` elapses first. )", 0) \ DECLARE(Seconds, max_execution_time_leaf, 0, R"( Similar semantically to [`max_execution_time`](#max_execution_time) but only applied on leaf nodes for distributed or remote queries. For example, if we want to limit the execution time on a leaf node to `10s` but have no limit on the initial node, instead of having `max_execution_time` in the nested subquery settings: ```sql SELECT count() FROM cluster(cluster, view(SELECT * FROM t SETTINGS max_execution_time = 10)); ``` We can use `max_execution_time_leaf` as the query settings: ```sql SELECT count() FROM cluster(cluster, view(SELECT * FROM t)) SETTINGS max_execution_time_leaf = 10; ``` )", 0) \ DECLARE(OverflowMode, timeout_overflow_mode_leaf, OverflowMode::THROW, R"( Sets what happens when the query in leaf node run longer than `max_execution_time_leaf`. Possible values: - `throw`: throw an exception (default). - `break`: stop executing the query and return the partial result, as if the source data ran out. Some operations cannot return a partial result safely, so instead of a smaller result they stop without producing one: a function computing a single value stops without producing that value. Whether such a stop also reaches the client as a `TIMEOUT_EXCEEDED` error, or only as a missing result, depends on where the query was interrupted. )", 0) \ \ DECLARE(UInt64, min_execution_speed, 0, R"( Minimal execution speed in rows per second. Checked on every data block when [`timeout_before_checking_execution_speed`](/reference/settings/session-settings/other#timeout_before_checking_execution_speed) expires. If the execution speed is lower, an exception is thrown. )", 0) \ DECLARE(UInt64, max_execution_speed, 0, R"( The maximum number of execution rows per second. Checked on every data block when [`timeout_before_checking_execution_speed`](/reference/settings/session-settings/other#timeout_before_checking_execution_speed) expires. If the execution speed is high, the execution speed will be reduced. )", 0) \ DECLARE(UInt64, min_execution_speed_bytes, 0, R"( The minimum number of execution bytes per second. Checked on every data block when [`timeout_before_checking_execution_speed`](/reference/settings/session-settings/other#timeout_before_checking_execution_speed) expires. If the execution speed is lower, an exception is thrown. )", 0) \ DECLARE(UInt64, max_execution_speed_bytes, 0, R"( The maximum number of execution bytes per second. Checked on every data block when [`timeout_before_checking_execution_speed`](/reference/settings/session-settings/other#timeout_before_checking_execution_speed) expires. If the execution speed is high, the execution speed will be reduced. )", 0) \ DECLARE(Seconds, timeout_before_checking_execution_speed, 10, R"( Checks that execution speed is not too slow (no less than `min_execution_speed`), after the specified time in seconds has expired. If set to `0`, the execution speed limits are checked from the start of the query, but [`max_estimated_execution_time`](/reference/settings/session-settings/max#max_estimated_execution_time) is not checked at all. )", 0) \ DECLARE(Seconds, max_estimated_execution_time, 0, R"( Maximum query estimate execution time in seconds. Checked on every data block when [`timeout_before_checking_execution_speed`](/reference/settings/session-settings/other#timeout_before_checking_execution_speed) expires. It operates based on extrapolation relative to the current query execution speed. If you set `timeout_before_checking_execution_speed` to 0, then this setting will not be checked. )", 0, \ {"24.1", 0, 0, "Separate max_execution_time and max_estimated_execution_time"}) \ \ DECLARE(UInt64, max_columns_to_read, 0, R"( The maximum number of columns that can be read from a table in a single query. If a query requires reading more than the specified number of columns, an exception is thrown. This setting is useful for preventing overly complex queries. `0` value means unlimited. )", 0) \ DECLARE(UInt64, max_temporary_columns, 0, R"( The maximum number of temporary columns that must be kept in RAM simultaneously when running a query, including constant columns. If a query generates more than the specified number of temporary columns in memory as a result of intermediate calculation, then an exception is thrown. This setting is useful for preventing overly complex queries. `0` value means unlimited. )", 0) \ DECLARE(UInt64, max_temporary_non_const_columns, 0, R"( Like `max_temporary_columns`, the maximum number of temporary columns that must be kept in RAM simultaneously when running a query, but without counting constant columns. Constant columns are formed fairly often when running a query, but they require approximately zero computing resources. )", 0) \ \ DECLARE(UInt64, max_sessions_for_user, 0, R"( Maximum number of simultaneous sessions per authenticated user to the ClickHouse server. Example: ```xml 1 2 0 single_session_user two_sessions_profile unlimited_sessions_profile ``` Possible values: - Positive integer - `0` - infinite count of simultaneous sessions (default) )", 0) \ \ DECLARE(UInt64, max_subquery_depth, 100, R"( If a query has more than the specified number of nested subqueries, throws an exception. This allows you to have a sanity check to protect against the users of your cluster from writing overly complex queries. )", 0) \ DECLARE(UInt64, max_analyze_depth, 5000, R"( Maximum number of analyses performed by interpreter. )", 0) \ DECLARE(UInt64, max_ast_depth, 1000, R"( The maximum nesting depth of a query syntactic tree. If exceeded, an exception is thrown. At this time, it isn't checked during parsing, but only after parsing the query. This means that a syntactic tree that is too deep can be created during parsing, but the query will fail. )", 0) \ DECLARE(UInt64, max_ast_elements, 50000, R"( The maximum number of elements in a query syntactic tree. If exceeded, an exception is thrown. At this time, it isn't checked during parsing, but only after parsing the query. This means that a syntactic tree that is too deep can be created during parsing, but the query will fail. )", 0) \ DECLARE(UInt64, max_expanded_ast_elements, 500000, R"( Maximum size of query syntax tree in number of nodes after expansion of aliases and the asterisk. The same limit also bounds the number of nodes created by substituting `WITH` elements (common table expressions and aliased expressions) into the query. This applies wherever `WITH` elements are substituted, including `SELECT` queries, `CREATE VIEW` and `CREATE MATERIALIZED VIEW`, `ATTACH` with a full definition, `ALTER TABLE ... MODIFY QUERY`, mutation expressions in `ALTER TABLE ... UPDATE/DELETE` and lightweight `UPDATE`, distributed `INSERT ... SELECT`, and the propagation of `WITH` elements to all parts of a `UNION`. If the limit is exceeded, the query fails with the `TOO_BIG_AST` error. )", 0) \ \ DECLARE(Float, ast_fuzzer_runs, 0, R"( Enables the server-side AST fuzzer that runs randomized queries after each normal query, discarding their results. - 0: disabled (default). - A value between 0 and 1 (exclusive): probability of running a single fuzzed query. - A value >= 1: the number of fuzzed queries to run per normal query. The fuzzer accumulates AST fragments from all queries across all sessions, producing increasingly interesting mutations over time. Fuzzed queries that fail are silently discarded; results are never returned to the client. )", EXPERIMENTAL, \ {"26.2", 0, 0, "New setting to enable server-side AST fuzzer."}) \ DECLARE(Bool, ast_fuzzer_any_query, false, R"( When false (default), the server-side AST fuzzer (controlled by `ast_fuzzer_runs`) only fuzzes read-only queries (SELECT, EXPLAIN, SHOW, DESCRIBE, EXISTS). When true, all query types including DDL and INSERT are fuzzed. )", EXPERIMENTAL, \ {"26.2", false, false, "New setting to allow fuzzing all query types, not just read-only."}) \ DECLARE(Bool, ast_fuzzer_oracle, false, R"( When enabled together with `ast_fuzzer_runs`, applies a suite of correctness oracle checks to successfully executed fuzzed SELECT queries: TLP WHERE/DISTINCT/GROUP BY/HAVING/Aggregate, NoREC, DQP (toggling individual optimizer settings), Identity WHERE, and Subquery wrap. A mismatch throws an `AST_FUZZER_ORACLE_MISMATCH` exception. )", EXPERIMENTAL, \ {"26.9", false, false, "New setting to enable correctness oracle checks in the server-side AST fuzzer."}) \ DECLARE(Bool, allow_fuzz_query_functions, false, R"( Enables the `fuzzQuery` function that applies random AST mutations to a query string. )", EXPERIMENTAL, \ {"26.2", false, false, "New setting to enable the fuzzQuery function."}) \ \ DECLARE(UInt64, readonly, 0, R"( 0 - no read-only restrictions. 1 - only read requests, as well as changing explicitly allowed settings. 2 - only read requests, as well as changing settings, except for the 'readonly' setting. Do not make `readonly` itself changeable under `readonly = 1`: a session can then clear it with `SET readonly = 0`, unless the same constraint also forbids `0`. See [constraints on settings](/concepts/features/configuration/settings/constraints-on-settings#readonly-changeable-in-readonly). )", 0) \ \ DECLARE(UInt64, max_rows_in_set, 0, R"( The maximum number of rows for a data set in the IN clause created from a subquery. )", 0) \ DECLARE(UInt64, max_bytes_in_set, 0, R"( The maximum number of bytes (of uncompressed data) used by a set in the IN clause created from a subquery. )", 0) \ DECLARE(OverflowMode, set_overflow_mode, OverflowMode::THROW, R"( Sets what happens when the amount of data exceeds one of the limits. Possible values: - `throw`: throw an exception (default). - `break`: stop executing the query and return the partial result, as if the source data ran out. )", 0) \ \ DECLARE(Bool, exact_rows_before_limit, false, R"( When enabled, ClickHouse will provide exact value for rows_before_limit_at_least statistic, but with the cost that the data before limit will have to be read completely )", 0) \ DECLARE(Bool, rows_before_aggregation, false, R"( When enabled, ClickHouse will provide exact value for rows_before_aggregation statistic, represents the number of rows read before aggregation )", 0, \ {"24.8", false, false, "Provide exact value for rows_before_aggregation statistic, represents the number of rows read before aggregation"}) \ DECLARE(UInt64, max_rows_in_join, 0, R"( Limits the number of rows in the right-side data structure (typically a hash table) used when joining tables. This setting applies to [SELECT ... JOIN](/reference/statements/select/join) operations and the [Join](/reference/engines/table-engines/special/join) table engine. If a query contains multiple joins, ClickHouse checks this setting for every intermediate result. It is a hard cap for every hash-based `join_algorithm`: when the limit is reached the query throws or breaks according to [`join_overflow_mode`](/reference/settings/session-settings/join#join_overflow_mode). It never makes a join spill to disk — that decision belongs to [`max_bytes_before_external_join`](/reference/settings/session-settings/max-bytes#max_bytes_before_external_join) and [`max_bytes_ratio_before_external_join`](/reference/settings/session-settings/max-bytes#max_bytes_ratio_before_external_join). The exception is `legacy_join_size_limits_trigger_spilling`: with it on, the part of a join that already runs on disk treats this limit as a further spill trigger instead of a cap. When an `ON` section determines no join key at all, there is no algorithm to choose: the limit applies to the right side materialized by the [block nested loop join](/reference/statements/select/join#join-with-an-arbitrary-on-condition), spilled blocks included, and the action on overflow is [`join_overflow_mode`](/reference/settings/session-settings/join#join_overflow_mode). Possible values: - Positive integer. - `0` — Unlimited number of rows. )", 0) \ DECLARE(UInt64, max_bytes_in_join, 0, R"( The maximum size in bytes of the right-side data structure (typically a hash table) used when joining tables. This setting applies to [SELECT ... JOIN](/reference/statements/select/join) operations and the [Join table engine](/reference/engines/table-engines/special/join). If a query contains multiple joins, ClickHouse checks this setting for every intermediate result. It is a hard cap for every hash-based `join_algorithm`: when the limit is reached the query throws or breaks according to [`join_overflow_mode`](/reference/settings/session-settings/join#join_overflow_mode). It never makes a join spill to disk — that decision belongs to [`max_bytes_before_external_join`](#max_bytes_before_external_join) and [`max_bytes_ratio_before_external_join`](#max_bytes_ratio_before_external_join). Because it is a cap rather than a trigger, setting it at or below the spill threshold normally makes the query fail before the join can spill at all — unless the join is spill-capable and `enable_adaptive_memory_spill_scheduler` forces a spill first, or `legacy_join_size_limits_trigger_spilling` turns this limit back into a spill trigger for the part of a join that already runs on disk. The limit counts what the hash tables hold, so a join that spilled reaches it as each bucket is loaded rather than while the right side is read: it can read more of the right side before stopping than an in-memory hash join would. When an `ON` section determines no join key at all, there is no algorithm to choose: the limit applies to the right side materialized by the [block nested loop join](/reference/statements/select/join#join-with-an-arbitrary-on-condition), spilled blocks included, and the action on overflow is [`join_overflow_mode`](/reference/settings/session-settings/join#join_overflow_mode). Possible values: - Positive integer. - 0 — Memory control is disabled. )", 0) \ DECLARE(OverflowMode, join_overflow_mode, OverflowMode::THROW, R"( Defines what action ClickHouse performs when a join reaches any of the following limits: - [max_bytes_in_join](/reference/settings/session-settings/max-bytes#max_bytes_in_join) - [max_rows_in_join](/reference/settings/session-settings/max-rows#max_rows_in_join) Every hash-based [`join_algorithm`](/reference/settings/session-settings/join#join_algorithm) value honors this setting, including the ones that spill to disk: reaching the limit stops the query rather than triggering a spill. The exception is `legacy_join_size_limits_trigger_spilling`: with it on, the part of a join that already runs on disk spills further instead of acting on this setting. `ie_join` honors it as well, on the input it accumulates from both sides. `partial_merge` still handles the limits by switching strategy — see [`join_algorithm`](/reference/settings/session-settings/join#join_algorithm). Possible values: - `THROW` — ClickHouse throws an exception and stops the query. - `BREAK` — ClickHouse stops the query and does not throw an exception. Default value: `THROW`. **See Also** - [JOIN clause](/reference/statements/select/join) - [Join table engine](/reference/engines/table-engines/special/join) )", 0) \ DECLARE(Bool, join_any_take_last_row, false, R"( Changes the behaviour of join operations with `ANY` strictness when the right table has more than one matching row for a key. This setting applies to [`Join`](/reference/engines/table-engines/special/join) engine tables and hash-based join algorithms. It has no effect on a [block nested loop join](/reference/statements/select/join#join-with-an-arbitrary-on-condition): with no join key there is no group of matching rows to take the last one of. If a join is built in parallel, the order of rows can be non-deterministic. This means that `join_any_take_last_row = 1` can return a non-deterministic row for `ANY JOIN` queries. Possible values: - 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. See also: - [JOIN clause](/reference/statements/select/join) - [Join table engine](/reference/engines/table-engines/special/join) - [join_default_strictness](#join_default_strictness) )", IMPORTANT) \ DECLARE(JoinAlgorithm, join_algorithm, "direct,hash,ie_join", R"( Specifies which [JOIN](/reference/statements/select/join) algorithm is used. Several algorithms can be specified, and an available one would be chosen for a particular query based on kind/strictness and table engine. Spilling for hash-based algorithms is configured separately from `join_algorithm`. All hash-based algorithms use [`max_bytes_before_external_join`](/reference/settings/session-settings/max-bytes#max_bytes_before_external_join) and [`max_bytes_ratio_before_external_join`](/reference/settings/session-settings/max-bytes#max_bytes_ratio_before_external_join) as spill thresholds. Most algorithms affect a query only when they are the one selected for it. Some, however, change planning merely by being listed — even as a lower-priority fallback that is not ultimately selected — because the decision is made before the algorithm is picked. There are two such effects: - Join-key type inference becomes stricter (a merge join cannot join keys of different types, for example `String` and `Nullable(String)`). This can change the result types of `USING` columns, and can make a join into a `Join`-engine table fail with `TYPE_MISMATCH`. Triggered by `full_sorting_merge` and `parallel_full_sorting_merge`. - `ORDER BY ... LIMIT` on the preserved side of a join gets an explicit sort instead of a read in primary-key order, because the join is assumed to break the ordered read (a merge join inserts its own pre-join sort; a partial merge join re-sorts the left blocks; a join that can produce delayed blocks does not propagate the ordered read either). The result is the same, the plan is less efficient. Triggered by `full_sorting_merge`, `parallel_full_sorting_merge`, `partial_merge`, `prefer_partial_merge`, `grace_hash` and `auto`, and also by a non-zero `max_bytes_before_external_join` / `max_bytes_ratio_before_external_join`. Both apply even when the query eventually runs with `hash` or another algorithm. If this is undesirable, do not list the algorithms above in `join_algorithm` for the affected queries. Possible values: - grace_hash [Grace hash join](https://en.wikipedia.org/wiki/Hash_join#Grace_hash_join) is used. Grace hash provides an algorithm option that provides performant complex joins while limiting memory use. Selecting `grace_hash` explicitly is intended primarily for diagnostic use. To enable join spilling, set [`max_bytes_before_external_join`](/reference/settings/session-settings/max-bytes#max_bytes_before_external_join) or [`max_bytes_ratio_before_external_join`](/reference/settings/session-settings/max-bytes#max_bytes_ratio_before_external_join) instead. `grace_hash` is external from the first block: the right table is partitioned straight away, where `hash` and `parallel_hash` collect it in memory first and partition it only once it crosses the spill threshold. Pick it when you already know the right side will not fit in memory and want to skip the in-memory phase. The spill threshold itself is the same one every hash algorithm uses, [`max_bytes_before_external_join`](/reference/settings/session-settings/max-bytes#max_bytes_before_external_join) / [`max_bytes_ratio_before_external_join`](/reference/settings/session-settings/max-bytes#max_bytes_ratio_before_external_join), and one of the two has to be non-zero unless `legacy_join_size_limits_trigger_spilling` is on. Without a threshold `grace_hash` is passed over for the next algorithm in the list, and rejected if it is the only one. The first phase of a grace join reads the right table and splits it into N buckets depending on the hash value of key columns (initially, N is `grace_hash_join_initial_buckets`). This is done in a way to ensure that each bucket can be processed independently. Rows from the first bucket are added to an in-memory hash table while the others are saved to disk. If the hash table grows beyond the spill threshold, the number of buckets is increased along with the assigned bucket for each row. Any rows which don't belong to the current bucket are flushed and reassigned. Supports `INNER/LEFT/RIGHT/FULL ALL/ANY JOIN`. - hash [Hash join algorithm](https://en.wikipedia.org/wiki/Hash_join) is used. The most generic implementation that supports all combinations of kind and strictness and multiple join keys that are combined with `OR` in the `JOIN ON` section. When using the `hash` algorithm, the right part of `JOIN` is uploaded into RAM. - parallel_hash The same as `hash`, kept for compatibility. `INNER`, `LEFT`, `RIGHT` and `FULL` hash joins can build the hash table on up to `max_threads` threads, and `parallel_hash_join_threshold` decides when they do. To build it on several threads whenever the join kind allows it, set `parallel_hash_join_threshold` to `0`. When using the `parallel_hash` algorithm, the right part of `JOIN` is uploaded into RAM. - partial_merge A variation of the [sort-merge algorithm](https://en.wikipedia.org/wiki/Sort-merge_join), where only the right table is fully sorted. The `RIGHT JOIN` and `FULL JOIN` are supported only with `ALL` strictness (`SEMI`, `ANTI`, `ANY`, and `ASOF` are not supported). When using the `partial_merge` algorithm, ClickHouse sorts the data and dumps it to the disk. The `partial_merge` algorithm in ClickHouse differs slightly from the classic realization. First, ClickHouse sorts the right table by joining keys in blocks and creates a min-max index for sorted blocks. Then it sorts parts of the left table by the `join key` and joins them over the right table. The min-max index is also used to skip unneeded right table blocks. - direct The `direct` (also known as nested loop) algorithm performs a lookup in the right table using rows from the left table as keys. It's supported by special storages such as [Dictionary](/reference/engines/table-engines/special/dictionary), [EmbeddedRocksDB](/reference/engines/table-engines/integrations/embedded-rocksdb), and [MergeTree](/reference/engines/table-engines/mergetree-family/mergetree) tables. For MergeTree tables, the algorithm pushes join key filters directly to the storage layer. This can be more efficient when the key can use the table's primary key index for lookups, otherwise it performs full scans of the right table for each left table block. Supports `INNER` and `LEFT` joins and only single-column equality join keys without other conditions. - auto When set to `auto`, `hash` join is tried first, and the algorithm is switched on the fly to another algorithm if the memory limit is violated. - full_sorting_merge [Sort-merge algorithm](https://en.wikipedia.org/wiki/Sort-merge_join) with full sorting of joined tables before joining. - ie_join The sort-based [IEJoin](https://vldb.org/pvldb/vol8/p2074-khayyat.pdf) algorithm for a `JOIN` whose `ON` section has two inequality comparisons (`<`, `<=`, `>`, `>=`) between expressions of the joined tables. Supports `ALL INNER/LEFT/RIGHT/FULL JOIN` and `SEMI`/`ANTI` `LEFT/RIGHT JOIN`. The position in the list sets the priority. Listed after other algorithms, as in the default value, `ie_join` is used only when the `ON` section has no equality conditions. Listed first, it is used whenever the `ON` section has two inequality conditions, and any remaining conditions are applied as a filter over the join result. When there are more than two inequality conditions, the two used by the algorithm are chosen by their estimated selectivity from [column statistics](/reference/engines/table-engines/mergetree-family/mergetree#column-statistics); without statistics, the first two in syntax order are used. Without `ie_join` in the list, an `INNER JOIN` with only inequality conditions is executed as a `CROSS JOIN` with a filter, and the other join kinds as a [block nested loop join](/reference/statements/select/join#join-with-an-arbitrary-on-condition). Both inputs are accumulated in memory before joining: [`max_rows_in_join`](/reference/settings/session-settings#max_rows_in_join) and [`max_bytes_in_join`](/reference/settings/session-settings#max_bytes_in_join) limit the accumulated input of both sides together (not just the right side), with the action on overflow set by [`join_overflow_mode`](/reference/settings/session-settings#join_overflow_mode); the sort indexes the operator builds on top of the accumulated input are not counted against the limit. The join operator itself runs in a single thread; only the pre-join sorts of the inputs are parallelized. - parallel_full_sorting_merge Same as `full_sorting_merge`, but hash-compatible equality joins are sharded by the hash of the join keys into independent per-shard merge joins that run in parallel (up to `max_threads`), instead of a single merge join. This keeps the low, streaming memory usage of a merge join while using all threads, and the result is not ordered. Hash-sharding by the join keys is applied only to plain equality joins on key types whose hash agrees with the merge-join comparison, and only when neither side is already sorted. It is skipped in these cases: - `ASOF` joins, and floating-point / `JSON` / `Object` / `Dynamic` key types: their hashes are not consistent with the merge-join comparison, so equal keys could land in different shards. - Sides that are already sorted (a MergeTree read in order, or any pre-sorted input): an order-preserving scatter into the per-shard merges can deadlock the pipeline. The in-order read and its `read_in_order_use_virtual_row` optimization are kept instead. - While the initiator builds a distributed plan (`make_distributed_plan`), because the scattered sort is not serializable for remote execution. The local single-fragment plan and the per-worker fragments re-optimize with that setting disabled, so they can still be sharded. Skipping it disables only this rewrite, not parallelism in general: the join runs as a single `full_sorting_merge`, and MergeTree sides read in order can still be sharded at the source by primary-key ranges (which order by the same comparison the join uses, so equal keys stay together) by `query_plan_join_shard_by_pk_ranges` (enabled by default). - prefer_partial_merge ClickHouse always tries to use `partial_merge` join if possible, otherwise, it uses `hash`. *Deprecated*, same as `partial_merge,hash`. - default (deprecated) Legacy value, please don't use anymore. Same as `direct,hash`, i.e. try to use direct join and hash join (in this order). )", 0, \ {"26.11", "direct,parallel_hash,hash,ie_join", "direct,hash,ie_join", "`parallel_hash` is an obsolete alias of `hash` and was dropped from the default list; it is still accepted. Listing `hash` or `parallel_hash` does not control how parallel the join is."}, \ {"26.8", "direct,parallel_hash,hash", "direct,parallel_hash,hash,ie_join", "Appended `ie_join` to the default list, so a join whose `ON` section has only inequality conditions is executed with IEJoin instead of a `CROSS JOIN` with a filter. Being last, it is used only when the other algorithms do not apply."}, \ {"24.12", "default", "direct,parallel_hash,hash", "'default' was deprecated in favor of explicitly specified join algorithms, also parallel_hash is now preferred over hash"}) \ DECLARE(Bool, allow_block_nested_loop_join, true, R"( Allow executing a `JOIN` with an arbitrary `ON` condition, one with no equality between the joined tables, as a [block nested loop join](/reference/statements/select/join#join-with-an-arbitrary-on-condition). It examines every pair of rows, which costs the product of the two tables' row counts. The operator is the last resort of join planning, reached only when no [`join_algorithm`](/reference/settings/session-settings/join#join_algorithm) can execute the condition, so it is not selected through that setting. When the setting is disabled, a query that reaches the operator is rejected with `INVALID_JOIN_ON_EXPRESSION` while it is being planned. Possible values: - 0 — Reject such a query. - 1 — Execute it as a block nested loop join (default). )", 0, \ {"26.10", false, true, "New setting that gates the block nested loop join, which executes a `JOIN` whose `ON` section determines no join key instead of rejecting it with `INVALID_JOIN_ON_EXPRESSION`. The compatibility value 0 restores the previous behavior."}) \ DECLARE(UInt64, cross_to_inner_join_rewrite, 1, R"( Use inner join instead of comma/cross join if there are joining expressions in the WHERE section. Values: 0 - no rewrite, 1 - apply if possible for comma/cross, 2 - force rewrite all comma joins, cross - if possible )", 0) \ DECLARE(UInt64, cross_join_min_rows_to_compress, 10000000, R"( Minimal count of rows to compress block in CROSS JOIN, and in the [block nested loop join](/reference/statements/select/join#join-with-an-arbitrary-on-condition), which materializes its right side the same way. Zero value means - disable this threshold. This block is compressed when any of the two thresholds (by rows or by bytes) are reached. )", 0, \ {"24.5", 0, 10000000, "Minimal count of rows to compress block in CROSS JOIN. Zero value means - disable this threshold. This block is compressed when any of the two thresholds (by rows or by bytes) are reached."}) \ DECLARE(UInt64, cross_join_min_bytes_to_compress, 1_GiB, R"( Minimal size of block to compress in CROSS JOIN, and in the [block nested loop join](/reference/statements/select/join#join-with-an-arbitrary-on-condition), which materializes its right side the same way. Zero value means - disable this threshold. This block is compressed when any of the two thresholds (by rows or by bytes) are reached. )", 0, \ {"24.5", 0, 1_GiB, "Minimal size of block to compress in CROSS JOIN. Zero value means - disable this threshold. This block is compressed when any of the two thresholds (by rows or by bytes) are reached."}) \ DECLARE(UInt64, default_max_bytes_in_join, 1000000000, R"( Maximum size of right-side table if limit is required but `max_bytes_in_join` is not set. )", 0) \ DECLARE(UInt64, partial_merge_join_left_table_buffer_bytes, 0, R"( If not 0 group left table blocks in bigger ones for left-side table in partial merge join. It uses up to 2x of specified memory per joining thread. )", 0) \ DECLARE(UInt64, partial_merge_join_rows_in_right_blocks, 65536, R"( Limits sizes of right-hand join data blocks in partial merge join algorithm for [JOIN](/reference/statements/select/join) queries. ClickHouse server: 1. Splits right-hand join data into blocks with up to the specified number of rows. 2. Indexes each block with its minimum and maximum values. 3. Unloads prepared blocks to disk if it is possible. Possible values: - Any positive integer. Recommended range of values: \[1000, 100000\]. )", 0) \ DECLARE(UInt64, join_on_disk_max_files_to_merge, 64, R"( Limits the number of files allowed for parallel sorting in MergeJoin operations when they are executed on disk. The bigger the value of the setting, the more RAM is used and the less disk I/O is needed. Possible values: - Any positive integer, starting from 2. )", 0) \ DECLARE(NonZeroUInt64, grace_hash_join_initial_buckets, 1, R"( Initial number of grace hash join buckets )", 0, \ {"26.11", 1, 1, "The setting is no longer experimental. The default is unchanged."}) \ DECLARE(NonZeroUInt64, grace_hash_join_max_buckets, 1024, R"( Limit on the number of grace hash join buckets )", 0, \ {"26.11", 1024, 1024, "The setting is no longer experimental. The default is unchanged."}) \ DECLARE(UInt64, max_rows_in_set_to_optimize_join, 0, R"( Maximal size of the set to filter joined tables by each other's row sets before joining. Possible values: - 0 — Disable. - Any positive integer. )", 0, \ {"24.1", 100000, 0, "Disable join optimization as it prevents from read in order optimization"}) \ \ DECLARE(Bool, compatibility_ignore_collation_in_create_table, true, R"( Compatibility ignore collation in create table )", 0) \ \ DECLARE(String, temporary_files_codec, "LZ4", R"( Sets compression codec for temporary files used in sorting and joining operations on disk. Sets of `IN` that spill to disk do not compress the files that their lookups read, whatever this setting is, because decompressing the blocks that each lookup reads costs more than reading the larger files. Possible values: - LZ4 — [LZ4](https://en.wikipedia.org/wiki/LZ4_(compression_algorithm)) compression is applied. - NONE — No compression is applied. )", 0) \ \ DECLARE(NonZeroUInt64, temporary_files_buffer_size, DBMS_DEFAULT_BUFFER_SIZE, "Size of the buffer for temporary files writers. Larger buffer size means less system calls, but more memory consumption. A value above 1 GiB is reduced to 1 GiB.", 0, \ {"25.10", DBMS_DEFAULT_BUFFER_SIZE, DBMS_DEFAULT_BUFFER_SIZE, "New setting"}) \ DECLARE(UInt64, max_rows_to_transfer, 0, R"( Maximum size (in rows) that can be passed to a remote server or saved in a temporary table when the GLOBAL IN/JOIN section is executed. )", 0) \ DECLARE(UInt64, max_bytes_to_transfer, 0, R"( The maximum number of bytes (uncompressed data) that can be passed to a remote server or saved in a temporary table when the GLOBAL IN/JOIN section is executed. )", 0) \ DECLARE(OverflowMode, transfer_overflow_mode, OverflowMode::THROW, R"( Sets what happens when the amount of data exceeds one of the limits. Possible values: - `throw`: throw an exception (default). - `break`: stop executing the query and return the partial result, as if the source data ran out. )", 0) \ \ DECLARE(UInt64, max_rows_in_distinct, 0, R"( The maximum number of different rows when using DISTINCT. )", 0) \ DECLARE(UInt64, max_bytes_in_distinct, 0, R"( The maximum number of bytes of the state (in uncompressed bytes) in memory, which is used by a hash table when using DISTINCT. )", 0) \ DECLARE(OverflowMode, distinct_overflow_mode, OverflowMode::THROW, R"( Sets what happens when the amount of data exceeds one of the limits. Possible values: - `throw`: throw an exception (default). - `break`: stop executing the query and return the partial result, as if the source data ran out. )", 0) \ \ DECLARE(UInt64, max_memory_usage, 0, R"( Cloud default value: depends on the amount of RAM on the replica. The maximum amount of RAM to use for running a query on a single server. A value of `0` means unlimited. This setting does not consider the volume of available memory or the total volume of memory on the machine. The restriction applies to a single query within a single server. You can use `SHOW PROCESSLIST` to see the current memory consumption for each query. Peak memory consumption is tracked for each query and written to the log. Memory usage is not fully tracked for states of the following aggregate functions from `String` and `Array` arguments: - `min` - `max` - `any` - `anyLast` - `argMin` - `argMax` Memory consumption is also restricted by the parameters [`max_memory_usage_for_user`](/reference/settings/session-settings/max-memory-usage#max_memory_usage_for_user) and [`max_server_memory_usage`](/reference/settings/server-settings/settings/max-server-memory-usage#max_server_memory_usage). )", 0) \ DECLARE(UInt64, memory_overcommit_ratio_denominator, 1_GiB, R"( It represents the soft memory limit when the hard limit is reached on the global level. This value is used to compute the overcommit ratio for the query. Zero means skip the query. Read more about [memory overcommit](/concepts/features/configuration/settings/memory-overcommit). )", 0, \ {"22.5", 0, 1073741824, "Enable memory overcommit feature by default"}) \ DECLARE(UInt64, max_memory_usage_for_user, 0, R"( The maximum amount of RAM to use for running a user's queries on a single server. Zero means unlimited. By default, the amount is not restricted (`max_memory_usage_for_user = 0`). Also see the description of [`max_memory_usage`](/reference/settings/session-settings/max-memory-usage#max_memory_usage). For example if you want to set `max_memory_usage_for_user` to 1000 bytes for a user named `clickhouse_read`, you can use the statement ```sql ALTER USER clickhouse_read SETTINGS max_memory_usage_for_user = 1000; ``` You can verify it worked by logging out of your client, logging back in, then use the `getSetting` function: ```sql SELECT getSetting('max_memory_usage_for_user'); ``` )", 0) \ DECLARE(UInt64, memory_overcommit_ratio_denominator_for_user, 1_GiB, R"( It represents the soft memory limit when the hard limit is reached on the user level. This value is used to compute the overcommit ratio for the query. Zero means skip the query. Read more about [memory overcommit](/concepts/features/configuration/settings/memory-overcommit). )", 0, \ {"22.5", 0, 1073741824, "Enable memory overcommit feature by default"}) \ DECLARE(UInt64, max_untracked_memory, (4 * 1024 * 1024), R"( Small allocations and deallocations are grouped in thread local variable and tracked or profiled only when an amount (in absolute value) becomes larger than the specified value. If the value is higher than 'memory_profiler_step' it will be effectively lowered to 'memory_profiler_step'. )", 0) \ DECLARE(UInt64, max_reverse_dictionary_lookup_cache_size_bytes, (100 * 1024 * 1024), R"( Maximum size in bytes of the per-query reverse dictionary lookup cache used by the function `dictGetKeys`. The cache stores serialized key tuples per attribute value to avoid re-scanning the dictionary within the same query. When the limit is reached, entries are evicted using LRU. Set to 0 to disable caching. )", 0, \ {"25.12", 100 * 1024 * 1024, 100 * 1024 * 1024, "New setting. Maximum size in bytes of the per-query reverse dictionary lookup cache used by the function `dictGetKeys`. The cache stores serialized key tuples per attribute value to avoid re-scanning the dictionary within the same query."}) \ DECLARE(UInt64, memory_profiler_step, (4 * 1024 * 1024), R"( Sets the step of memory profiler. Whenever query memory usage becomes larger than every next step in number of bytes the memory profiler will collect the allocating stacktrace and will write it into [trace_log](/reference/system-tables/trace_log). Possible values: - A positive integer number of bytes. - 0 for turning off the memory profiler. )", 0) \ DECLARE(Float, memory_profiler_sample_probability, 0., R"( Collect random allocations and deallocations and write them into system.trace_log with 'MemorySample' trace_type. The probability is for every alloc/free regardless of the size of the allocation (can be changed with `memory_profiler_sample_min_allocation_size` and `memory_profiler_sample_max_allocation_size`). Note that sampling happens only when the amount of untracked memory exceeds 'max_untracked_memory'. You may want to set 'max_untracked_memory' to 0 for extra fine-grained sampling. )", 0) \ DECLARE(UInt64, memory_profiler_sample_min_allocation_size, 0, R"( Collect random allocations of size greater or equal than the specified value with probability equal to `memory_profiler_sample_probability`. 0 means disabled. You may want to set 'max_untracked_memory' to 0 to make this threshold work as expected. )", 0) \ DECLARE(UInt64, memory_profiler_sample_max_allocation_size, 0, R"( Collect random allocations of size less or equal than the specified value with probability equal to `memory_profiler_sample_probability`. 0 means disabled. You may want to set 'max_untracked_memory' to 0 to make this threshold work as expected. )", 0) \ DECLARE(Bool, trace_profile_events, false, R"( Enables or disables collecting stacktraces on each update of profile events along with the name of profile event and the value of increment and sending them into [trace_log](/reference/system-tables/trace_log). Possible values: - 1 — Tracing of profile events enabled. - 0 — Tracing of profile events disabled. )", 0) \ DECLARE(String, trace_profile_events_list, "", R"( When the setting `trace_profile_events` is enabled, limit the traced events to the specified list of comma-separated names. If the `trace_profile_events_list` is an empty string (by default), trace all profile events. Example value: 'DiskS3ReadMicroseconds,DiskS3ReadRequestsCount,SelectQueryTimeMicroseconds,ReadBufferFromS3Bytes' Using this setting allows more precise collection of data for a large number of queries, because otherwise the vast amount of events can overflow the internal system log queue and some portion of them will be dropped. The names are checked against [`system.events`](/reference/system-tables/events), and a query fails if the list mentions an event that does not exist. )", 0, \ {"26.1", "", "", "New setting"}) \ \ DECLARE(UInt64, memory_usage_overcommit_max_wait_microseconds, 5'000'000, R"( Maximum time thread will wait for memory to be freed in the case of memory overcommit on a user level. If the timeout is reached and memory is not freed, an exception is thrown. Read more about [memory overcommit](/concepts/features/configuration/settings/memory-overcommit). )", 0) \ \ DECLARE(UInt64, reserve_memory, 0, R"( Used in workload scheduling. The minimum amount of RAM reserved to be used for running a query on a single server. Reservation is made through the WORKLOAD hierarchy using the value of a `workload` query setting. If not enough memory is available to the workload, a query is prevented from starting and waits in pending state until the reservation can be fulfilled. A value of `0` means no reservation. This setting takes effect only if MEMORY RESERVATION resource is created. )", EXPERIMENTAL, \ {"26.7", 0, 0, "New setting to reserve memory for specific workload before starting a query."}) \ DECLARE(UInt64, min_bytes_to_spill, 64_MiB, R"( Used in workload scheduling. The minimum amount of bytes to spill. This setting takes effect only if MEMORY RESERVATION resource is created. )", EXPERIMENTAL, \ {"26.10", 0, 64_MiB, "New setting for dynamic spilling via workloads."}) \ DECLARE(UInt64, max_network_bandwidth, 0, R"( Limits the speed of the data exchange over the network in bytes per second. This setting applies to every query. Possible values: - Positive integer. - 0 — Bandwidth control is disabled. )", 0) \ DECLARE(UInt64, max_network_bytes, 0, R"( 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. Possible values: - Positive integer. - 0 — Data volume control is disabled. )", 0) \ DECLARE(UInt64, max_network_bandwidth_for_user, 0, R"( 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. Possible values: - Positive integer. - 0 — Control of the data speed is disabled. )", 0)\ DECLARE(UInt64, max_network_bandwidth_for_all_users, 0, R"( 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. Possible values: - Positive integer. - 0 — Control of the data speed is disabled. )", 0) \ \ DECLARE(UInt64, max_temporary_data_on_disk_size_for_user, 0, R"( The maximum amount of data consumed by temporary files on disk in bytes for all concurrently running user queries. Possible values: - Positive integer. - `0` — unlimited (default) )", 0)\ DECLARE(UInt64, max_temporary_data_on_disk_size_for_query, 0, R"( The maximum amount of data consumed by temporary files on disk in bytes for all concurrently running queries. Possible values: - Positive integer. - `0` — unlimited (default) )", 0)\ DECLARE(UInt64, max_temporary_tables, 0, R"( The maximum number of temporary tables that can exist in one session at the same time. Only tables created with `CREATE TEMPORARY TABLE` are counted: tables with external data sent with a query and the temporary tables built internally for `GLOBAL IN` / `GLOBAL JOIN` or materialized CTEs are not. The limit is checked when a new temporary table is created, and an exception with the `TOO_MANY_TABLES` error code is thrown if the session already has this number of temporary tables. Replacing an existing temporary table with `CREATE OR REPLACE TEMPORARY TABLE` does not increase the number of tables and is always allowed. Possible values: - Positive integer. - `0` — unlimited (default) )", 0, \ {"26.10", 0, 0, "New setting to limit the number of temporary tables in a session."}) \ DECLARE(UInt64, max_temporary_table_memory_usage, 0, R"( The maximum number of bytes of memory that one temporary table with the `Memory` engine can hold. It applies to tables created with `CREATE TEMPORARY TABLE`, including the default temporary table engine (see `default_temporary_table_engine`), and is counted in the same way as `total_bytes` in `system.tables`. The limit is checked on every `INSERT` into the table (including `CREATE TEMPORARY TABLE ... AS SELECT`), while the data is being received and again before it is added: if the table would exceed it, the `INSERT` throws an exception with the `TOO_MANY_BYTES` error code and the data is not added. An `INSERT` that writes with several threads (see `max_insert_threads`) adds the data of every thread separately, so the data of some threads may already be added when another one throws, but the table never exceeds the limit. The value is taken from the settings of the `INSERT` query. The limit is also checked after a mutation (`ALTER TABLE ... UPDATE`, `MATERIALIZE COLUMN`, etc.), with the value from the settings of the `ALTER` query: if the mutated data would exceed it, the mutation throws an exception with the `TOO_MANY_BYTES` error code and the data is left unchanged. Note that the `max_bytes_to_keep` setting of the `Memory` engine is different: it evicts the oldest data instead of rejecting the new one. If both are set, the eviction is applied first. Possible values: - Positive integer. - `0` — unlimited (default) )", 0, \ {"26.10", 0, 0, "New setting to limit the memory usage of a temporary table with the `Memory` engine."}) \ DECLARE(UInt64, max_temporary_table_size_bytes_compressed, 0, R"( The maximum size in bytes of the data on disk (compressed) of one temporary table with an engine of the `MergeTree` family. It applies to tables created with `CREATE TEMPORARY TABLE` and is counted in the same way as `total_bytes` in `system.tables`, that is, as the sum of the sizes of the active data parts. The limit is checked on every `INSERT` into the table (including `CREATE TEMPORARY TABLE ... AS SELECT`) before each new data part is committed: if the table would exceed it, the `INSERT` throws an exception with the `TOO_MANY_BYTES` error code and the part is not added. Parts committed earlier by the same `INSERT` stay in the table, as with any other error during an `INSERT` of multiple blocks. The value is taken from the settings of the `INSERT` query. The operations that add existing parts to the table are limited in the same way, with the value from the settings of their query: `ATTACH PART`, `ATTACH PARTITION`, `ATTACH PARTITION ... FROM`, `REPLACE PARTITION ... FROM` and `CREATE TEMPORARY TABLE ... CLONE AS`. They are rejected as a whole, unless they do not increase the size of the table. For `ATTACH PARTITION`, the check is done once for all its parts before they are attached, so writes running concurrently with it may make the table exceed the limit slightly. The parts written by background merges and mutations (`ALTER TABLE ... UPDATE`, `MATERIALIZE COLUMN`, etc.) are not checked, so a mutation that makes the data larger can make the table exceed the limit. Possible values: - Positive integer. - `0` — unlimited (default) )", 0, \ {"26.10", 0, 0, "New setting to limit the compressed size of a temporary table with an engine of the `MergeTree` family."}) \ DECLARE(UInt64, max_temporary_table_size_bytes_uncompressed, 0, R"( The maximum size in bytes of the uncompressed data of one temporary table with an engine of the `MergeTree` family. It applies to tables created with `CREATE TEMPORARY TABLE` and is counted in the same way as `total_bytes_uncompressed` in `system.tables`. The limit is checked in the same way as `max_temporary_table_size_bytes_compressed`. Possible values: - Positive integer. - `0` — unlimited (default) )", 0, \ {"26.10", 0, 0, "New setting to limit the uncompressed size of a temporary table with an engine of the `MergeTree` family."}) \ \ DECLARE(UInt64, backup_restore_keeper_max_retries, 1000, R"( Max retries for [Zoo]Keeper operations in the middle of a BACKUP or RESTORE operation. Should be big enough so the whole operation won't fail because of a temporary [Zoo]Keeper failure. )", 0, \ {"24.11", 20, 1000, "Should be big enough so the whole operation BACKUP or RESTORE operation won't fail because of a temporary [Zoo]Keeper failure in the middle of it."}, \ {"24.10", 20, 1000, "Should be big enough so the whole operation BACKUP or RESTORE operation won't fail because of a temporary [Zoo]Keeper failure in the middle of it."}) \ DECLARE(UInt64, backup_restore_keeper_retry_initial_backoff_ms, 100, R"( Initial backoff timeout for [Zoo]Keeper operations during backup or restore )", 0) \ DECLARE(UInt64, backup_restore_keeper_retry_max_backoff_ms, 5000, R"( Max backoff timeout for [Zoo]Keeper operations during backup or restore Cloud default value: `60000`. )", 0) \ DECLARE(UInt64, backup_restore_failure_after_host_disconnected_for_seconds, 3600, R"( If a host during a BACKUP ON CLUSTER or RESTORE ON CLUSTER operation doesn't recreate its ephemeral 'alive' node in ZooKeeper for this amount of time then the whole backup or restore is considered as failed. This value should be bigger than any reasonable time for a host to reconnect to ZooKeeper after a failure. Zero means unlimited. )", 0, \ {"26.10", 3600, 3600, "Keep the default regardless of `compatibility`.", CompatibilitySetting::Ignore}, \ {"24.11", 0, 3600, "New setting."}, \ {"24.10", 0, 3600, "New setting."}) \ DECLARE(UInt64, backup_restore_keeper_max_retries_while_initializing, 20, R"( Max retries for [Zoo]Keeper operations during the initialization of a BACKUP ON CLUSTER or RESTORE ON CLUSTER operation. )", 0, \ {"26.10", 20, 20, "Keep the default regardless of `compatibility`.", CompatibilitySetting::Ignore}, \ {"24.11", 0, 20, "New setting."}, \ {"24.10", 0, 20, "New setting."}) \ DECLARE(UInt64, backup_restore_keeper_max_retries_while_handling_error, 20, R"( Max retries for [Zoo]Keeper operations while handling an error of a BACKUP ON CLUSTER or RESTORE ON CLUSTER operation. )", 0, \ {"26.10", 20, 20, "Keep the default regardless of `compatibility`.", CompatibilitySetting::Ignore}, \ {"24.11", 0, 20, "New setting."}, \ {"24.10", 0, 20, "New setting."}) \ DECLARE(UInt64, backup_restore_finish_timeout_after_error_sec, 180, R"( How long the initiator should wait for other host to react to the 'error' node and stop their work on the current BACKUP ON CLUSTER or RESTORE ON CLUSTER operation. )", 0, \ {"26.10", 180, 180, "Keep the default regardless of `compatibility`.", CompatibilitySetting::Ignore}, \ {"24.11", 0, 180, "New setting."}, \ {"24.10", 0, 180, "New setting."}) \ DECLARE(UInt64, backup_restore_keeper_value_max_size, 1048576, R"( Maximum size of data of a [Zoo]Keeper's node during backup )", 0) \ DECLARE(UInt64, backup_restore_batch_size_for_keeper_multi, 1000, R"( Maximum size of batch for multi request to [Zoo]Keeper during backup or restore )", 0) \ DECLARE(UInt64, backup_restore_batch_size_for_keeper_multiread, 10000, R"( Maximum size of batch for multiread request to [Zoo]Keeper during backup or restore )", 0) \ DECLARE(Float, backup_restore_keeper_fault_injection_probability, 0.0f, R"( Approximate probability of failure for a keeper request during backup or restore. Valid value is in interval [0.0f, 1.0f] )", 0) \ DECLARE(UInt64, backup_restore_keeper_fault_injection_seed, 0, R"( 0 - random seed, otherwise the setting value )", 0) \ DECLARE(UInt64, backup_restore_s3_retry_attempts, 1000, R"( Setting for Aws::Client::RetryStrategy, Aws::Client does retries itself, 0 means no retries. It takes place only for backup/restore. )", 0, \ {"24.7", 1000, 1000, "Setting for Aws::Client::RetryStrategy, Aws::Client does retries itself, 0 means no retries. It takes place only for backup/restore."}) \ DECLARE(UInt64, backup_s3_expired_token_retry_timeout_ms, 120000, R"( Maximum time in milliseconds to retry an S3 request whose response identifies `ExpiredToken` during backup or restore. Retries also stop at `backup_restore_s3_retry_attempts`. Zero disables these retries. AWS S3 `HEAD` responses expose only a generic HTTP status, so this retry does not cover `HEAD` metadata requests. )", 0, \ {"26.10", 120000, 120000, "The change was backported to 26.8 and is recorded there."}, \ {"26.8", 0, 120000, "Retry S3 backup and restore requests after an expired token; 0 restores the previous behavior."}) \ DECLARE(UInt64, backup_restore_s3_retry_initial_backoff_ms, 25, R"( Initial backoff delay in milliseconds before the first retry attempt during backup and restore. Each subsequent retry increases the delay exponentially, up to the maximum specified by `backup_restore_s3_retry_max_backoff_ms` )", 0, \ {"25.8", 25, 25, "New setting"}) \ DECLARE(UInt64, backup_restore_s3_retry_max_backoff_ms, 5000, R"( Maximum delay in milliseconds between retries during backup and restore operations. )", 0, \ {"25.8", 5000, 5000, "New setting"}) \ DECLARE(Float, backup_restore_s3_retry_jitter_factor, .1f, R"( Jitter factor applied to the retry backoff delay in Aws::Client::RetryStrategy during backup and restore operations. The computed backoff delay is multiplied by a random factor in the range [1.0, 1.0 + jitter], up to the maximum `backup_restore_s3_retry_max_backoff_ms`. Must be in [0.0, 1.0] interval )", 0, \ {"25.8", 0.0, 0.1, "New setting"}) \ DECLARE(Bool, resumable_backup_from_snapshot, false, R"( Enables resumable `BACKUP FROM SNAPSHOT`: a failed attempt can be rerun without recopying the entries of batches that already completed. Only available in ClickHouse Cloud, for directory-style `S3` and `AzureBlobStorage` destinations. Enabling it in ClickHouse open-source builds, where `BACKUP FROM SNAPSHOT` itself is unavailable, makes `BACKUP` fail with `WRONG_BACKUP_SETTINGS`. )", EXPERIMENTAL, \ {"26.8", false, false, "New experimental setting to enable resumable `BACKUP FROM SNAPSHOT`."}) \ DECLARE(UInt64, max_backup_bandwidth, 0, R"( The maximum read speed in bytes per second for particular backup on server. Zero means unlimited. )", 0) \ DECLARE(Bool, restore_replicated_merge_tree_to_shared_merge_tree, false, R"( Replace table engine from Replicated*MergeTree -> Shared*MergeTree during RESTORE. Cloud default value: `1`. )", 0, \ {"25.2", false, false, "New setting."}) \ \ DECLARE(Bool, log_profile_events, true, R"( Log query performance statistics into the query_log, query_thread_log and query_views_log. )", 0) \ DECLARE(Bool, log_query_settings, true, R"( Log query settings into the query_log and OpenTelemetry span log. )", 0) \ DECLARE(Bool, log_query_threads, false, R"( Setting up query threads logging. Query threads log into the [system.query_thread_log](/reference/system-tables/query_thread_log) table. This setting has effect only when [log_queries](#log_queries) is true. Queries' threads run by ClickHouse with this setup are logged according to the rules in the [query_thread_log](/reference/settings/server-settings/settings/query#query_thread_log) server configuration parameter. Possible values: - 0 — Disabled. - 1 — Enabled. **Example** ```text log_query_threads=1 ``` )", 0) \ DECLARE(Bool, log_query_views, true, R"( Setting up query views logging. When a query run by ClickHouse with this setting enabled has associated views (materialized or live views), they are logged in the [query_views_log](/reference/settings/server-settings/settings/query#query_views_log) server configuration parameter. Example: ```text log_query_views=1 ``` )", 0) \ DECLARE(String, log_comment, "", R"( Specifies the value for the `log_comment` field of the [system.query_log](/reference/system-tables/query_log) table and comment text for the server log. It can be used to improve the readability of server logs. Additionally, it helps to select queries related to the test from the `system.query_log` after running [clickhouse-test](/resources/develop-contribute/contribute/tests). Possible values: - Any string no longer than [max_query_size](#max_query_size). If the max_query_size is exceeded, the server throws an exception. **Example** Query: ```sql SET log_comment = 'log_comment test', log_queries = 1; SELECT 1; SYSTEM FLUSH LOGS; SELECT type, query FROM system.query_log WHERE log_comment = 'log_comment test' AND event_date >= yesterday() ORDER BY event_time DESC LIMIT 2; ``` Result: ```text ┌─type────────┬─query─────┐ │ QueryStart │ SELECT 1; │ │ QueryFinish │ SELECT 1; │ └─────────────┴───────────┘ ``` )", 0) \ DECLARE(Int64, query_metric_log_interval, -1, R"( The interval in milliseconds at which the [query_metric_log](/reference/system-tables/query_metric_log) for individual queries is collected. If set to any negative value, it will take the value `collect_interval_milliseconds` from the [query_metric_log setting](/reference/settings/server-settings/settings/query#query_metric_log) or default to 1000 if not present. To disable the collection of a single query, set `query_metric_log_interval` to 0. Default value: -1 )", 0, \ {"24.10", 0, -1, "New setting."}) \ DECLARE(Bool, regexp_dict_allow_hyperscan, true, R"( Allow regexp_tree dictionary using Hyperscan library. )", 0) \ DECLARE(Bool, regexp_dict_flag_case_insensitive, false, R"( Use case-insensitive matching for a regexp_tree dictionary. Can be overridden in individual expressions with (?i) and (?-i). )", 0) \ DECLARE(Bool, regexp_dict_flag_dotall, false, R"( Allow '.' to match newline characters for a regexp_tree dictionary. )", 0) \ DECLARE(Bool, dictionary_use_async_executor, false, R"( Execute a pipeline for reading dictionary source in several threads. It's supported only by dictionaries with local CLICKHOUSE source. )", 0) \ DECLARE(BoolAuto, dictionary_lazy_load, Field("auto"), R"( Controls loading of a dictionary when specified in the `SETTINGS` clause of `CREATE DICTIONARY`: `1` defers loading until first use, `0` loads the dictionary at creation, `'auto'` follows the server setting `dictionaries_lazy_load`. Has no effect when set on a session or query level. )", 0, \ {"26.7", "auto", "auto", "New setting overriding the server setting `dictionaries_lazy_load` for an individual dictionary."}) \ DECLARE(LogsLevel, send_logs_level, LogsLevel::fatal, R"( Send server text logs with specified minimum level to client. Valid values: 'test', 'trace', 'debug', 'information', 'warning', 'error', 'fatal', 'none' )", 0) \ DECLARE(String, send_logs_source_regexp, "", R"( Send server text logs with specified regexp to match log source name. Empty means all sources. )", 0) \ DECLARE(Bool, enable_optimize_predicate_expression_to_final_subquery, true, R"( Allow push predicate to final subquery. )", 0) \ DECLARE(Bool, allow_push_predicate_when_subquery_contains_with, true, R"( Allows push predicate when subquery contains WITH clause )", 0) \ DECLARE(Bool, allow_push_predicate_ast_for_distributed_subqueries, true, R"( Allows push predicate on AST level for distributed subqueries with enabled analyzer )", 0, \ {"25.1", false, true, "A new setting"}) \ \ DECLARE(UInt64, low_cardinality_max_dictionary_size, 8192, R"( Sets a maximum size in rows of a shared global dictionary for the [LowCardinality](/reference/data-types/lowcardinality) 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. Possible values: - Any positive integer. )", 0) \ DECLARE(Bool, low_cardinality_use_single_dictionary_for_part, false, R"( Turns on or turns off using of single dictionary for the data part. 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`. Possible values: - 1 — Creating several dictionaries for the data part is prohibited. - 0 — Creating several dictionaries for the data part is not prohibited. )", 0) \ DECLARE(Bool, sql_compatible_division_for_integers, false, R"( Makes `/` and `divide` return an integer when both operands are integer types, including `Int128`, `UInt128`, `Int256`, and `UInt256`. The quotient is truncated toward zero. The result has the width of the first operand and is signed if either operand is signed. Division by zero or a quotient outside the result type's range throws an exception. `Nullable` operands propagate `NULL`. By default, division of two integers returns `Float64`. This setting does not change division involving `Decimal` or floating-point operands, or the explicit functions `intDiv`, `divideDecimal`, and `divideOrNull`. The choice is recorded in newly submitted SQL before expressions are stored in table metadata, views, SQL functions, or mutations. Existing definitions and `ATTACH` queries retain their original division semantics, independently of this setting. )", 0, \ {"26.11", false, false, "Use the SQL-compatible name for the integer division setting."}, \ {"26.10", false, false, "New setting to enable exact integer division for `/` and `divide`."}) \ DECLARE(Bool, decimal_check_overflow, true, R"( Check overflow of decimal arithmetic/comparison operations )", 0) \ DECLARE(Bool, allow_custom_error_code_in_throwif, false, R"( Enable custom error code in function throwIf(). If true, thrown exceptions may have unexpected error codes. )", 0) \ \ DECLARE(Bool, prefer_localhost_replica, true, R"( Enables/disables preferable using the localhost replica when processing distributed queries. Possible values: - 1 — ClickHouse always sends a query to the localhost replica if it exists. - 0 — ClickHouse uses the balancing strategy specified by the [load_balancing](#load_balancing) setting. Disable this setting if you use [max_parallel_replicas](#max_parallel_replicas) without [parallel_replicas_custom_key](#parallel_replicas_custom_key). If [parallel_replicas_custom_key](#parallel_replicas_custom_key) is set, disable this setting only if it's used on a cluster with multiple shards containing multiple replicas. If it's used on a cluster with a single shard and multiple replicas, disabling this setting will have negative effects. )", 0) \ DECLARE(UInt64, max_fetch_partition_retries_count, 5, R"( Amount of retries while fetching partition from another host. )", 0) \ DECLARE(UInt64, http_max_multipart_form_data_size, 1024 * 1024 * 1024, R"( Limit on size of multipart/form-data content. This setting cannot be parsed from URL parameters and should be set in a user profile. Note that content is parsed and external tables are created in memory before the start of query execution. And this is the only limit that has an effect on that stage (limits on max memory usage and max execution time have no effect while reading HTTP form data). )", 0) \ DECLARE(Bool, calculate_text_stack_trace, true, R"( Calculate text stack trace in case of exceptions during query execution. This is the default. It requires symbol lookups that may slow down fuzzing tests when a huge amount of wrong queries are executed. In normal cases, you should not disable this option. )", 0) \ DECLARE(Bool, enable_job_stack_trace, false, R"( Output stack trace of a job creator when job results in exception. Disabled by default to avoid performance overhead. )", 0, \ {"25.6", false, false, "The setting was disabled by default to avoid performance overhead."}, \ {"24.11", false, false, "Enables collecting stack traces from job's scheduling. Disabled by default to avoid performance overhead."}) \ DECLARE(Bool, allow_ddl, true, R"( If it is set to true, then a user is allowed to executed DDL queries. )", 0) \ DECLARE(Bool, parallel_view_processing, false, R"( Enables pushing to attached views concurrently instead of sequentially. )", 0) \ DECLARE(Bool, enable_unaligned_array_join, false, R"( Allow ARRAY JOIN with multiple arrays that have different sizes. When this settings is enabled, arrays will be resized to the longest one. )", 0) \ DECLARE(Bool, optimize_read_in_order, true, R"( Enables [ORDER BY](/reference/statements/select/order-by#optimization-of-data-reading) optimization in [SELECT](/reference/statements/select/index) queries for reading data from [MergeTree](/reference/engines/table-engines/mergetree-family/mergetree) tables. Possible values: - 0 — `ORDER BY` optimization is disabled. - 1 — `ORDER BY` optimization is enabled. **See Also** - [ORDER BY Clause](/reference/statements/select/order-by#optimization-of-data-reading) )", 0) \ DECLARE(Bool, optimize_read_in_reverse_order_final, true, R"( Enables reading data in reverse order of the sorting key in `SELECT` queries with the `FINAL` modifier from [ReplacingMergeTree](/reference/engines/table-engines/mergetree-family/replacingmergetree) tables, and from [Merge](/reference/engines/table-engines/special/merge) tables when every underlying table supports it. Takes effect only when [optimize_read_in_order](#optimize_read_in_order) is also enabled. Possible values: - 0 — Reading in reverse order with `FINAL` is disabled. - 1 — Reading in reverse order with `FINAL` is enabled. )", 0, \ {"26.9", false, true, "New setting to enable the read-in-order optimization when reading in reverse order of the sorting key with the `FINAL` modifier from `ReplacingMergeTree` tables."}) \ DECLARE(Bool, read_in_order_use_virtual_row, true, R"( Use virtual row while reading in order of primary key or its monotonic function fashion. It is useful when searching over multiple parts as only the parts that can actually contribute to the result are read, plus a bounded read-ahead window of at most `max_threads` parts that keeps reads parallel. )", 0, \ {"26.8", false, true, "Enable the virtual row optimization by default. When reading in order of the primary key over many parts, it lets `MergingSortedTransform` reprioritize sources using primary key values from the sparse index, so parts that are not relevant for the query are not read, plus a bounded read-ahead window of at most `max_threads` parts that keeps reads parallel. This significantly reduces peak memory consumption (see https://github.com/ClickHouse/ClickHouse/issues/52624)."}, \ {"24.11", false, false, "Use virtual row while reading in order of primary key or its monotonic function fashion. It is useful when searching over multiple parts as only relevant ones are touched."}) \ DECLARE(Bool, read_in_order_use_virtual_row_per_block, false, R"( When enabled together with `read_in_order_use_virtual_row`, emit a virtual row after each block read (not only at the beginning of each part). This allows `MergingSortedTransform` to reprioritize sources more frequently, which is useful when downstream filters discard many rows and data is distributed unevenly across parts. Note that it disables `read_in_order_use_buffering` optimization and preliminary merge (`read_in_order_two_level_merge_threshold`) for reading. )", 0, \ {"26.4", false, false, "Emit virtual row after each block during read-in-order to allow more frequent source reprioritization in MergingSortedTransform."}) \ DECLARE(Bool, optimize_aggregation_in_order, false, R"( Enables [GROUP BY](/reference/statements/select/group-by) optimization in [SELECT](/reference/statements/select/index) queries for aggregating data in corresponding order in [MergeTree](/reference/engines/table-engines/mergetree-family/mergetree) tables. It also applies to a single `uniqExact` (or `count(DISTINCT)`) without `GROUP BY` over a table sorted by its argument: the distinct values are counted as they arrive in order, so they are not kept in memory. With several threads, the read is split into ranges of the sorting key that are counted in parallel; when it cannot be split (for example, for a floating-point argument or a function of the sorting key), the usual aggregation is used. Projections are chosen before the order of aggregation. If a [projection](/reference/engines/table-engines/mergetree-family/mergetree#projections) reads fewer granules than the table, it is used even when it is not sorted by the `GROUP BY` key, and the aggregation then keeps all the groups in memory instead of aggregating in order. Possible values: - 0 — `GROUP BY` optimization is disabled. - 1 — `GROUP BY` optimization is enabled. **See Also** - [GROUP BY optimization](/reference/statements/select/group-by#group-by-optimization-depending-on-table-sorting-key) )", 0) \ DECLARE(Bool, optimize_aggregation_in_order_limit, true, R"( When enabled and aggregation in order is active, pushes LIMIT into the aggregation step to enable early termination after producing enough groups. This reduces the amount of data read when ORDER BY matches the GROUP BY key prefix. May reduce the value reported by `rows_before_limit_at_least`; use `exact_rows_before_limit` if exact counts are needed. )", 0, \ {"26.7", false, true, "New setting to push the `LIMIT` into aggregation-in-order for early termination when the `ORDER BY` is a prefix of the `GROUP BY` sort description."}) \ DECLARE(Bool, enable_adaptive_aggregator, true, R"( Enables the adaptive `GROUP BY` algorithm: every thread aggregates into its local hash table until it reaches `adaptive_aggregator_freeze_threshold` keys or its hash-table buffer reaches `adaptive_aggregator_freeze_threshold_bytes`, then the table freezes, so that rows of already-seen (frequent) keys keep updating it in place, while new (rare) keys are staged by their hash into per-partition buffers and aggregated exactly once, inside the bucket-parallel merge, which takes the partitions a few at a time in cache-sized tables. Frequent keys stay in small cache-resident tables, and rare keys are stored and processed once instead of once per thread. The external aggregation settings (`max_bytes_before_external_group_by`, `max_bytes_ratio_before_external_group_by`) are honored: past the threshold a thread writes its staged records to disk and frees them, and the merge reads them back bucket by bucket. A table that has not frozen yet is written to disk as in the ordinary external aggregation once it holds enough memory, and a frozen one once its aggregate states, such as those of `uniqExact` or `groupArray`, grow enough; the thread then starts filling a new table. )", 0, \ {"26.8", false, true, "New setting to enable adaptive `GROUP BY` aggregation that freezes each thread's local hash table once it reaches `adaptive_aggregator_freeze_threshold` keys, so frequent keys keep aggregating in the small local tables while rare keys are routed by their hash into per-bucket backlogs and aggregated exactly once, inside the bucket-parallel merge; this stores and processes rare keys once instead of once per thread."}) \ DECLARE(UInt64, adaptive_aggregator_freeze_threshold, 16384, R"( The number of keys at which the adaptive aggregator freezes a thread's local hash table (see `enable_adaptive_aggregator`). Smaller values keep the frozen tables cache-resident, larger values let them absorb more of the frequent keys. 0 freezes the tables at the first opportunity, which makes the algorithm behave like pure sharding by the key hash: every key is routed by its hash and aggregated by a single owner, just deferred to the merge phase instead of exchanged between threads during the scan. )", 0, \ {"26.8", 16384, 16384, "New setting to set the number of keys at which the adaptive aggregator (`enable_adaptive_aggregator`) freezes a thread's local hash table."}) \ DECLARE(UInt64, adaptive_aggregator_freeze_threshold_bytes, 4_MiB, R"( The memory size at which the adaptive aggregator freezes a thread's local hash table (see `enable_adaptive_aggregator`). A table freezes at whichever of this and `adaptive_aggregator_freeze_threshold` is reached first. The size is the local table's hash-table buffer, checked between blocks: the cells that every lookup walks, which hold the keys (references to the bytes of string keys) and the pointers to the aggregation states, or the states themselves where they are stored inline. The byte bound matters when the cells are wide: the key-count threshold alone would let such tables outgrow the CPU caches. The memory of the aggregation states does not count, because it grows through the keys that a table already holds, which a freeze does not stop. At the default, tables of ordinary key widths keep freezing by the key count. 0 disables the byte bound, so the key-count threshold decides. )", 0, \ {"26.9", 4194304, 4194304, "New setting bounding the adaptive aggregator's frozen local tables in bytes, whichever of it and the key-count threshold is reached first; 0 disables the byte bound."}) \ DECLARE(Bool, adaptive_aggregator_disable_thaw, false, R"( Disables the per-thread thaw guard of the adaptive aggregator (see `enable_adaptive_aggregator`). By default, a thread whose staged records keep repeating the same keys can thaw its table and resume ordinary aggregation. When at least half of the frozen threads thaw, the verdict is remembered in the hash-table statistics (`collect_hash_table_stats_during_aggregation`), so that later runs of the query do not use the adaptive aggregator. A query of the form `GROUP BY ... ORDER BY count() DESC LIMIT n` merges only the groups that can reach the top (top-K pruning). It remembers its verdict separately from the same aggregation without the `LIMIT`. If `count()` is its only aggregate, a thread also keeps its table frozen while the pruning is expected to discard most of the rows that the table stages. With this setting, repeated staged keys do not thaw a table, and a remembered verdict is ignored. The external aggregation settings still allow a growing frozen table to be written to disk and replaced with a new learning table. )", 0, \ {"26.11", false, false, "New setting to keep the adaptive aggregator's local tables frozen whatever the repeats of the staged keys, ignoring a thaw verdict remembered in the hash-table statistics."}) \ DECLARE(Bool, read_in_order_use_buffering, true, R"( Use buffering before merging while reading in order of primary key. It increases the parallelism of query execution )", 0, \ {"24.7", false, true, "Use buffering before merging while reading in order of primary key"}) \ DECLARE(UInt64, aggregation_in_order_max_block_bytes, 50000000, R"( Maximal size of block in bytes accumulated during aggregation in order of primary key. Lower block size allows to parallelize more final merge stage of aggregation. )", 0) \ DECLARE(UInt64, read_in_order_two_level_merge_threshold, 100, R"( Minimal number of parts to read to run preliminary merge step during multithread reading in order of primary key. )", 0) \ DECLARE(Bool, low_cardinality_allow_in_native_format, true, R"( Allows or restricts using the [LowCardinality](/reference/data-types/lowcardinality) data type with the [Native](/reference/formats/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. This setting is required mainly for third-party clients which do not support `LowCardinality` data type. Possible values: - 1 — Usage of `LowCardinality` is not restricted. - 0 — Usage of `LowCardinality` is restricted. )", 0) \ DECLARE(Bool, cancel_http_readonly_queries_on_client_close, false, R"( Cancels HTTP read-only queries (e.g. SELECT) when a client closes the connection without waiting for the response. Cloud default value: `1`. )", 0) \ DECLARE(Bool, external_table_functions_use_nulls, true, R"( Defines how [mysql](/reference/functions/table-functions/mysql), [postgresql](/reference/functions/table-functions/postgresql) and [odbc](/reference/functions/table-functions/odbc) table functions use Nullable columns. Possible values: - 0 — The table function explicitly uses Nullable columns. - 1 — The table function implicitly uses Nullable columns. **Usage** If the setting is set to `0`, the table function does not make Nullable columns and inserts default values instead of NULL. This is also applicable for NULL values inside arrays. )", 0) \ DECLARE(Bool, external_table_strict_query, false, R"( If it is set to true, a filter on the columns of an external table (`MySQL`, `PostgreSQL`, `SQLite`, `ODBC`, `JDBC`) that cannot be pushed down to the external database is rejected with an exception instead of being applied locally after the data is fetched. The check covers the top-level `WHERE` predicate and each conjunct of a top-level `AND`. A `PREWHERE` on the columns of the external table is not a case for this setting: these table engines do not support `PREWHERE`, and such a query is rejected with `ILLEGAL_PREWHERE` regardless of the setting. The check runs only where a filter could be pushed down at all: when the external table is the only table of the query, on either side of an `INNER JOIN`, or on the preserving side of an outer join (the left side of a `LEFT JOIN`, the right side of a `RIGHT JOIN`). On the non-preserving side of a `LEFT`/`RIGHT JOIN` and on either side of a `FULL JOIN` nothing is pushed down and nothing is checked, so a filter on the columns of the external table is applied locally after the join even in strict mode. Where the check runs, a predicate that references other tables joined in the surrounding query is not pushed down and is excluded from the check, whether it references only the joined side (for example `WHERE r.flag`) or mixes it with the external table inside one non-`AND` expression (for example `WHERE l.id = 1 OR r.flag`); such a predicate keeps its usual ClickHouse evaluation point (`WHERE` after the join, `PREWHERE` before it) and is not rejected. )", 0) \ \ DECLARE(Bool, allow_hyperscan, true, R"( Allow functions that use Hyperscan library. Disable to avoid potentially long compilation times and excessive resource usage. )", 0) \ DECLARE(UInt64, max_hyperscan_regexp_length, 0, R"( Defines the maximum length for each regular expression in the [hyperscan multi-match functions](/reference/functions/regular-functions/string-search-functions#multiMatchAny). Possible values: - Positive integer. - 0 - The length is not limited. **Example** Query: ```sql SELECT multiMatchAny('abcd', ['ab','bcd','c','d']) SETTINGS max_hyperscan_regexp_length = 3; ``` Result: ```text ┌─multiMatchAny('abcd', ['ab', 'bcd', 'c', 'd'])─┐ │ 1 │ └────────────────────────────────────────────────┘ ``` Query: ```sql SELECT multiMatchAny('abcd', ['ab','bcd','c','d']) SETTINGS max_hyperscan_regexp_length = 2; ``` Result: ```text Exception: Regexp length too large. ``` **See Also** - [max_hyperscan_regexp_total_length](#max_hyperscan_regexp_total_length) )", 0) \ DECLARE(UInt64, max_hyperscan_regexp_total_length, 0, R"( Sets the maximum length total of all regular expressions in each [hyperscan multi-match function](/reference/functions/regular-functions/string-search-functions#multiMatchAny). Possible values: - Positive integer. - 0 - The length is not limited. **Example** Query: ```sql SELECT multiMatchAny('abcd', ['a','b','c','d']) SETTINGS max_hyperscan_regexp_total_length = 5; ``` Result: ```text ┌─multiMatchAny('abcd', ['a', 'b', 'c', 'd'])─┐ │ 1 │ └─────────────────────────────────────────────┘ ``` Query: ```sql SELECT multiMatchAny('abcd', ['ab','bc','c','d']) SETTINGS max_hyperscan_regexp_total_length = 5; ``` Result: ```text Exception: Total regexp lengths too large. ``` **See Also** - [max_hyperscan_regexp_length](#max_hyperscan_regexp_length) )", 0) \ DECLARE(Bool, reject_expensive_hyperscan_regexps, true, R"( Reject patterns which will likely be expensive to evaluate with hyperscan (due to NFA state explosion) )", 0) \ DECLARE(Bool, allow_simdjson, true, R"( Allow using simdjson library in 'JSON*' functions if AVX2 instructions are available. If disabled rapidjson will be used. )", 0) \ DECLARE(Bool, json_extract_named_tuples_as_objects, false, R"( Fill named tuples from JSON objects only, in the `JSONExtract` family of functions. When disabled, a JSON array fills a named tuple positionally (the historical behavior), so which array element lands in which named field depends on the tuple's declaration order. Unnamed tuples always fill positionally from arrays regardless of this setting. This setting applies to JSON passed as a string. Extraction from a column of the `JSON` data type is not affected, for typed and untyped paths alike: it reads the column's subcolumns instead of parsing a JSON document, so it never reaches the code this setting governs. Named tuple *columns* in JSON input formats are governed by the separate [input_format_json_named_tuples_as_objects](/reference/settings/formats/input-format#input_format_json_named_tuples_as_objects) setting; this setting covers the extraction functions only. Disabled by default. )", 0, \ {"26.10", false, false, "New setting to make the `JSONExtract` family fill named tuples from JSON objects only, instead of the historical positional fill from arrays. Unnamed tuples always fill positionally, and extraction from a column of the `JSON` data type is unaffected."}) \ DECLARE(Bool, json_extract_use_cast_string_to_date_time_mode, true, R"( Controls which setting the `JSONExtract` family of functions follows when parsing a JSON string value into `DateTime` or `DateTime64`. When enabled, the parsing mode is taken from [cast_string_to_date_time_mode](#cast_string_to_date_time_mode), consistently with `CAST`. When disabled, it is taken from [date_time_input_format](/reference/settings/formats/date-time#date_time_input_format), as before version 26.8. When the chosen parser cannot read the value, the function returns the default value of the type (`1970-01-01 00:00:00`) without an error, so a mismatch between the two settings silently changes the extracted values. )", 0, \ {"26.11", true, true, "New setting to choose whether the `JSONExtract` family parses `DateTime` values according to `cast_string_to_date_time_mode` (since 26.8) or `date_time_input_format` (before 26.8)."}, \ {"26.8", false, true, "`JSONExtract` parses `DateTime` values according to `cast_string_to_date_time_mode` instead of `date_time_input_format`. `compatibility` with versions before 26.8 restores the previous behavior."}) \ DECLARE(Bool, allow_introspection_functions, false, R"( Enables or disables [introspection functions](/reference/functions/regular-functions/introspection) for query profiling. Possible values: - 1 — Introspection functions enabled. - 0 — Introspection functions disabled. **See Also** - [Sampling Query Profiler](/concepts/features/performance/troubleshoot/sampling-query-profiler) - System table [trace_log](/reference/system-tables/trace_log) )", 0) \ DECLARE(Bool, splitby_max_substrings_includes_remaining_string, false, R"( Controls whether function [splitBy*()](/reference/functions/regular-functions/splitting-merging-functions) with argument `max_substrings` > 0 will include the remaining string in the last element of the result array. Possible values: - `0` - The remaining string will not be included in the last element of the result array. - `1` - The remaining string will be included in the last element of the result array. This is the behavior of Spark's [`split()`](https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.functions.split.html) function and Python's ['string.split()'](https://docs.python.org/3/library/stdtypes.html#str.split) method. )", 0) \ \ DECLARE(Bool, allow_execute_multiif_columnar, true, R"( Allow execute multiIf function columnar )", 0) \ DECLARE(Bool, allow_executable_tables, true, R"( Allow reading through the `executable` table function and from `Executable` and `ExecutablePool` tables. Disabling this refuses reads only: creating, attaching, dropping and describing such tables still works. `ExecutablePool` processes that have already started are left running rather than terminated, but each read is still refused until the setting is enabled again. )", 0, \ {"26.10", true, true, "New setting to disable reading through the `executable` table function and from `Executable` and `ExecutablePool` tables."}) \ DECLARE(Bool, formatdatetime_f_prints_single_zero, false, R"( Formatter '%f' in function 'formatDateTime' prints a single zero instead of six zeros if the formatted value has no fractional seconds. )", 0, \ {"23.4", true, false, "Improved compatibility with MySQL DATE_FORMAT()/STR_TO_DATE()"}) \ DECLARE(Bool, formatdatetime_f_prints_scale_number_of_digits, false, R"( Formatter '%f' in function 'formatDateTime' prints only the scale amount of digits for a DateTime64 instead of fixed 6 digits. )", 0, \ {"25.1", true, false, "New setting."}) \ DECLARE(Bool, formatdatetime_parsedatetime_m_is_month_name, true, R"( Formatter '%M' in functions 'formatDateTime' and 'parseDateTime' print/parse the month name instead of minutes. )", 0, \ {"23.4", false, true, "Improved compatibility with MySQL DATE_FORMAT/STR_TO_DATE"}) \ DECLARE(Bool, parsedatetime_parse_without_leading_zeros, true, R"( Formatters '%c', '%l' and '%k' in function 'parseDateTime' parse months and hours without leading zeros. )", 0, \ {"23.11", false, true, "Improved compatibility with MySQL DATE_FORMAT/STR_TO_DATE"}) \ DECLARE(Bool, parsedatetime_e_requires_space_padding, false, R"( Formatter '%e' in function 'parseDateTime' expects that single-digit days are space-padded, e.g., ' 2' is accepted but '2' raises an error. )", 0, \ {"25.5", true, false, "Improved compatibility with MySQL DATE_FORMAT/STR_TO_DATE"}) \ DECLARE(Bool, formatdatetime_format_without_leading_zeros, false, R"( Formatters '%c', '%l' and '%k' in function 'formatDateTime' print months and hours without leading zeros. )", 0) \ DECLARE(Bool, formatdatetime_e_with_space_padding, false, R"( Formatter '%e' in function 'formatDateTime' prints single-digit days with a leading space, e.g. ' 2' instead of '2'. )", 0, \ {"25.5", true, false, "Improved compatibility with MySQL DATE_FORMAT/STR_TO_DATE"}) \ DECLARE(Bool, least_greatest_legacy_null_behavior, false, R"( If enabled, functions 'least' and 'greatest' return NULL if one of their arguments is NULL. )", 0, \ {"24.12", true, false, "New setting"}) \ DECLARE(Bool, array_count_legacy_uint32_result, false, R"( If enabled, function `arrayCount` returns `UInt32` as before version 26.10, instead of `UInt64`. The `UInt32` result silently wraps around for arrays with more than `4294967295` matching elements. The setting also restores the pre-26.10 constness of the result: a predicate folding to a constant false then produces a constant result column even for a non-constant array. During a rolling upgrade, enable it on the upgraded servers for the users under which distributed queries execute on them, to keep distributed queries initiated by not-yet-upgraded servers fully unchanged (an old initiator does not forward this setting, so type-sensitive expressions evaluated locally on upgraded shards would otherwise observe `UInt64`), and remove it after the upgrade is complete. Which user a shard-side query runs under depends on the cluster configuration: with an interserver `secret` configured, it is the initiator's current user; otherwise it is the user from the cluster definition or from the `remote` table function (`default` unless specified). The simplest robust approach is to enable the setting for all users of the upgraded servers. )", 0, \ {"26.10", true, false, "`arrayCount` now returns `UInt64` instead of `UInt32`, so that the result is exact for arrays with more than `4294967295` matching elements. Set this setting to `true` to return `UInt32` as before."}) \ DECLARE(Bool, h3togeo_lon_lat_result_order, false, R"( Function 'h3ToGeo' returns (lon, lat) if true, otherwise (lat, lon). )", 0, \ {"25.1", true, false, "A new setting"}) \ DECLARE(GeoToH3ArgumentOrder, geotoh3_argument_order, GeoToH3ArgumentOrder::LAT_LON, R"( Function 'geoToH3' accepts (lon, lat) if set to 'lon_lat' and (lat, lon) if set to 'lat_lon'. )", BETA, \ {"25.5", "lon_lat", "lat_lon", "A new setting for legacy behaviour to set lon and lat argument order"}) \ DECLARE(Bool, functions_h3_default_if_invalid, false, "If false, h3 functions, e.g. h3CellAreaM2, throw an exception if input is invalid. If true, they return 0 or default value.", 0, \ {"26.2", true, false, "A new setting for legacy behaviour to allow invalid inputs to h3 functions"}) \ DECLARE(UInt64, max_wkb_geometry_elements, 1'000'000, R"( Maximum number of points, rings, or polygons allowed in a single WKB geometry element during parsing by `readWKB` and related functions. This protects against excessive memory allocations from malformed WKB data. Set to 0 to use the hard-coded limit (100 million). )", 0, \ {"26.4", 1'000'000, 1'000'000, "New setting to limit element counts in WKB geometry parsing, preventing excessive memory allocation on malformed data."}) \ DECLARE(UInt64, max_rand_distribution_trials, 1'000'000'000, R"( Maximum number of trials allowed for random distribution functions such as `randBinomial` and `randNegativeBinomial`. This prevents extremely long computation times with large trial counts. `0` disables the limit, and the setting may be raised above its default, except for `randBinomial` with a probability strictly between 0 and 1, which always rejects more than 10^9 trials because the cost of a single sample is proportional to the number of trials in the worst case, with a probability that grows with it. The probabilities 0 and 1 are exempt from that hard cap, because a sample costs constant time for them. )", 0, \ {"26.4", 1'000'000'000, 1'000'000'000, "New setting to limit trial counts in random distribution functions, preventing hangs with extreme inputs."}) \ DECLARE(Float, max_rand_distribution_parameter, 1e6, R"( Maximum value for distribution shape parameters in random distribution functions such as `randChiSquared`, `randStudentT`, and `randFisherF`. This prevents extremely long computation times with extreme parameter values. `0` disables the limit; values for which the sampler does not terminate at all are still rejected. )", 0, \ {"26.4", 1e6, 1e6, "New setting to limit shape parameters in random distribution functions, preventing hangs with extreme inputs."}) \ DECLARE(UInt64, max_partitions_per_insert_block, 100, R"( Limits the maximum number of partitions in a single inserted block and an exception is thrown if the block contains too many partitions. - Positive integer. - `0` — Unlimited number of partitions. **Details** When inserting data, ClickHouse calculates the number of partitions in the inserted block. If the number of partitions is more than `max_partitions_per_insert_block`, ClickHouse either logs a warning or throws an exception based on `throw_on_max_partitions_per_insert_block`. Exceptions have the following text: > "Too many partitions for a single INSERT block (`partitions_count` partitions, limit is " + toString(max_partitions) + "). The limit is controlled by the 'max_partitions_per_insert_block' setting. A large number of partitions is a common misconception. It will lead to severe negative performance impact, including slow server startup, slow INSERT queries and slow SELECT queries. Recommended total number of partitions for a table is under 1000..10000. Please note, that partitioning is not intended to speed up SELECT queries (ORDER BY key is sufficient to make range queries fast). Partitions are intended for data manipulation (DROP PARTITION, etc)." This setting is a safety threshold because using a large number of partitions is a common misconception. )", 0, \ {"19.5", 0, 100, "Add a limit for the number of partitions in one block"}) \ DECLARE(Bool, throw_on_max_partitions_per_insert_block, true, R"( Allows you to control the behaviour when `max_partitions_per_insert_block` is reached. Possible values: - `true` - When an insert block reaches `max_partitions_per_insert_block`, an exception is raised. - `false` - Logs a warning when `max_partitions_per_insert_block` is reached. This can be useful if you're trying to understand the impact on users when changing [`max_partitions_per_insert_block`](/reference/settings/session-settings/max-partitions#max_partitions_per_insert_block). )", 0) \ DECLARE(Int64, max_partitions_to_read, -1, R"( Limits the maximum number of partitions that can be accessed in a single query. The setting value specified when the table is created can be overridden via query-level setting. Possible values: - Positive integer - `-1` - unlimited (default) You can also specify the MergeTree setting [`max_partitions_to_read`](/reference/settings/session-settings/max-partitions#max_partitions_to_read) in tables' setting. )", 0) \ DECLARE(Bool, check_query_single_value_result, false, R"( Defines the level of detail for the [CHECK TABLE](/reference/statements/check-table) query result for `MergeTree` family engines . Possible values: - 0 — the query shows a check status for every individual data part of a table. - 1 — the query shows the general table check status. )", 0, \ {"25.12", true, false, "Changed setting to make CHECK TABLE more useful"}) \ DECLARE(Bool, allow_drop_detached, false, R"( Allow ALTER TABLE ... DROP DETACHED PART[ITION] ... queries )", 0) \ DECLARE(Bool, allow_replace_partition_from_empty_source, false, R"( Allow `ALTER TABLE ... REPLACE PARTITION ... FROM ...` to silently drop the destination partition when the source has no parts in that partition. By default this is disallowed: `REPLACE PARTITION` from a source that has no data in the requested partition raises an exception, because in this case the operation effectively becomes a silent `DROP PARTITION` on the destination (the destination's data is removed and nothing replaces it), a common cause of accidental data loss (see [#23727](https://github.com/ClickHouse/ClickHouse/issues/23727)). Enable this setting to restore the previous behavior, for example when you intentionally use an empty source partition to clear data in the destination. For an unconditional drop, prefer `ALTER TABLE ... DROP PARTITION ...` instead. )", 0, \ {"26.6", true, false, "New safety check: `ALTER TABLE ... REPLACE PARTITION ... FROM ...` now throws when the source table has no parts in the requested partition (fixes the silent data loss in [#23727](https://github.com/ClickHouse/ClickHouse/issues/23727)). The previous behavior, silently dropping the destination partition, is preserved by setting `allow_replace_partition_from_empty_source = 1`."}) \ DECLARE(Bool, dynamic_disk_allow_from_env, false, R"( Allow using `from_env` substitutions in the dynamic disk configuration (i.e. in the `disk()` function arguments). Disabled by default to prevent users from reading arbitrary environment variables when defining table storage. )", 0, \ {"26.5", false, false, "New setting to allow `from_env` substitutions in dynamic disk configuration (the `disk()` function). Disabled by default for security."}) \ DECLARE(Bool, dynamic_disk_allow_include, false, R"( Allow using `include` in the dynamic disk configuration (i.e. in the `disk()` function arguments). Disabled by default. )", 0, \ {"26.5", false, false, "New setting to allow `include` in dynamic disk configuration (the `disk()` function). Disabled by default."}) \ DECLARE(Bool, dynamic_disk_allow_from_zk, false, R"( Allow using `from_zk` substitutions in the dynamic disk configuration (i.e. in the `disk()` function arguments). Disabled by default. )", 0, \ {"26.5", false, false, "New setting to allow `from_zk` substitutions in dynamic disk configuration (the `disk()` function). Disabled by default."}) \ DECLARE_WITH_ALIAS(Bool, s3_allow_server_credentials_in_user_queries, false, R"( Allow S3, Azure Blob Storage and MongoDB access that originates from user SQL to use server-managed credentials. Also available under the alias `allow_server_credentials_in_user_queries`, as it applies to Azure as well. When disabled (the default), the `s3`/`s3Cluster` table functions, the `S3`/`S3Queue` engines, S3 named collections, dynamic `disk(type=s3, ...)` definitions, `BACKUP`/`RESTORE TO S3`, DataLake table-data reads, and `DataLakeCatalog` databases (Glue, BigLake) may not resolve credentials from the environment, instance metadata (IMDS), IRSA, ECS, instance profile, SSO, AWS config/credentials files, or the GCP OAuth metadata service. A request that asks for one of those server-managed sources (for example `use_environment_credentials = 1` or `http_client = gcp_oauth`) without supplying usable explicit credentials is rejected with `ACCESS_DENIED`. A request that asks for none of them is sent unsigned (anonymous), the same as if `NOSIGN` had been given. `role_arn`-based STS assume-role (`extra_credentials(role_arn = '...')`) stays allowed even when this setting is disabled: the target role must explicitly trust the identity the server runs under, and only the assumed role's credentials ever sign the query's S3 requests, so the server's own credentials are not exposed to the query. This is the documented way to grant ClickHouse Cloud access to a private bucket. The role is assumed with the query's own base keys when the query supplies a complete pair; otherwise the STS AssumeRole call is signed by the server's ambient identity. Static keys from the server ``/endpoint config or from a named collection are never used as the STS base for a query-supplied role, and a `role_arn` configured in the server `` config is not applied to user queries at all. Dynamic `disk(type=s3, role_arn=...)` definitions remain covered by the restriction. Whether a credential-less request asks for environment credentials is decided by `use_environment_credentials`. Named collections default it to `0`, so a collection that only specifies a URL reads anonymously. The `s3`/`s3Cluster` table functions and `S3`/`S3Queue` engines use the built-in default (`1`) unless the server `` config sets it otherwise; set `0` to make their credential-less reads anonymous by default too (otherwise such a request is refused and must use `NOSIGN`). Disks defined in the server configuration are unaffected and keep using environment credentials by default; user-created dynamic `disk(type = s3, ...)` definitions are covered by the restriction (see above) and are rejected when they rely on default/environment credentials. This prevents an authenticated user from making the server access S3 with its own (ambient) credentials. Credentials supplied explicitly are not affected: keys passed in the query, static keys in a named collection (created via SQL or defined in config), and keys in the server `` config all keep working. The recommended way to give user queries S3 access is a named collection with explicit credentials (or `NOSIGN` for public buckets): the keys stay out of the query text, and use of each collection is controlled with RBAC (`GRANT NAMED COLLECTION ON TO `), so you grant specific users specific buckets instead of exposing the server's own identity. Scope (out of scope on purpose): this setting blocks only the server's ambient credential sources listed above. It does not block operator-provisioned static `access_key_id`/`secret_access_key` from the server `` config or from a config-defined named collection: those are treated as explicit credentials and keep working. Note, however, that config request material such as `access_header` or server-side-encryption keys is not by itself treated as a credential here: a request that carries only such material but no explicit key pair (and the default `use_environment_credentials = 1`) is still refused, because it would otherwise fall back to the server's ambient credentials. Such an endpoint must also provide explicit keys, `NOSIGN`, `use_environment_credentials = 0`, or the escape hatch below. A trusted administrative client may need server-managed credentials for legitimate operations (for example, attaching system tables on an `s3_plain_rewritable` disk via SQL). Enable this setting in that client's session or settings profile to permit it. For `BACKUP`/`RESTORE ... ON CLUSTER` the initiator's value of this setting is propagated to the other hosts and used there as-is. Those hosts run the per-host continuation of the operation through the distributed DDL queue, by default without the initiator's user, so they would otherwise evaluate the restriction against their own default profile; the initiator's value is preserved instead, because it has already opened the same backup destination under its own, constrained, settings. A `readonly` constraint on the initiator still applies (an untrusted initiator cannot enable the setting for its own on-cluster backup), so this does not weaken the restriction. Durability for persistent `S3` and `S3Queue` tables: enabling this only per session or profile is not durable across a restart. When the server reloads such a table from its stored definition (startup or `RESTORE`) it rebuilds the S3 client and re-applies the restriction with the startup context, so a table that relied on server-managed credentials and was created only under a session/profile `s3_allow_server_credentials_in_user_queries = 1` is created successfully but becomes inaccessible after a restart (the table is left in place; queries against it fail until its credentials resolve to a permitted source again). The server itself still starts. Give such tables explicit credentials for durable access; alternatively, enabling the setting server-wide keeps them loading across restarts, at the cost of relaxing the restriction for all reloads. Sessions with different values of this setting do not share a table's access. A persistent `S3`, `S3Queue`, `AzureBlobStorage` or `AzureQueue` table keeps the value it was created with (or the value of the startup context after a restart), and no session changes it: - A session where this setting is disabled cannot use an `S3` or `S3Queue` table created with it enabled, even if the table has explicit credentials or `NOSIGN`, and cannot use an Azure table that authenticates with the server's identity. To share a table with such sessions, create it in one of them. - A session where this setting is enabled does not give the server's credentials back to a table that lost them on a restart. Detach the table and attach it again in such a session instead. - An `S3` table created with this setting disabled keeps the authentication settings it was created with: later changes of the server `` configuration, such as rotated keys, reach it only when it is attached again. Azure Blob Storage is covered by this setting as well. When it is disabled, the `azureBlobStorage`/`azureBlobStorageCluster` table functions, the `AzureBlobStorage`/`AzureQueue` engines, Azure named collections, dynamic `disk(type = azure_blob_storage, ...)` definitions, `BACKUP`/`RESTORE TO AzureBlobStorage`, and DataLake table-data reads over Azure may not authenticate with the identity the server itself runs under: the AKS workload identity (a projected service-account token from `AZURE_FEDERATED_TOKEN_FILE`) or the Azure managed identity of the machine. Such a request is rejected with `ACCESS_DENIED`. Credentials supplied explicitly are unaffected: an `account_name`/`account_key` pair, a connection string, a SAS token, and static credentials in a named collection or in the server `` all keep working. Azure binds a storage bearer token to the account it was minted for and not to the host it is sent to, so a request to a URL taken from the query would both hand a usable token to whoever controls that URL and read containers the user has no rights to. For Azure, a named collection that relies on workload or managed identity is restricted too, including one defined in the server configuration, and so is `extra_credentials(client_id = '...', tenant_id = '...')`, which exchanges the server's own federated token for the named client. Disks defined in the server configuration keep using workload or managed identity. A dynamic Azure disk is restricted like a table, except for a table in the `system` database with the server setting `s3_allow_server_credentials_for_system_table_disks`; a dynamic Azure disk created while this setting is enabled records that in its stored definition, so after a restart it keeps using the server's identity. The record is written only by the server and is ignored in a `CREATE` or `ATTACH` query. The destination of `after_processing = 'move'` in `AzureQueue` must carry its own credentials, a connection string or a SAS token, even with this setting enabled, the same way an `S3Queue` move destination needs its own keys. A persistent `AzureBlobStorage` or `AzureQueue` table, or a table on a dynamic Azure disk, that relied on the server's identity is loaded at startup with a client that has no credentials, per `s3_load_table_anonymously_if_credentials_restricted`; `RESTORE` creates Azure tables like `CREATE`, so such a table is refused there instead. MongoDB is covered by this setting as well. When it is disabled, a query that reads with the `mongodb` table function or from a `MongoDB` table is rejected with `ACCESS_DENIED` if the connection string makes the server authenticate with its own credentials: with the authentication mechanism `MONGODB-OIDC` (the identity the server runs under: a Kubernetes service account token, or a token from the Azure or GCP instance metadata service), `MONGODB-AWS`, `GSSAPI` or `MONGODB-X509`, or with the connection option `tlsCertificateKeyFile` (or its deprecated alias `sslClientCertificateKeyFile`), which makes the server present a client certificate from its own filesystem. Only `SCRAM-SHA-1`, `SCRAM-SHA-256` and `PLAIN` are accepted, or no `authMechanism` at all. The check uses the settings of the session that reads, also for a table created by another user, so a session where this setting is enabled should not read MongoDB tables, or views of them, defined by untrusted users. Creating a `MongoDB` table is not checked. A MongoDB dictionary created with a DDL query may not use these mechanisms or `tlsCertificateKeyFile` whatever the value of this setting (except in `clickhouse-local`), because the server loads it with its own context, after the named collection it refers to may have changed; define such a dictionary in the server configuration files. Dictionaries defined in the server configuration files are not restricted, also when they refer to a named collection created with a DDL query, so whoever may alter that collection controls their connection string. To keep it disabled for untrusted users, pin it in their profile by both setting the value explicitly to `0` and marking it `readonly`: ```xml 0 ``` This setting has no effect in `clickhouse-local`, where the user is the operator. `DataLakeCatalog` databases (Glue, BigLake) are also covered, with one difference. A catalog object is created once and shared by every user of the database, so the value cannot be read per query; it is captured from the session that runs `CREATE DATABASE` (or a user `ATTACH DATABASE`). A database created while this setting is enabled (for example in a trusted session or profile) may use the server's ambient credentials for its catalog, and every user able to query that database then shares them; created under the default, the catalog is restricted for everyone regardless of who queries it. When the server loads an already-created database from its own metadata (startup, `RESTORE`) the restriction is re-applied with the startup context, the same as for persistent `S3`/`S3Queue` tables: a catalog that resolves server-managed credentials is left unavailable and the database becomes inaccessible after a restart (the server still starts; the database loads with an unavailable catalog per `s3_load_table_anonymously_if_credentials_restricted`, and queries report the restriction). A catalog given explicit credentials (Glue: `aws_access_key_id` and `aws_secret_access_key`; BigLake: a complete Google ADC triple) works regardless and is durable across restart. )", 0, allow_server_credentials_in_user_queries, \ {"26.11", false, false, "Also blocks Azure Blob Storage access from user SQL from authenticating with the server's own identity (the AKS workload identity or the machine's managed identity). Added the alias `allow_server_credentials_in_user_queries`. Also blocks MongoDB authentication with credentials of the server process (`MONGODB-OIDC`, `MONGODB-AWS`, `GSSAPI`, `MONGODB-X509`, `tlsCertificateKeyFile`) in the `mongodb` table function and the `MongoDB` engine."}, \ {"26.7", true, false, "New setting to block S3 access from user SQL from resolving the server's own ambient credentials (environment/IMDS/IRSA/instance-profile/AWS-config-file/GCP-OAuth-metadata). Explicit role_arn-based STS assume-role is still allowed. The previous behavior (allowed) is restored with compatibility settings."}) \ DECLARE(UInt64, max_parts_to_move, 1000, "Limit the number of parts that can be moved in one query. Zero means unlimited.", 0, \ {"24.10", 0, 1000, "New setting"}) \ \ DECLARE(UInt64, max_table_size_to_drop, default_max_size_to_drop, R"( Restriction on deleting tables in query time. The value `0` means that you can delete all tables without any restrictions. Cloud default value: 1 TB. This query setting overwrites its server setting equivalent, see [max_table_size_to_drop](/reference/settings/server-settings/settings/max-table#max_table_size_to_drop) )", 0) \ DECLARE(UInt64, max_partition_size_to_drop, default_max_size_to_drop, R"( Restriction on dropping partitions in query time. The value `0` means that you can drop partitions without any restrictions. Cloud default value: 1 TB. This query setting overwrites its server setting equivalent, see [max_partition_size_to_drop](/reference/settings/server-settings/settings/max#max_partition_size_to_drop) )", 0) \ \ DECLARE(UInt64, postgresql_connection_pool_size, 16, R"( Connection pool size for PostgreSQL table engine and database engine. )", 0) \ DECLARE(UInt64, postgresql_connection_attempt_timeout, 2, R"( Connection timeout in seconds of a single attempt to connect PostgreSQL end-point. The value is passed as a `connect_timeout` parameter of the connection URL. )", 0, \ {"24.7", 2, 2, "Allow to control 'connect_timeout' parameter of PostgreSQL connection."}) \ DECLARE(UInt64, postgresql_connection_pool_wait_timeout, 5000, R"( Connection pool push/pop timeout on empty pool for PostgreSQL table engine and database engine. By default it will block on empty pool. )", 0) \ DECLARE(UInt64, postgresql_connection_pool_retries, 2, R"( Connection pool push/pop retries number for PostgreSQL table engine and database engine. )", 0, \ {"24.7", 2, 2, "Allow to control the number of retries in PostgreSQL connection pool."}) \ DECLARE(Bool, postgresql_connection_pool_auto_close_connection, false, R"( Close connection before returning connection to the pool. )", 0) \ DECLARE(Float, postgresql_fault_injection_probability, 0.0f, R"( Approximate probability of failing internal (for replication) PostgreSQL queries. Valid value is in interval [0.0f, 1.0f] )", 0, \ {"25.2", 0., 0., "New setting"}) \ DECLARE(UInt64, glob_expansion_max_elements, 1000, R"( Maximum number of allowed addresses (For external storages, table functions, etc). The `url` table function and the `URL` table engine generate the addresses of a pattern one by one, so for them this limits how many addresses a single query is allowed to generate rather than how large the pattern is. A query that stops early, for example under a `LIMIT`, can use a pattern that describes many more addresses than this. A `_path` or `_file` predicate is applied to every generated address, so the ones it rejects are counted as well. )", 0) \ DECLARE_WITH_ALIAS(Bool, allow_url_wildcard_from_index_pages, false, R"( Allow wildcard expansion for `url()` and `ENGINE = URL` from HTTP index pages. )", EXPERIMENTAL, allow_experimental_url_wildcard_from_index_pages, \ {"26.9", false, false, "Added an alias for setting `allow_experimental_url_wildcard_from_index_pages`."}, \ {"26.7", false, false, "New setting to enable expanding wildcards in the `url` table function by listing HTTP index pages. At the time the setting was named `allow_experimental_url_wildcard_from_index_pages`, which is now an alias of it."}) \ DECLARE(UInt64, url_wildcard_max_directories_to_read, 100000, R"( Maximum number of directories that can be traversed while expanding URL wildcards from index pages. )", 0, \ {"26.7", 100000, 100000, "New setting to limit the number of directories read when expanding wildcards in the `url` table function."}) \ DECLARE(UInt64, odbc_bridge_connection_pool_size, 16, R"( Connection pool size for each connection settings string in ODBC bridge. )", 0) \ DECLARE(Bool, odbc_bridge_use_connection_pooling, true, R"( Use connection pooling in ODBC bridge. If set to false, a new connection is created every time. )", 0) \ \ DECLARE(String, obfuscate_seed, "", R"( Seed for the `obfuscate` table function. Arbitrary string — the seed for each column is derived from it and the column name, so the same seed always produces the same obfuscation. Empty string means a random seed is generated for each query. The seed is an ordinary setting, not a secret: its value is stored and shown in plain text like any other setting, for example in `system.query_log` and `system.settings`. Do not use a password or another secret as the seed. If the obfuscated outputs of different queries must not be correlatable with each other, keep the default empty value (a fresh random seed per query) instead of setting a fixed seed. )", 0, \ {"26.10", "", "", "New setting: seed string for the obfuscate table function."}) \ DECLARE(UInt64, obfuscate_markov_order, 5, R"( Maximum context-buffer size used by the legacy Markov model for the `obfuscate` table function. The model records contexts shorter than this value, preserving the semantics of the standalone `clickhouse obfuscator` tool. Must be in the range `[1, 1000]`. )", 0, \ {"26.10", 5, 5, "New setting: maximum context-buffer size for the obfuscate table function's legacy Markov model."}) \ DECLARE(UInt64, obfuscate_markov_frequency_cutoff, 5, R"( Frequency cutoff for the Markov model used by the `obfuscate` table function: buckets with count less than this value are discarded. )", 0, \ {"26.10", 5, 5, "New setting: frequency cutoff for the obfuscate table function's Markov model."}) \ DECLARE(UInt64, obfuscate_markov_num_buckets_cutoff, 0, R"( Cutoff for the number of different possible continuations for a context in the `obfuscate` table function's Markov model: histograms with fewer buckets than this are discarded. )", 0, \ {"26.10", 0, 0, "New setting: number-of-buckets cutoff for the obfuscate table function's Markov model."}) \ DECLARE(UInt64, obfuscate_markov_frequency_add, 0, R"( Constant added to every count in the `obfuscate` table function's Markov model to lower probability distribution skew. )", 0, \ {"26.10", 0, 0, "New setting: constant added to every frequency count in the obfuscate table function's Markov model."}) \ DECLARE(Float, obfuscate_markov_frequency_desaturate, 0.0, R"( Value in `[0, 1]` that moves every frequency in the `obfuscate` table function's Markov model towards the average to lower probability distribution skew. )", 0, \ {"26.10", 0.0, 0.0, "New setting: frequency desaturation factor in [0,1] for the obfuscate table function's Markov model."}) \ DECLARE(UInt64, obfuscate_markov_determinator_sliding_window_size, 8, R"( Size of the sliding window in the source string that is hashed to seed the RNG in the `obfuscate` table function's Markov model. )", 0, \ {"26.10", 8, 8, "New setting: sliding-window size used to seed the RNG in the obfuscate table function's Markov model."}) \ \ DECLARE(Seconds, distributed_replica_error_half_life, DBMS_CONNECTION_POOL_WITH_FAILOVER_DEFAULT_DECREASE_ERROR_PERIOD, R"( - Type: seconds - Default value: 60 seconds 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 the last error. See also: - [load_balancing](#load_balancing-round_robin) - [Table engine Distributed](/reference/engines/table-engines/special/distributed) - [distributed_replica_error_cap](#distributed_replica_error_cap) - [distributed_replica_max_ignored_errors](#distributed_replica_max_ignored_errors) )", 0) \ DECLARE(UInt64, distributed_replica_error_cap, DBMS_CONNECTION_POOL_WITH_FAILOVER_MAX_ERROR_COUNT, R"( - Type: unsigned int - Default value: 1000 The error count of each replica is capped at this value, preventing a single replica from accumulating too many errors. See also: - [load_balancing](#load_balancing-round_robin) - [Table engine Distributed](/reference/engines/table-engines/special/distributed) - [distributed_replica_error_half_life](#distributed_replica_error_half_life) - [distributed_replica_max_ignored_errors](#distributed_replica_max_ignored_errors) )", 0) \ DECLARE(UInt64, distributed_replica_max_ignored_errors, 0, R"( - Type: unsigned int - Default value: 0 The 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](/reference/engines/table-engines/special/distributed) - [distributed_replica_error_cap](#distributed_replica_error_cap) - [distributed_replica_error_half_life](#distributed_replica_error_half_life) )", 0) \ \ DECLARE(UInt64, min_free_disk_space_for_temporary_data, 0, R"( The minimum disk space to keep while writing temporary data used in external sorting and aggregation. )", 0) \ \ DECLARE(DefaultTableEngine, default_temporary_table_engine, DefaultTableEngine::Memory, R"( Same as [default_table_engine](#default_table_engine) but for temporary tables. In this example, any new temporary table that does not specify an `Engine` will use the `Log` table engine: Query: ```sql SET default_temporary_table_engine = 'Log'; CREATE TEMPORARY TABLE my_table ( x UInt32, y UInt32 ); SHOW CREATE TEMPORARY TABLE my_table; ``` Result: ```response ┌─statement────────────────────────────────────────────────────────────────┐ │ CREATE TEMPORARY TABLE default.my_table ( `x` UInt32, `y` UInt32 ) ENGINE = Log └──────────────────────────────────────────────────────────────────────────┘ ``` )", 0) \ DECLARE(DefaultTableEngine, default_table_engine, DefaultTableEngine::MergeTree, R"( Default table engine to use when `ENGINE` is not set in a `CREATE` statement. Possible values: - a string representing any valid table engine name Cloud default value: `SharedMergeTree`. **Example** Query: ```sql SET default_table_engine = 'Log'; SELECT name, value, changed FROM system.settings WHERE name = 'default_table_engine'; ``` Result: ```response ┌─name─────────────────┬─value─┬─changed─┐ │ default_table_engine │ Log │ 1 │ └──────────────────────┴───────┴─────────┘ ``` In this example, any new table that does not specify an `Engine` will use the `Log` table engine: Query: ```sql CREATE TABLE my_table ( x UInt32, y UInt32 ); SHOW CREATE TABLE my_table; ``` Result: ```response ┌─statement────────────────────────────────────────────────────────────────┐ │ CREATE TABLE default.my_table ( `x` UInt32, `y` UInt32 ) ENGINE = Log └──────────────────────────────────────────────────────────────────────────┘ ``` )", 0, \ {"24.3", "None", "MergeTree", "Set default table engine to MergeTree for better usability"}) \ DECLARE(Bool, show_table_uuid_in_table_create_query_if_not_nil, false, R"( Sets the `SHOW TABLE` query display. Possible values: - 0 — The query will be displayed without table UUID. - 1 — The query will be displayed with table UUID. )", 0, \ {"20.7", true, false, "Stop showing UID of the table in its CREATE query for Engine=Atomic"}) \ DECLARE(Bool, database_atomic_wait_for_drop_and_detach_synchronously, false, R"( Adds a modifier `SYNC` to all `DROP` and `DETACH` queries. Possible values: - 0 — Queries will be executed with delay. - 1 — Queries will be executed without delay. )", 0) \ DECLARE(Bool, enable_scalar_subquery_optimization, true, R"( If it is set to true, prevent scalar subqueries from (de)serializing large scalar values and possibly avoid running the same subquery more than once. )", 0, \ {"19.18", false, true, "Prevent scalar subqueries from (de)serializing large scalar values and possibly avoid running the same subquery more than once"}) \ DECLARE(Bool, optimize_trivial_count_query, true, R"( Enables or disables the optimization to trivial query `SELECT count() FROM table` using metadata from MergeTree. If you need to use row-level security, disable this setting. Possible values: - 0 — Optimization disabled. - 1 — Optimization enabled. See also: - [optimize_functions_to_subcolumns](#optimize_functions_to_subcolumns) )", 0) \ DECLARE(Bool, optimize_trivial_approximate_count_query, false, R"( Use an approximate value for trivial count optimization of storages that support such estimation, for example, EmbeddedRocksDB. Possible values: - 0 — Optimization disabled. - 1 — Optimization enabled. )", 0) \ DECLARE(Bool, optimize_trivial_group_by_limit_query, true, R"( Enables or disables the optimization of a trivial query `SELECT ... FROM table GROUP BY key_expr LIMIT n` (with no `HAVING`/`ORDER BY`/`QUALIFY`/`LIMIT BY`/`DISTINCT`/window clauses and no `GROUP BY` modifiers) by capping the aggregation at `n + offset` distinct keys. With no aggregate functions in the projection, the cap is applied by setting `max_rows_to_group_by = n + offset` with `group_by_overflow_mode = 'any'` (this form also applies on the shards of distributed queries). With aggregate functions in the projection, the cap is applied only when the server performs the complete aggregation locally: once any aggregation thread exceeds the cap, all threads are restricted to a single shared set of `n + offset` kept keys, so the aggregate values of the returned keys stay exact. The optimization is suppressed when the user has explicitly set `group_by_overflow_mode` to a non-`any` value (to preserve their explicit `throw`/`break` contract), when the user has already set a tighter `max_rows_to_group_by`, and with [exact_rows_before_limit](#exact_rows_before_limit) (the cap would make `rows_before_limit_at_least` report at most `n + offset`). The aggregate-function form excludes the `GROUP BY` top-K heap of [enable_group_by_top_k_optimization](#enable_group_by_top_k_optimization) on the same query. The heap is faster, so the cutoff is applied only when the heap does not apply: when it is disabled, when `n + offset` exceeds [query_plan_max_limit_for_top_k_optimization](#query_plan_max_limit_for_top_k_optimization), when `max_rows_to_group_by` is set, or when the query plan is serialized. Possible values: - 0 — Optimization disabled. - 1 — Optimization enabled. )", 0, \ {"26.5", false, true, "New setting that limits aggregation to at most LIMIT distinct keys for `SELECT key_expr FROM t GROUP BY key_expr LIMIT n` queries."}) \ DECLARE(Bool, optimize_trivial_count_with_sparsity_filter, true, R"( Extends the [optimize_trivial_count_query](#optimize_trivial_count_query) optimization to queries of the form `SELECT count() FROM t WHERE col const`, where ` const` exactly partitions rows into defaults and non-defaults of `col`. The count is then served from the per-column `num_defaults` / `num_rows` counters that MergeTree already keeps in `serialization.json`, with no data scan. Patterns recognised: - `col = default(col)` / `col != default(col)` for `Int*` / `UInt*`, `String` / `FixedString`, `Date` / `DateTime` / `DateTime64`, `Decimal*`, `UUID`, `IPv4` / `IPv6`. - `IS NULL` / `IS NOT NULL` on `Nullable` columns. - `empty(col)` / `notEmpty(col)` on `String` columns. - `col = true` / `col != true` on `Bool` columns. - `col > 0`, `col >= 1`, `col < 1`, `col <= 0` on unsigned integer columns. - Bare `col` / `NOT col` on `Int*`, `UInt*`, `Bool` columns (truthy test). The equality patterns are not applied to `Float*`, `Enum*`, `Date32`, `Nullable`, `LowCardinality`, or composite types (`Tuple`, `Array`, `Map`, ...) — for these the count is served from the regular scan path. To take effect, the per-part `num_defaults` counter must be exact. Enable the MergeTree table setting `compute_exact_num_defaults_for_sparse_columns` on the target table before inserts and merges. Parts written without it are silently opted out of the rewrite, so enabling `optimize_trivial_count_with_sparsity_filter` alone is not enough. For the `IS NULL` / `IS NOT NULL` patterns on `Nullable` columns, the column must also have a `num_defaults` entry in `serialization.json`, which only happens when the MergeTree table setting `nullable_serialization_version` is set to `allow_sparse` at insert / merge time. With the default value `basic` `Nullable` columns get no per-column entry, so the optimization silently does not apply. Possible values: - 0 — Optimization disabled. - 1 — Optimization enabled. See also: - [optimize_trivial_count_query](#optimize_trivial_count_query) )", BETA, \ {"26.8", false, true, "Promote to BETA and enable by default: serve `SELECT count() FROM t WHERE ` from the persisted per-column `num_defaults` / `num_rows` counters when `` partitions rows into defaults vs non-defaults. Requires the MergeTree setting `compute_exact_num_defaults_for_sparse_columns` (also enabled by default now)."}, \ {"26.7", false, false, "New (experimental) setting to serve `SELECT count() FROM t WHERE ` from per-column `num_defaults` / `num_rows` recorded in `serialization.json` when `` partitions rows into defaults vs non-defaults."}) \ DECLARE(Bool, optimize_count_from_files, true, R"( Enables or disables the optimization of counting number of rows from files in different input formats. It applies to table functions/engines `file`/`s3`/`url`/`hdfs`/`azureBlobStorage`. Possible values: - 0 — Optimization disabled. - 1 — Optimization enabled. )", 0) \ DECLARE(Bool, optimize_min_max_from_files, true, R"( Enables or disables computing `min` and `max` of columns from the statistics stored in data files instead of reading the data, for queries whose only aggregate functions are `min` and `max` of table columns, without `GROUP BY` and without filters. It applies to the table function/engine `file` with the `Parquet` format (not to files inside archives), for integer (up to 64 bits), date, date-time and decimal columns whose column chunk statistics are present in every row group. Possible values: - 0 - Optimization disabled. - 1 - Optimization enabled. )", 0, \ {"26.10", false, true, "New setting to compute `min` / `max` from Parquet column chunk statistics."}) \ DECLARE(Bool, use_cache_for_count_from_files, true, R"( Enables caching of rows number during count from files in table functions `file`/`s3`/`url`/`hdfs`/`azureBlobStorage`. Enabled by default. )", 0) \ DECLARE(Bool, optimize_respect_aliases, true, R"( If it is set to true, it will respect aliases in WHERE/GROUP BY/ORDER BY, that will help with partition pruning/secondary indexes/optimize_aggregation_in_order/optimize_read_in_order/optimize_trivial_count )", 0) \ DECLARE(UInt64, mutations_sync, 0, R"( Controls how the client waits for mutations created by [`ALTER TABLE`](/reference/statements/alter/index) operations such as `UPDATE`, `DELETE`, `MATERIALIZE INDEX`, `MATERIALIZE PROJECTION`, `MATERIALIZE COLUMN`, and `MATERIALIZE STATISTICS`. Possible values: | Value | Description | |-------|-------------------------------------------------------------------------------------------------------------------------------------------------------| | `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). | | `3` | The query waits only for the active replicas. Inactive replicas apply the mutations when they become active. | )", 0) \ DECLARE_WITH_ALIAS(Bool, enable_lightweight_delete, true, R"( Enable lightweight DELETE mutations for mergetree tables. )", 0, allow_experimental_lightweight_delete) \ DECLARE(LightweightDeleteMode, lightweight_delete_mode, LightweightDeleteMode::ALTER_UPDATE, R"( A mode of internal update query that is executed as a part of lightweight delete. Possible values: - `alter_update` - run `ALTER UPDATE` query that creates a heavyweight mutation. - `lightweight_update` - run lightweight update if possible, run `ALTER UPDATE` otherwise. - `lightweight_update_force` - run lightweight update if possible, throw otherwise. For `DELETE FROM ... ON CLUSTER`, each executing host derives the mode from its own settings, so hosts whose profiles set different defaults can run the delete in different modes. A replicated shard executes on one replica, so there it is that replica's settings that decide. Setting it in the session of the initiating query overrides this, because the distributed DDL entry carries session changes. A host that constrains the setting clamps the value back. )", 0, \ {"25.5", "alter_update", "alter_update", "A new setting"}) \ DECLARE(UInt64, lightweight_deletes_sync, 2, R"( The same as [`mutations_sync`](#mutations_sync), but controls only execution of lightweight deletes. Possible values: | Value | Description | |-------|-------------------------------------------------------------------------------------------------------------------------------------------------------| | `0` | Mutations execute asynchronously. | | `1` | The query waits for the lightweight deletes to complete on the current server. | | `2` | The query waits for the lightweight deletes to complete on all replicas (if they exist). | | `3` | The query waits only for the active replicas. Inactive replicas apply the lightweight deletes when they become active. | **See Also** - [Synchronicity of ALTER Queries](/reference/statements/alter/index#synchronicity-of-alter-queries) - [Mutations](/reference/statements/alter/index#mutations) Cloud default value: `1`. )", 0, \ {"24.4", 2, 2, "The same as 'mutation_sync', but controls only execution of lightweight deletes"}) \ DECLARE(Bool, apply_deleted_mask, true, R"( Enables filtering out rows deleted with lightweight DELETE. If disabled, a query will be able to read those rows. This is useful for debugging and \"undelete\" scenarios )", 0) \ DECLARE(Bool, optimize_normalize_count_variants, true, R"( Rewrite aggregate functions that semantically equals to count() as count(). )", 0, \ {"21.3", false, true, "Rewrite aggregate functions that semantically equals to count() as count() by default"}) \ DECLARE(Bool, optimize_injective_functions_inside_uniq, true, R"( Delete injective functions of one argument inside uniq*() functions. )", 0) \ DECLARE(Bool, count_matches_stop_at_empty_match, false, R"( Stop counting once a pattern matches zero-length in the `countMatches` function. )", 0, \ {"25.6", true, false, "New setting."}) \ DECLARE(Bool, rewrite_count_distinct_if_with_count_distinct_implementation, false, R"( Allows you to rewrite `countDistcintIf` with [count_distinct_implementation](#count_distinct_implementation) setting. Possible values: - true — Allow. - false — Disallow. )", 0, \ {"23.8", false, false, "New setting to rewrite countDistinctIf with count_distinct_implementation configuration. It is disabled by default"}) \ DECLARE(Bool, convert_query_to_cnf, false, R"( When set to `true`, a `SELECT` query will be converted to conjunctive normal form (CNF). There are scenarios where rewriting a query in CNF may execute faster (view this [Github issue](https://github.com/ClickHouse/ClickHouse/issues/11749) for an explanation). For example, notice how the following `SELECT` query is not modified (the default behavior): ```sql EXPLAIN SYNTAX SELECT * FROM ( SELECT number AS x FROM numbers(20) ) AS a WHERE ((x >= 1) AND (x <= 5)) OR ((x >= 10) AND (x <= 15)) SETTINGS convert_query_to_cnf = false; ``` The result is: ```response ┌─explain────────────────────────────────────────────────────────┐ │ SELECT x │ │ FROM │ │ ( │ │ SELECT number AS x │ │ FROM numbers(20) │ │ WHERE ((x >= 1) AND (x <= 5)) OR ((x >= 10) AND (x <= 15)) │ │ ) AS a │ │ WHERE ((x >= 1) AND (x <= 5)) OR ((x >= 10) AND (x <= 15)) │ │ SETTINGS convert_query_to_cnf = 0 │ └────────────────────────────────────────────────────────────────┘ ``` Let's set `convert_query_to_cnf` to `true` and see what changes: ```sql EXPLAIN SYNTAX SELECT * FROM ( SELECT number AS x FROM numbers(20) ) AS a WHERE ((x >= 1) AND (x <= 5)) OR ((x >= 10) AND (x <= 15)) SETTINGS convert_query_to_cnf = true; ``` Notice the `WHERE` clause is rewritten in CNF, but the result set is the identical - the Boolean logic is unchanged: ```response ┌─explain───────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ SELECT x │ │ FROM │ │ ( │ │ SELECT number AS x │ │ FROM numbers(20) │ │ WHERE ((x <= 15) OR (x <= 5)) AND ((x <= 15) OR (x >= 1)) AND ((x >= 10) OR (x <= 5)) AND ((x >= 10) OR (x >= 1)) │ │ ) AS a │ │ WHERE ((x >= 10) OR (x >= 1)) AND ((x >= 10) OR (x <= 5)) AND ((x <= 15) OR (x >= 1)) AND ((x <= 15) OR (x <= 5)) │ │ SETTINGS convert_query_to_cnf = 1 │ └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` Possible values: true, false )", 0) \ DECLARE(Bool, optimize_or_like_chain, true, R"( Optimize multiple `OR LIKE/ILIKE/match` predicates on the same expression into a single `multiSearchAny`/`multiSearchAnyCaseInsensitiveUTF8` (for pure-substring `%needle%` patterns) or `multiMatchAny` (for other patterns, when Hyperscan/Vectorscan is permitted). When neither fast path is applicable — for example when Hyperscan is disabled or unavailable, or the patterns are raw `match` regexps, not valid UTF-8, contain an embedded NUL, are end-anchored (do not end in an unescaped `%`; Vectorscan matches `$` before a final newline, so the rewrite would widen the filter), or the haystack is `FixedString`/`Enum` — the original `OR` chain is kept unchanged, because a combined `match` alternation over RE2 is consistently slower than the original short-circuit `OR`. For pure `LIKE`/`ILIKE`/`match` `OR` chains the original expressions are preserved in `indexHint()` to allow index analysis; mixed `OR` chains that include non-`LIKE` branches intentionally skip `indexHint()` wrapping so that ranges matching only the non-`LIKE` branch are not pruned. The `multiMatchAny` rewrite honors `allow_hyperscan`, `max_hyperscan_regexp_length`, `max_hyperscan_regexp_total_length` and `reject_expensive_hyperscan_regexps`. A chain is rewritten only when it has enough branches sharing the same left-hand-side expression to make the rewrite reliably faster than short-circuit `OR` evaluation: at least `optimize_or_like_chain_min_substrings` branches for the `multiSearchAny` path, and at least `optimize_or_like_chain_min_patterns` branches for the `multiMatchAny` path. )", 0, \ {"26.7", false, true, "Enable by default: optimize OR chains of LIKE/ILIKE/match into multiSearchAny (pure-substring patterns) or multiMatchAny (other patterns, when Hyperscan/Vectorscan is permitted); when neither fast path applies the original OR chain is kept unchanged."}) \ DECLARE(UInt64, optimize_or_like_chain_min_patterns, 10, R"( Minimum number of non-pure-substring `LIKE`/`ILIKE`/`match` branches (prefix/suffix/regexp patterns), sharing the same left-hand-side expression, required for `optimize_or_like_chain` to rewrite a chain into `multiMatchAny`. Calibrated on the `hits` dataset (see `tests/performance/optimize_or_like_chain_hits.xml`): a `multiMatchAny` (Hyperscan) rewrite of prefix/regexp `LIKE` chains only becomes faster than short-circuit `OR` evaluation from about nine branches, so shorter chains are kept as-is to avoid regressing them. A value of 0 or 1 disables the threshold. Has no effect when `optimize_or_like_chain` is disabled. See also `optimize_or_like_chain_min_substrings` for the pure-substring (`multiSearchAny`) path. )", 0, \ {"26.7", 0, 10, "New setting controlling the minimum number of non-pure-substring LIKE/ILIKE/match branches (sharing the same LHS expression) required for optimize_or_like_chain to rewrite a chain into multiMatchAny. Shorter chains are kept as-is because the multiMatchAny (Hyperscan) rewrite only becomes faster than short-circuit OR evaluation from about nine branches."}) \ DECLARE(UInt64, optimize_or_like_chain_min_substrings, 4, R"( Minimum number of pure-substring (`%needle%`) `LIKE`/`ILIKE` branches, sharing the same left-hand-side expression, required for `optimize_or_like_chain` to rewrite a chain into `multiSearchAny`/`multiSearchAnyCaseInsensitiveUTF8`. Calibrated on the `hits` dataset (see `tests/performance/optimize_or_like_chain_hits.xml`): the `multiSearchAny` rewrite becomes faster than short-circuit `OR` evaluation from about four branches. A value of 0 or 1 disables the threshold. Has no effect when `optimize_or_like_chain` is disabled. See also `optimize_or_like_chain_min_patterns` for the regexp (`multiMatchAny`) path. )", 0, \ {"26.7", 0, 4, "New setting controlling the minimum number of pure-substring (%needle%) LIKE/ILIKE branches (sharing the same LHS expression) required for optimize_or_like_chain to rewrite a chain into multiSearchAny."}) \ DECLARE(Bool, optimize_arithmetic_operations_in_aggregate_functions, true, R"( Move arithmetic operations out of aggregation functions )", 0) \ DECLARE(Bool, optimize_redundant_functions_in_order_by, true, R"( Remove functions from ORDER BY if its argument is also in ORDER BY )", 0) \ DECLARE(Bool, optimize_truncate_order_by_after_group_by_keys, true, R"( Remove trailing ORDER BY elements once all GROUP BY keys are covered in the ORDER BY prefix. )", 0, \ {"26.4", false, true, "Remove trailing ORDER BY elements once all GROUP BY keys are covered in the ORDER BY prefix."}) \ DECLARE(Bool, optimize_if_chain_to_multiif, false, R"( Replace if(cond1, then1, if(cond2, ...)) chains to multiIf. Currently it's not beneficial for numeric types. )", 0) \ DECLARE(Bool, optimize_multiif_to_if, true, R"( Replace 'multiIf' with only one condition to 'if'. )", 0) \ DECLARE(Bool, optimize_if_transform_const_strings_to_lowcardinality, false, R"( If enabled, the `if`, `multiIf`, and `transform` functions with constant string result branches (and defaults) will return `LowCardinality(String)` instead of `String`. Disabled by default because constructing a `LowCardinality` dictionary per block can be slower than a plain `String` result when the dictionary is not reused downstream. The optimization is not applied when the whole expression is constant (constant condition or input as well): a constant gains nothing from `LowCardinality`, and functions expecting constant `String` arguments (e.g. `arrayReduce`, `joinGet`, `tupleElement`) keep working. All the result branches have to be constants, so a nested `if` chain such as `if(cond1, 'a', if(cond2, 'b', 'c'))` keeps plain `String`: the else-branch of the outer `if` is another `if`, not a constant. Write it as `multiIf(cond1, 'a', cond2, 'b', 'c')` to get `LowCardinality(String)`. This setting has no effect while `optimize_if_transform_strings_to_enum` is enabled: the `Enum` rewrite takes precedence, and the result stays `String` (or `Nullable(String)`) even for the explicit `multiIf` form above. )", 0, \ {"26.11", false, false, "New setting to allow optimizing results of const branches from `if`/`multiIf`/`transform` into `LowCardinality`. Disabled by default."}) \ DECLARE(Bool, optimize_if_transform_strings_to_enum, false, R"( Replaces string-type arguments in If and Transform to enum. Disabled by default cause it could make inconsistent change in distributed query that would lead to its fail. )", 0) \ DECLARE(Bool, optimize_functions_to_subcolumns, true, R"( Enables or disables optimization by transforming some functions to reading subcolumns. This reduces the amount of data to read. These functions can be transformed: - [length](/reference/functions/regular-functions/array-functions#length) to read the [size0](/reference/data-types/array#array-size) subcolumn. - [empty](/reference/functions/regular-functions/array-functions#empty) to read the [size0](/reference/data-types/array#array-size) subcolumn. - [notEmpty](/reference/functions/regular-functions/array-functions#notEmpty) to read the [size0](/reference/data-types/array#array-size) subcolumn. - [isNull](/reference/functions/regular-functions/functions-for-nulls#isNull) to read the [null](/reference/data-types/nullable#finding-null) subcolumn. - [isNotNull](/reference/functions/regular-functions/functions-for-nulls#isNotNull) to read the [null](/reference/data-types/nullable#finding-null) subcolumn. - [count](/reference/functions/aggregate-functions/count) to read the [null](/reference/data-types/nullable#finding-null) subcolumn. - [mapKeys](/reference/functions/regular-functions/tuple-map-functions#mapKeys) to read the [keys](/reference/data-types/map#reading-subcolumns-of-map) subcolumn. - [mapValues](/reference/functions/regular-functions/tuple-map-functions#mapValues) to read the [values](/reference/data-types/map#reading-subcolumns-of-map) subcolumn. - [has](/reference/functions/regular-functions/array-functions#has) and [notHas](/reference/functions/regular-functions/array-functions#notHas) for `Map` to read the [keys](/reference/data-types/map#reading-subcolumns-of-map) subcolumn. - [mapContainsKeyLike](/reference/functions/regular-functions/tuple-map-functions#mapContainsKeyLike) to read the [keys](/reference/data-types/map#reading-subcolumns-of-map) subcolumn. - [mapContainsValueLike](/reference/functions/regular-functions/tuple-map-functions#mapContainsValueLike) to read the [values](/reference/data-types/map#reading-subcolumns-of-map) subcolumn. Possible values: - 0 — Optimization disabled. - 1 — Optimization enabled. )", 0, \ {"24.8", false, true, "Enabled settings by default"}) \ DECLARE(Bool, optimize_using_constraints, false, R"( Use [constraints](/reference/statements/create/table#constraints) for query optimization. The default is `false`. Possible values: - true, false )", 0) \ DECLARE(Bool, optimize_substitute_columns, false, R"( Use [constraints](/reference/statements/create/table#constraints) for column substitution. The default is `false`. Possible values: - true, false )", 0) \ DECLARE(Bool, optimize_append_index, false, R"( Use [constraints](/reference/statements/create/table#constraints) in order to append index condition. The default is `false`. Possible values: - true, false )", 0) \ DECLARE(Bool, optimize_time_filter_with_preimage, true, R"( Optimize Date and DateTime predicates by converting functions into equivalent comparisons without conversions (e.g. `toYear(col) = 2023 -> col >= '2023-01-01' AND col <= '2023-12-31'`) )", 0, \ {"24.2", true, true, "Optimize Date and DateTime predicates by converting functions into equivalent comparisons without conversions (e.g. toYear(col) = 2023 -> col >= '2023-01-01' AND col <= '2023-12-31')"}) \ DECLARE(Bool, normalize_function_names, true, R"( Normalize function names to their canonical names )", 0, \ {"21.3", false, true, "Normalize function names to their canonical names, this was needed for projection query routing"}) \ DECLARE(Bool, enable_early_constant_folding, true, R"( Enable query optimization where we analyze function and subqueries results and rewrite query if there are constants there )", 0) \ DECLARE(Bool, deduplicate_blocks_in_dependent_materialized_views, true, R"( Enables or disables the deduplication check for materialized views that receive data from Replicated\* tables. Possible values: - 0 — Disabled. - 1 — Enabled. When enabled, ClickHouse performs deduplication of blocks in materialized views that depend on Replicated\* tables. This setting is useful for ensuring that materialized views do not contain duplicate data when the insertion operation is being retried due to a failure. **See Also** - [NULL Processing in IN Operators](/concepts/features/operations/insert/deduplicating-inserts-on-retries#insert-deduplication-with-materialized-views) )", 0, \ {"26.2", false, true, "Enable deduplication for dependent materialized views by default."}) \ DECLARE(Bool, wait_for_part_commit_in_dependent_materialized_views, false, R"( Controls whether each sink commits its just-written part before its own dependent materialized view cascade runs, so a cascade that reads back from the source via `JOIN` observes the part written by that sink. The guarantee is per sink instance — parts written by other sink threads of the same `INSERT` may not yet be visible. The setting does not provide cross-thread commit ordering. Has no effect on inserts into tables with no dependent materialized views. )", 0, \ {"26.6", false, false, "New setting"}) \ DECLARE(Bool, materialized_views_ignore_errors, false, R"( If enabled, exceptions thrown while pushing data to a dependent materialized view (in its `SELECT` or in the inner table sink) are logged as a warning and the `INSERT` statement succeeds. If disabled (default), such an exception propagates and the `INSERT` statement fails. This setting controls only error reporting. It does not roll back a write to the source table, and it does not guarantee whether the original block has already been committed to the source table when an error occurs in a dependent view's pipeline. When disabled (default), the `INSERT` fails on a view error — retry it with insert deduplication (`insert_deduplicate`, `deduplicate_blocks_in_dependent_materialized_views`) for exactly-once delivery to the source table and all dependent views. When enabled, the `INSERT` reports success despite partial delivery to failing views and their downstream chains; use this only when source-table writes must not be blocked by view-side problems (for example, `system.*_log` tables). See the `CREATE VIEW` docs for full semantics. )", 0) \ DECLARE(Bool, ignore_materialized_views_with_dropped_target_table, false, R"( Ignore MVs with dropped target table during pushing to views )", 0, \ {"24.1", false, false, "Add new setting to allow to ignore materialized views with dropped target table"}) \ DECLARE(Bool, allow_materialized_view_with_bad_select, false, R"( Allow CREATE MATERIALIZED VIEW with SELECT query that references nonexistent tables or columns. It must still be syntactically valid. Doesn't apply to refreshable MVs. Doesn't apply if the MV schema needs to be inferred from the SELECT query (i.e. if the CREATE has no column list and no TO table). Can be used for creating MV before its source table. )", 0, \ {"25.4", true, false, "Don't allow creating MVs referencing nonexistent columns or tables"}, \ {"24.9", true, true, "Support (but not enable yet) stricter validation in CREATE MATERIALIZED VIEW"}) \ DECLARE(Bool, materialized_views_squash_parallel_inserts, true, R"(Squash inserts to materialized views destination table of a single INSERT query from parallel inserts to reduce amount of generated parts. If set to false and `parallel_view_processing` is enabled, INSERT query will generate part in the destination table for each `max_insert_thread`. )", 0, \ {"25.10", false, true, "Added setting to preserve old behavior if needed."}) \ DECLARE(Bool, materialized_views_populate_atomically, true, R"( Make `CREATE MATERIALIZED VIEW ... POPULATE` atomic: the view is subscribed to new inserts of the source table and a snapshot of the existing data is taken together, under a brief exclusive lock on the source table, so that every row inserted concurrently with the population is delivered to the view exactly once (neither missed nor duplicated). The (possibly long-running) population then reads the pinned snapshot without holding any lock. This is local insert-path atomicity: the exclusive lock only serializes with inserts that acquire this source table's storage lock on the same server, so the exactly-once guarantee covers inserts arriving through this server. It is not a cluster-wide guarantee - rows inserted on another replica of a `ReplicatedMergeTree` source, or through a distributed write path (for example, into a `Distributed` table or via `ON CLUSTER`), concurrently with the population can still be missed or duplicated. This requires the source table to support reading a pinned point-in-time snapshot (the `MergeTree` family and `Memory`). For any other source (a view, `Distributed`, `Merge`, the `Log` family, or a table not in an `Atomic` database) the population falls back to the legacy, non-atomic behavior (recorded in the server log): existing data is read with a separate, non-coordinated snapshot, so rows inserted during the population can be missed or duplicated. Set this setting to `false` to force the legacy behavior for all sources. Applies to plain `CREATE MATERIALIZED VIEW` only; `CREATE OR REPLACE` / `REPLACE` always use the legacy non-atomic population, and so does a view created in a `Replicated` database (where `POPULATE` requires `database_replicated_allow_heavy_create`), because a failed population could not be rolled back consistently on all replicas there. )", 0, \ {"26.8", false, true, "New setting that makes plain `CREATE MATERIALIZED VIEW ... POPULATE` locally atomic: existing data is snapshotted and the view is subscribed to new inserts together, under a brief exclusive lock on the source, so rows inserted through the same server are neither missed nor duplicated. The guarantee covers the local insert path only - inserts arriving on another replica or through a distributed write are outside the cut - and it requires a source that can provide a pinned snapshot (the `MergeTree` family and `Memory`); other sources, as well as `CREATE OR REPLACE` / `REPLACE`, keep the legacy non-atomic population. Set to `false` for the legacy non-atomic behavior everywhere."}) \ DECLARE(Bool, validate_polygons, true, R"( Enables or disables throwing an exception in the [pointInPolygon](/reference/functions/regular-functions/geo/coordinates#pointinpolygon) function, if the polygon is self-intersecting or self-tangent. 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. )", 0, \ {"20.4", false, true, "Throw exception if polygon is invalid in function pointInPolygon by default instead of returning possibly wrong results"}) \ DECLARE(UInt64, max_parser_depth, DBMS_DEFAULT_MAX_PARSER_DEPTH, R"( Limits maximum recursion depth in the recursive descent parser. Allows controlling the stack size. Possible values: - Positive integer. - 0 — Recursion depth is unlimited. )", 0) \ DECLARE(UInt64, max_parser_backtracks, DBMS_DEFAULT_MAX_PARSER_BACKTRACKS, R"( Maximum parser backtracking (how many times it tries different alternatives in the recursive descend parsing process). )", 0, \ {"24.3", 0, 1000000, "Limiting the complexity of parsing"}) \ DECLARE(UInt64, max_recursive_cte_evaluation_depth, DBMS_RECURSIVE_CTE_MAX_EVALUATION_DEPTH, R"( Maximum limit on recursive CTE evaluation depth )", 0, \ {"24.4", DBMS_RECURSIVE_CTE_MAX_EVALUATION_DEPTH, DBMS_RECURSIVE_CTE_MAX_EVALUATION_DEPTH, "Maximum limit on recursive CTE evaluation depth"}) \ DECLARE(UInt64, recursive_cte_max_steps_in_type_inference, 10, R"( Maximum number of iterations for inferring column types in recursive CTEs. Column types are determined by iteratively applying `getLeastSupertype` across the non-recursive and recursive sides of the UNION ALL until convergence. Set to 0 to disable type widening and use the types from the non-recursive part only. )", 0, \ {"26.5", 0, 10, "Maximum iterations for inferring column types in recursive CTEs via iterative getLeastSupertype"}) \ DECLARE(Bool, allow_settings_after_format_in_insert, false, R"( Control whether `SETTINGS` after `FORMAT` in `INSERT` queries is allowed or not. It is not recommended to use this, since this may interpret part of `SETTINGS` as values. Example: ```sql INSERT INTO FUNCTION null('foo String') SETTINGS max_threads=1 VALUES ('bar'); ``` But the following query will work only with `allow_settings_after_format_in_insert`: ```sql SET allow_settings_after_format_in_insert=1; INSERT INTO FUNCTION null('foo String') VALUES ('bar') SETTINGS max_threads=1; ``` Possible values: - 0 — Disallow. - 1 — Allow. Use this setting only for backward compatibility if your use cases depend on old syntax. )", 0, \ {"22.4", true, false, "Do not allow SETTINGS after FORMAT for INSERT queries because ClickHouse interpret SETTINGS as some values, which is misleading"}) \ DECLARE(Bool, transform_null_in, false, R"( Enables equality of [NULL](/reference/syntax#null) values for [IN](/reference/statements/in) operator. 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. Possible values: - 0 — Comparison of `NULL` values in `IN` operator returns `false`. - 1 — Comparison of `NULL` values in `IN` operator returns `true`. **Example** Consider the `null_in` table: ```text ┌──idx─┬─────i─┐ │ 1 │ 1 │ │ 2 │ NULL │ │ 3 │ 3 │ └──────┴───────┘ ``` Query: ```sql SELECT idx, i FROM null_in WHERE i IN (1, NULL) SETTINGS transform_null_in = 0; ``` Result: ```text ┌──idx─┬────i─┐ │ 1 │ 1 │ └──────┴──────┘ ``` Query: ```sql SELECT idx, i FROM null_in WHERE i IN (1, NULL) SETTINGS transform_null_in = 1; ``` Result: ```text ┌──idx─┬─────i─┐ │ 1 │ 1 │ │ 2 │ NULL │ └──────┴───────┘ ``` **See Also** - [NULL Processing in IN Operators](/reference/statements/in#null-processing) )", 0) \ DECLARE(Bool, allow_nondeterministic_mutations, false, R"( User-level setting that allows mutations on replicated tables to make use of non-deterministic functions such as `dictGet`, and of the virtual columns whose values may differ between replicas, such as `_table`, `_database` and `_disk_name`. Given that, for example, dictionaries, can be out of sync across nodes, mutations that pull values from them are disallowed on replicated tables by default. Enabling this setting allows this behavior, making it the user's responsibility to ensure that the data used is in sync across all nodes. **Example** ```xml 1 ``` )", 0) \ DECLARE(Seconds, lock_acquire_timeout, DBMS_DEFAULT_LOCK_ACQUIRE_TIMEOUT_SEC, R"( Defines how many seconds a locking request waits before failing. Locking timeout is used to protect from deadlocks while executing read/write operations with tables. When the timeout expires and the locking request fails, the ClickHouse server throws an exception "Locking attempt timed out. Possible deadlock avoided. Client should retry." with error code `DEADLOCK_AVOIDED`. Possible values: - Positive integer (in seconds). - 0 — No locking timeout. )", 0) \ DECLARE(Milliseconds, get_zookeeper_lock_acquire_timeout_ms, DBMS_DEFAULT_LOCK_ACQUIRE_TIMEOUT_SEC * 1000, R"( Defines how many milliseconds a query waits for a Keeper client: for the `Context` mutex of the client, and for a connection attempt that another thread is making for it. When the time is exceeded, the query fails with `TIMEOUT_EXCEEDED`. The query also stops waiting when it is cancelled. The value is taken from the query context, so it applies to operations that use it, such as reads from `system.zookeeper`, `zookeeperSessionUptime`, `SYSTEM RECONNECT ZOOKEEPER`, and query-context auxiliary Keeper access. Operations that use a global or background context, including `BACKUP` and `RESTORE` coordination and `Replicated` database activity, wait until the connection attempt ends and get its client or its Keeper error. `SYSTEM RELOAD CONFIG` and `SYSTEM RELOAD ASYNCHRONOUS METRICS` are not covered because they use independently serialized reload paths. Possible values: - Positive integer (in milliseconds). - 0 — No locking timeout. )", 0, \ {"26.10", 0, DBMS_DEFAULT_LOCK_ACQUIRE_TIMEOUT_SEC * 1000, "New setting"}) \ DECLARE(Bool, materialize_ttl_after_modify, true, R"( Apply TTL for old data, after ALTER MODIFY TTL query )", 0) \ DECLARE(Bool, data_type_default_nullable, false, R"( Allows data types without explicit modifiers [NULL or NOT NULL](/reference/statements/create/table#null-or-not-null-modifiers) in column definition will be [Nullable](/reference/data-types/nullable). It applies to `CREATE TABLE`, `ALTER TABLE ... ADD COLUMN` and `ALTER TABLE ... MODIFY COLUMN`. Possible values: - 1 — The data types in column definitions are set to `Nullable` by default. - 0 — The data types in column definitions are set to not `Nullable` by default. )", 0) \ DECLARE(Bool, cast_keep_nullable, false, R"( Enables or disables keeping of the `Nullable` data type in [CAST](/reference/functions/regular-functions/type-conversion-functions#CAST) operations. When the setting is enabled and the argument of `CAST` function is `Nullable`, the result is also transformed to `Nullable` type. When the setting is disabled, the result always has the destination type exactly. Possible values: - 0 — The `CAST` result has exactly the destination type specified. - 1 — If the argument type is `Nullable`, the `CAST` result is transformed to `Nullable(DestinationDataType)`. **Examples** The following query results in the destination data type exactly: ```sql SET cast_keep_nullable = 0; SELECT CAST(toNullable(toInt32(0)) AS Int32) as x, toTypeName(x); ``` Result: ```text ┌─x─┬─toTypeName(CAST(toNullable(toInt32(0)), 'Int32'))─┐ │ 0 │ Int32 │ └───┴───────────────────────────────────────────────────┘ ``` The following query results in the `Nullable` modification on the destination data type: ```sql SET cast_keep_nullable = 1; SELECT CAST(toNullable(toInt32(0)) AS Int32) as x, toTypeName(x); ``` Result: ```text ┌─x─┬─toTypeName(CAST(toNullable(toInt32(0)), 'Int32'))─┐ │ 0 │ Nullable(Int32) │ └───┴───────────────────────────────────────────────────┘ ``` **See Also** - [CAST](/reference/functions/regular-functions/type-conversion-functions#CAST) function )", 0) \ DECLARE(Bool, cast_ipv4_ipv6_default_on_conversion_error, false, R"( CAST operator into IPv4, CAST operator into IPV6 type, toIPv4, toIPv6 functions will return default value instead of throwing exception on conversion error. )", 0, \ {"22.3", true, false, "Make functions cast(value, 'IPv4') and cast(value, 'IPv6') behave same as toIPv4 and toIPv6 functions"}) \ DECLARE(Bool, alter_partition_verbose_result, false, R"( Enables or disables the display of information about the parts to which the manipulation operations with partitions and parts have been successfully applied. Applicable to [ATTACH PARTITION|PART](/reference/statements/alter/partition#attach-partitionpart) and to [FREEZE PARTITION](/reference/statements/alter/partition#freeze-partition). Possible values: - 0 — disable verbosity. - 1 — enable verbosity. **Example** ```sql CREATE TABLE test(a Int64, d Date, s String) ENGINE = MergeTree PARTITION BY toYYYYMDECLARE(d) ORDER BY a; INSERT INTO test VALUES(1, '2021-01-01', ''); INSERT INTO test VALUES(1, '2021-01-01', ''); ALTER TABLE test DETACH PARTITION ID '202101'; ALTER TABLE test ATTACH PARTITION ID '202101' SETTINGS alter_partition_verbose_result = 1; ┌─command_type─────┬─partition_id─┬─part_name────┬─old_part_name─┐ │ ATTACH PARTITION │ 202101 │ 202101_7_7_0 │ 202101_5_5_0 │ │ ATTACH PARTITION │ 202101 │ 202101_8_8_0 │ 202101_6_6_0 │ └──────────────────┴──────────────┴──────────────┴───────────────┘ ALTER TABLE test FREEZE SETTINGS alter_partition_verbose_result = 1; ┌─command_type─┬─partition_id─┬─part_name────┬─backup_name─┬─backup_path───────────────────┬─part_backup_path────────────────────────────────────────────┐ │ FREEZE ALL │ 202101 │ 202101_7_7_0 │ 8 │ /var/lib/clickhouse/shadow/8/ │ /var/lib/clickhouse/shadow/8/data/default/test/202101_7_7_0 │ │ FREEZE ALL │ 202101 │ 202101_8_8_0 │ 8 │ /var/lib/clickhouse/shadow/8/ │ /var/lib/clickhouse/shadow/8/data/default/test/202101_8_8_0 │ └──────────────┴──────────────┴──────────────┴─────────────┴───────────────────────────────┴─────────────────────────────────────────────────────────────┘ ``` )", 0) \ DECLARE(Bool, system_events_show_zero_values, false, R"( Allows to select zero-valued events from [`system.events`](/reference/system-tables/events). Some monitoring systems require passing all the metrics values to them for each checkpoint, even if the metric value is zero. Possible values: - 0 — Disabled. - 1 — Enabled. **Examples** Query ```sql SELECT * FROM system.events WHERE event='QueryMemoryLimitExceeded'; ``` Result ```text Ok. ``` Query ```sql SET system_events_show_zero_values = 1; SELECT * FROM system.events WHERE event='QueryMemoryLimitExceeded'; ``` Result ```text ┌─event────────────────────┬─value─┬─description───────────────────────────────────────────┐ │ QueryMemoryLimitExceeded │ 0 │ Number of times when memory limit exceeded for query. │ └──────────────────────────┴───────┴───────────────────────────────────────────────────────┘ ``` )", 0) \ DECLARE(Bool, system_metric_log_show_zero_values_in_histograms, false, R"( Controls whether zero-valued histogram data is written to the `histograms` nested column of `system.metric_log`. By default, histograms whose total observation `count` is zero are skipped, and within each emitted histogram, bucket entries with no observations are also omitted from the `histogram` map. Enable this to write every histogram and every bucket regardless of count — useful for monitoring systems that require every metric to appear at every checkpoint. Possible values: - 0 — Disabled. Histograms with `count = 0` are not emitted; emitted histograms include only buckets that received at least one observation. - 1 — Enabled. All histograms are written, and every bucket boundary appears in `histogram`. )", 0, \ {"26.5", false, false, "New setting controlling whether zero-valued histogram data is written to the histograms nested column of system.metric_log."}) \ DECLARE(MySQLDataTypesSupport, mysql_datatypes_support_level, "decimal,datetime64,date2Date32,geometry", R"( Defines how MySQL types are converted to corresponding ClickHouse types. A comma separated list in any combination of `decimal`, `datetime64`, `date2Date32`, `date2String` or `geometry`. All modern mappings (`decimal`, `datetime64`, `date2Date32`, `geometry`) are enabled by default. - `decimal`: convert `NUMERIC` and `DECIMAL` types to `Decimal` when precision allows it. - `datetime64`: convert `DATETIME` and `TIMESTAMP` types to `DateTime64` instead of `DateTime` when precision is not `0`. - `date2Date32`: convert `DATE` to `Date32` instead of `Date`. Takes precedence over `date2String`. - `date2String`: convert `DATE` to `String` instead of `Date`. Overridden by `datetime64`. - `geometry`: convert MySQL's spatial types (`LINESTRING`, `POLYGON`, `MULTILINESTRING`, `MULTIPOLYGON`, `MULTIPOINT`) to the corresponding ClickHouse geometric types, and the generic `GEOMETRY` type to the umbrella `Geometry` type. `POINT` is always converted to `Point` regardless of this option. Because a generic `GEOMETRY` column can hold any subtype, reading a value whose subtype has no ClickHouse counterpart (`GEOMETRYCOLLECTION`) throws an exception at read time; columns declared as `GEOMETRYCOLLECTION` map to `String`. A nullable spatial column other than `POINT` also maps to `Nullable(String)`, since `Point` is the only geometric type that can be nested inside `Nullable`. Every such string is a 4-byte SRID prefix followed by the WKB payload, as returned by MySQL. All of the above applies when the schema is inferred from the column types of a MySQL table; when the source is a query (the `query(...)` argument of the `mysql` table function or the `MySQL` table engine), MySQL reports every spatial result column as the generic `GEOMETRY` without the concrete subtype, so such columns — including `POINT` — map to `String` (`Nullable(String)` if nullable). )", 0, \ {"26.7", "decimal,datetime64,date2Date32", "decimal,datetime64,date2Date32,geometry", "Map MySQL's concrete spatial types (LINESTRING, POLYGON, MULTILINESTRING, MULTIPOLYGON, MULTIPOINT) and the generic GEOMETRY type to the corresponding ClickHouse geometric types by default. The generic GEOMETRY column maps to the umbrella Geometry type; reading a value whose subtype has no ClickHouse counterpart (GEOMETRYCOLLECTION) throws at read time."}, \ {"26.3", "", "decimal,datetime64,date2Date32", "Enable modern MySQL type mappings by default."}) \ DECLARE(Bool, optimize_trivial_insert_select, false, R"( Optimize trivial 'INSERT INTO table SELECT ... FROM TABLES' query Pair this with an explicit `max_insert_threads` setting: the optimization caps the `SELECT` to `max_insert_threads` reading threads, which changes how many blocks the `SELECT` produces. )", 0, \ {"24.7", true, false, "The optimization does not make sense in many cases."}) \ DECLARE(Bool, allow_non_metadata_alters, true, R"( Allows `ALTER` statements that modify data on disk, not only table metadata. When disabled, an `ALTER` DDL statement on a `MergeTree`-family table is rejected with `ALTER_OF_COLUMN_IS_FORBIDDEN` if it would rewrite data on disk, either directly or by scheduling a mutation (see `system.mutations`). This covers: - `ALTER TABLE ... MODIFY COLUMN` with a type change that rewrites the column, `ALTER TABLE ... DROP COLUMN` or `... CLEAR COLUMN` of a physical column, `ALTER TABLE ... RENAME COLUMN` of any column including an `ALIAS`, `ALTER TABLE ... DROP INDEX`, `... CLEAR INDEX`, `... DROP PROJECTION`, `... CLEAR PROJECTION`, `... DROP STATISTICS`, `... CLEAR STATISTICS`, and `ALTER TABLE ... MODIFY TTL` when `materialize_ttl_after_modify` is enabled. - `ALTER TABLE ... UPDATE` whenever it runs as a heavyweight mutation, which is the default `alter_update_mode = 'heavy'` and every case the other modes fall back to, `ALTER TABLE ... DELETE WHERE`, `ALTER TABLE ... MATERIALIZE INDEX`, `... MATERIALIZE PROJECTION`, `... MATERIALIZE STATISTICS`, `... MATERIALIZE COLUMN`, `... MATERIALIZE TTL` (unconditionally, unlike `MODIFY TTL` above), `... APPLY DELETED MASK`, `... APPLY PATCHES` and `... REWRITE PARTS`. Other `ALTER` statements are allowed, including `ADD COLUMN`, `COMMENT COLUMN`, `MODIFY SETTING`, an `Enum` extension, and `DROP COLUMN` of an `ALIAS` column. The dedicated `DELETE FROM ...` and `UPDATE ... SET ...` statements are a different thing from the `ALTER TABLE ... DELETE WHERE` and `ALTER TABLE ... UPDATE` commands above, and this setting never refuses them, in any mode they support. It governs `ALTER` DDL only. Use `GRANT` and `REVOKE` of `ALTER DELETE` and `ALTER UPDATE` to restrict data modification as a whole; note that those privileges cover the dedicated statements and the `ALTER` commands together, so they cannot separate the two forms. The check applies only to `MergeTree`-family tables. Other engines, such as `Memory`, `Log`, `StripeLog`, `KeeperMap` and `EmbeddedRocksDB`, ignore this setting. )", 0) \ DECLARE(Bool, enable_global_with_statement, true, R"( Propagate WITH statements to UNION queries and all subqueries )", 0, \ {"21.2", false, true, "Propagate WITH statements to UNION queries and all subqueries by default"}) \ DECLARE(Bool, enable_materialized_cte, false, R"( Enable materialized common table expressions (`WITH AS MATERIALIZED ()`). When enabled, a CTE declared as `MATERIALIZED` that is referenced more than once is executed once, stored in a temporary table, and all references read from that table. A CTE referenced only once is inlined as an ordinary CTE to avoid the overhead. When disabled, the `MATERIALIZED` keyword is ignored: the CTE is inlined at each reference like an ordinary CTE, and a warning is logged. )", EXPERIMENTAL, \ {"26.3", false, false, "New setting"}) \ DECLARE(Bool, analyzer_inline_views, false, R"( When enabled, the analyzer substitutes ordinary (non-materialized, non-parameterized) views with their defining subqueries, enabling cross-boundary optimizations such as predicate pushdown and column pruning. )", EXPERIMENTAL, \ {"26.4", false, false, "New setting"}) \ DECLARE(Bool, enable_scopes_for_with_statement, true, R"( If disabled, declarations in parent WITH clauses will behave the same scope as they declared in the current scope. Note that this is a compatibility setting for the analyzer to allow running some invalid queries that old analyzer could execute. )", 0, \ {"25.7", true, true, "New setting for backward compatibility with the old analyzer."}, \ {"25.6", true, true, "New setting for backward compatibility with the old analyzer."}, \ {"25.5", true, true, "New setting for backward compatibility with the old analyzer."}, \ {"25.4", true, true, "New setting for backward compatibility with the old analyzer."}) \ DECLARE(Bool, aggregate_functions_null_for_empty, false, R"( Enables or disables rewriting all aggregate functions in a query, adding [-OrNull](/reference/functions/aggregate-functions/combinators#-ornull) suffix to them. Enable it for SQL standard compatibility. It is implemented via query rewrite (similar to [count_distinct_implementation](#count_distinct_implementation) setting) to get consistent results for distributed queries. Possible values: - 0 — Disabled. - 1 — Enabled. **Example** Consider the following query with aggregate functions: ```sql SELECT SUM(-1), MAX(0) FROM system.one WHERE 0; ``` With `aggregate_functions_null_for_empty = 0` it would produce: ```text ┌─SUM(-1)─┬─MAX(0)─┐ │ 0 │ 0 │ └─────────┴────────┘ ``` With `aggregate_functions_null_for_empty = 1` the result would be: ```text ┌─SUMOrNull(-1)─┬─MAXOrNull(0)─┐ │ NULL │ NULL │ └───────────────┴──────────────┘ ``` )", 0) \ DECLARE(AggregateFunctionInputFormat, aggregate_function_input_format, "state", R"( How the input formats read columns of the `AggregateFunction` type. Possible values: - `state` — the serialized state of the aggregate function, as the output formats write it (the default). - `value` — a value of the argument of the aggregate function, or a tuple of the arguments if there are several of them. The value is aggregated to form the state. - `array` — an array of values, as described in the `value` option above. All elements of the array are aggregated to form the state. In the `value` and `array` modes the format reads the column as if it had the type of the values: `T` for `AggregateFunction(f, T)`, `Tuple(T1, T2)` for `AggregateFunction(f, T1, T2)`, or `Array` of it in the `array` mode. The values are written in the representation the format uses for that type: a number or a string in a text format, a JSON array in the JSON formats, the binary encoding of the type in `RowBinary` or `Native`, a column of that type in `Parquet`, and so on. This applies to every input format, and also to `AggregateFunction` nested in `Array`, `Tuple` or `Map`. **Examples** For a table with structure: ```sql CREATE TABLE example ( user_id UInt64, avg_session_length AggregateFunction(avg, UInt32) ); ``` With `aggregate_function_input_format = 'value'`: ```sql INSERT INTO example FORMAT CSV 123,456 ``` ```sql INSERT INTO example FORMAT JSONEachRow {"user_id": 123, "avg_session_length": 456} ``` With `aggregate_function_input_format = 'array'`: ```sql INSERT INTO example FORMAT CSV 123,"[456,789,101]" ``` ```sql INSERT INTO example FORMAT JSONEachRow {"user_id": 123, "avg_session_length": [456, 789, 101]} ``` Note: The `value` and `array` formats are slower than the default `state` format as they require creating and aggregating values during insertion. )", 0, \ {"25.12", "state", "state", "New setting to control AggregateFunction input format during INSERT operations. Setting Value set to state by default"}) \ DECLARE(Bool, optimize_syntax_fuse_functions, true, R"( Enables to fuse aggregate functions with identical argument. It rewrites query contains at least two aggregate functions from [sum](/reference/functions/aggregate-functions/sum), [count](/reference/functions/aggregate-functions/count) or [avg](/reference/functions/aggregate-functions/avg) with identical argument to [sumCount](/reference/functions/aggregate-functions/sumCount). Possible values: - 0 — Functions with identical argument are not fused. - 1 — Functions with identical argument are fused. **Example** Query: ```sql CREATE TABLE fuse_tbl(a Int8, b Int8) Engine = Log; SET optimize_syntax_fuse_functions = 1; EXPLAIN SYNTAX run_query_tree_passes = 1 SELECT sum(a), sum(b), count(b), avg(b) from fuse_tbl FORMAT TSVRaw; ``` Result: ```text SELECT sum(__table1.a) AS `sum(a)`, tupleElement(sumCount(__table1.b), 1) AS `sum(b)`, tupleElement(sumCount(__table1.b), 2) AS `count(b)`, divide(tupleElement(sumCount(__table1.b), 1), toFloat64(tupleElement(sumCount(__table1.b), 2))) AS `avg(b)` FROM default.fuse_tbl AS __table1 ``` )", 0, \ {"26.3", false, true, "The optimization is production-ready"}) \ DECLARE(Bool, flatten_nested, true, R"( Sets the data format of a [nested](/reference/data-types/nested-data-structures/index) columns. Possible values: - 1 — Nested column is flattened to separate arrays. - 0 — Nested column stays a single array of tuples. **Usage** If the setting is set to `0`, it is possible to use an arbitrary level of nesting. **Examples** Query: ```sql SET flatten_nested = 1; CREATE TABLE t_nest (`n` Nested(a UInt32, b UInt32)) ENGINE = MergeTree ORDER BY tuple(); SHOW CREATE TABLE t_nest; ``` Result: ```text ┌─statement───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ CREATE TABLE default.t_nest ( `n.a` Array(UInt32), `n.b` Array(UInt32) ) ENGINE = MergeTree ORDER BY tuple() SETTINGS index_granularity = 8192 │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` Query: ```sql SET flatten_nested = 0; CREATE TABLE t_nest (`n` Nested(a UInt32, b UInt32)) ENGINE = MergeTree ORDER BY tuple(); SHOW CREATE TABLE t_nest; ``` Result: ```text ┌─statement──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ CREATE TABLE default.t_nest ( `n` Nested(a UInt32, b UInt32) ) ENGINE = MergeTree ORDER BY tuple() SETTINGS index_granularity = 8192 │ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ ``` )", 0) \ DECLARE(Bool, asterisk_include_materialized_columns, false, R"( Include [MATERIALIZED](/reference/statements/create/view#materialized-view) columns for wildcard query (`SELECT *`). Possible values: - 0 - disabled - 1 - enabled )", 0) \ DECLARE(Bool, asterisk_include_alias_columns, false, R"( Include [ALIAS](/reference/statements/create/table#alias) columns for wildcard query (`SELECT *`). Possible values: - 0 - disabled - 1 - enabled )", 0) \ DECLARE(Bool, asterisk_include_virtual_columns, false, R"( Include virtual columns for wildcard query (`SELECT *`). Possible values: - 0 - disabled - 1 - enabled )", 0, \ {"26.4", false, false, "New setting"}) \ DECLARE(Bool, optimize_skip_merged_partitions, false, R"( Enables or disables optimization for [OPTIMIZE TABLE ... FINAL](/reference/statements/optimize) query if there is only one part with level > 0 and it doesn't have expired TTL. - `OPTIMIZE TABLE ... FINAL SETTINGS optimize_skip_merged_partitions=1` By default, `OPTIMIZE TABLE ... FINAL` query rewrites the one part even if there is only a single part. Possible values: - 1 - Enable optimization. - 0 - Disable optimization. )", 0) \ DECLARE(Bool, optimize_on_insert, true, R"( Enables or disables data transformation before the insertion, as if merge was done on this block (according to table engine). Possible values: - 0 — Disabled. - 1 — Enabled. **Example** The difference between enabled and disabled: Query: ```sql SET optimize_on_insert = 1; CREATE TABLE test1 (`FirstTable` UInt32) ENGINE = ReplacingMergeTree ORDER BY FirstTable; INSERT INTO test1 SELECT number % 2 FROM numbers(5); SELECT * FROM test1; SET optimize_on_insert = 0; CREATE TABLE test2 (`SecondTable` UInt32) ENGINE = ReplacingMergeTree ORDER BY SecondTable; INSERT INTO test2 SELECT number % 2 FROM numbers(5); SELECT * FROM test2; ``` Result: ```text ┌─FirstTable─┐ │ 0 │ │ 1 │ └────────────┘ ┌─SecondTable─┐ │ 0 │ │ 0 │ │ 0 │ │ 1 │ │ 1 │ └─────────────┘ ``` Note that this setting influences [Materialized view](/reference/statements/create/view#materialized-view) behaviour. )", 0, \ {"21.1", false, true, "Enable data optimization on INSERT by default for better user experience"}) \ DECLARE_WITH_ALIAS(Bool, optimize_use_projections, true, R"( Enables or disables [projection](/reference/engines/table-engines/mergetree-family/mergetree#projections) optimization when processing `SELECT` queries. Possible values: - 0 — Projection optimization disabled. - 1 — Projection optimization enabled. )", 0, allow_experimental_projection_optimization) \ DECLARE(Bool, optimize_use_implicit_projections, true, R"( Automatically choose implicit projections to perform SELECT query )", 0) \ DECLARE(Bool, optimize_use_projection_filtering, true, R"( Enables using projections to filter part ranges even when projections are not selected to perform SELECT query. )", 0, \ {"25.6", false, true, "New setting"}) \ DECLARE(Float, optimize_projection_skip_index_ratio, 0.5, R"( When `use_skip_indexes_on_data_read` is enabled, the base table's skip indexes are applied at data-read time, so the mark count that a normal projection candidate is compared against is estimated by the primary key only. If the best normal projection candidate reads more than this fraction of that estimate, and the base table has skip indexes usable for the query, the skip indexes are applied to the base table during planning and the refined mark count is used for the comparison. `0` always applies them, `1` keeps the primary-key-only comparison. Aggregate projections are not affected. Possible values: - A float in the range `[0, 1]`. )", 0, \ {"26.11", 1.0, 0.5, "New setting controlling when projection selection applies the base table's deferred skip indexes before comparing costs: the extra pass runs only if the best projection candidate reads more than this fraction of the parent's primary-key-only mark estimate. The previous value 1.0 restores the pre-existing behavior: with ratio = 1 the refinement never runs, because it could only matter for candidates that the primary-key-only comparison rejects anyway."}) \ DECLARE(Bool, force_optimize_projection, false, R"( Enables or disables the obligatory use of [projections](/reference/engines/table-engines/mergetree-family/mergetree#projections) in `SELECT` queries, when projection optimization is enabled (see [optimize_use_projections](#optimize_use_projections) setting). When enabled, a projection that can serve the query is used even if it requires reading more marks than the table itself, and the query fails with the `PROJECTION_NOT_USED` error when no projection can be used. Possible values: - 0 — Projection optimization is not obligatory. - 1 — Projection optimization is obligatory. )", 0) \ DECLARE(Bool, prefer_optimize_projection, false, R"( Makes the projection optimization prefer [projections](/reference/engines/table-engines/mergetree-family/mergetree#projections) over the table in `SELECT` queries, when projection optimization is enabled (see [optimize_use_projections](#optimize_use_projections) setting). When enabled, a projection that can serve the query is used even if it requires reading more marks than the table itself, the same as with [force_optimize_projection](#force_optimize_projection), but the query does not fail when no projection can be used. Possible values: - 0 — Projections are chosen by their estimated cost. - 1 — A usable projection is chosen regardless of its estimated cost. )", 0, \ {"26.10", false, false, "New setting: choose a usable projection regardless of its estimated cost, like `force_optimize_projection`, but without failing the query when no projection is used."}) \ DECLARE(String, force_optimize_projection_name, "", R"( If it is set to a non-empty string, check that this projection is used in the query at least once. Possible values: - string: name of projection that used in a query )", 0) \ DECLARE(String, preferred_optimize_projection_name, "", R"( If it is set to a non-empty string, ClickHouse will try to apply specified projection in query. Possible values: - string: name of preferred projection )", 0) \ DECLARE(UInt64, max_projection_rows_to_use_projection_index, 1'000'000, R"( If the number of rows to read from the projection index is less than or equal to this threshold, ClickHouse will try to apply the projection index during query execution. )", 0, \ {"25.11", 1'000'000, 1'000'000, "New setting"}) \ DECLARE(UInt64, min_table_rows_to_use_projection_index, 1'000'000, R"( If the estimated number of rows to read from the table is greater than or equal to this threshold, ClickHouse will try to use the projection index during query execution. )", 0, \ {"25.11", 1'000'000, 1'000'000, "New setting"}) \ DECLARE(Bool, enable_join_seal_gated_reading, false, R"( Gate the probe-side reading of a hash JOIN on the completion of the build-side runtime filter (see `enable_join_runtime_filters`): nothing is read on the probe side until the filter is complete, and the filter is then used to prune whole mark ranges by the primary key before read tasks are created, in addition to the ordinary row-level filtering. The gating is expressed as an edge of the query pipeline. On a gated read, the read-time index analysis of the same runtime filter (see `enable_join_runtime_filters_index_analysis`) is skipped as redundant. Experimental. Local reads are gated, including single-threaded and in-order reading; reads under FINAL, parallel replicas, or a join sharded by primary key ranges fall back to ungated reading with row-level filtering. )", EXPERIMENTAL, \ {"26.10", false, false, "New experimental setting to gate the probe-side reading of a hash JOIN on the build-side runtime filter completion and prune read ranges by it."}) \ DECLARE(Bool, use_indexes_refiner_in_read_pools, false, R"( Apply indexes evaluated at data-read time already inside MergeTree read pools: mark ranges fully filtered out by skip indexes (see `use_skip_indexes_on_data_read`) or by the projection index (see `optimize_use_projection_filtering`) are dropped before a read task is created for them, instead of being skipped granule by granule during reading. In the prefetched read pool the dropped ranges are never prefetched, but the task boundaries and the prefetch admission by `filesystem_prefetch_max_memory_usage` / `filesystem_prefetches_limit` are still decided before the filtering, so under highly selective filters the surviving tasks may be smaller than the intended task size and the admission may be conservative. )", 0, \ {"26.8", false, false, "New setting to drop mark ranges fully filtered out by skip indexes or a projection index before read tasks are created in MergeTree read pools."}) \ DECLARE(Bool, async_socket_for_remote, true, R"( Enables asynchronous read from socket while executing remote query. Enabled by default. )", 0, \ {"21.5", false, true, "Fix all problems and turn on asynchronous reads from socket for remote queries by default again"}, \ {"21.3", true, false, "Turn off asynchronous reads from socket for remote queries because of some problems"}) \ DECLARE(Bool, async_query_sending_for_remote, true, R"( Enables asynchronous connection creation and query sending while executing remote query. Enabled by default. )", 0, \ {"23.3", false, true, "Create connections and send query async across shards"}) \ DECLARE(Bool, insert_null_as_default, true, R"( Enables or disables the insertion of [default values](/reference/statements/create/table#default_values) instead of [NULL](/reference/syntax#null) into columns with not [nullable](/reference/data-types/nullable) data type. If column type is not nullable and this setting is disabled, then inserting `NULL` causes an exception. If column type is nullable, then `NULL` values are inserted as is, regardless of this setting. This setting is applicable to [INSERT ... SELECT](/reference/statements/insert-into#inserting-the-results-of-select) queries. Note that `SELECT` subqueries may be concatenated with `UNION ALL` clause. Possible values: - 0 — Inserting `NULL` into a not nullable column causes an exception. - 1 — Default column value is inserted instead of `NULL`. )", 0) \ DECLARE(Bool, describe_include_subcolumns, false, R"( Enables describing subcolumns for a [DESCRIBE](/reference/statements/describe-table) query. For example, members of a [Tuple](/reference/data-types/tuple) or subcolumns of a [Map](/reference/data-types/map#reading-subcolumns-of-map), [Nullable](/reference/data-types/nullable#finding-null) or an [Array](/reference/data-types/array#array-size) data type. Possible values: - 0 — Subcolumns are not included in `DESCRIBE` queries. - 1 — Subcolumns are included in `DESCRIBE` queries. **Example** See an example for the [DESCRIBE](/reference/statements/describe-table) statement. )", 0) \ DECLARE(Bool, describe_include_virtual_columns, false, R"( If true, virtual columns of table will be included into result of DESCRIBE query )", 0) \ DECLARE(Bool, describe_compact_output, false, R"( If true, include only column names and types into result of DESCRIBE query )", 0) \ DECLARE(Bool, apply_mutations_on_fly, false, R"( If true, mutations (UPDATEs and DELETEs) which are not materialized in data part will be applied on SELECTs. )", 0) \ DECLARE_WITH_ALIAS(Bool, enable_lightweight_update, true, R"( Allow to use lightweight updates. )", 0, allow_experimental_lightweight_update, \ {"25.8", false, true, "Lightweight updates were moved to Beta. Added an alias for setting 'allow_experimental_lightweight_update'."}, \ {"25.5", false, false, "A new setting. At the time the setting was named `allow_experimental_lightweight_update`, which is now an alias of it."}) \ DECLARE(Bool, apply_patch_parts, true, R"( If true, patch parts (that represent lightweight updates) are applied on SELECTs. )", 0, \ {"25.5", true, true, "A new setting"}) \ DECLARE(NonZeroUInt64, apply_patch_parts_join_cache_buckets, 8, R"( The number of buckets in the temporary cache for applying patch parts in Join mode. )", 0, \ {"25.8", 8, 8, "New setting"}) \ DECLARE(AlterUpdateMode, alter_update_mode, AlterUpdateMode::HEAVY, R"( A mode for `ALTER` queries that have the `UPDATE` commands. Possible values: - `heavy` - run regular mutation. - `lightweight` - run lightweight update if possible, run regular mutation otherwise. - `lightweight_force` - run lightweight update if possible, throw otherwise. )", 0, \ {"25.5", "heavy", "heavy", "A new setting"}) \ DECLARE(Bool, mutations_execute_nondeterministic_on_initiator, false, R"( If true constant nondeterministic functions (e.g. function `now()`) are executed on initiator and replaced to literals in `UPDATE` and `DELETE` queries. It helps to keep data in sync on replicas while executing mutations with constant nondeterministic functions. Default value: `false`. )", 0) \ DECLARE(Bool, mutations_execute_subqueries_on_initiator, false, R"( If true scalar subqueries are executed on initiator and replaced to literals in `UPDATE` and `DELETE` queries. Default value: `false`. )", 0) \ DECLARE(UInt64, mutations_max_literal_size_to_replace, 16384, R"( The maximum size of serialized literal in bytes to replace in `UPDATE` and `DELETE` queries. Takes effect only if at least one the two settings above is enabled. Default value: 16384 (16 KiB). )", 0) \ \ DECLARE(Float, create_replicated_merge_tree_fault_injection_probability, 0.0f, R"( The probability of a fault injection during table creation after creating metadata in ZooKeeper )", 0) \ DECLARE(Bool, delta_lake_log_metadata, false, R"( Enables logging delta lake metadata files into system table. )", 0, \ {"25.10", false, false, "New setting."}) \ DECLARE(Bool, delta_lake_reload_schema_for_consistency, false, R"( If enabled, schema is reloaded from the DeltaLake metadata before each query execution to ensure consistency between the schema used during query analysis and the schema used during execution. )", 0, \ {"26.3", false, false, "New setting to control whether DeltaLake reloads schema before each query for consistency."}) \ DECLARE(IcebergMetadataLogLevel, iceberg_metadata_log_level, IcebergMetadataLogLevel::None, R"( Controls the level of metadata logging for Iceberg tables to system.iceberg_metadata_log. Usually this setting can be modified for debugging purposes. Possible values: - none - No metadata log. - metadata - Root metadata.json file. - manifest_list_metadata - Everything above + metadata from avro manifest list which corresponds to a snapshot. - manifest_list_entry - Everything above + avro manifest list entries. - manifest_file_metadata - Everything above + metadata from traversed avro manifest files. - manifest_file_entry - Everything above + traversed avro manifest files entries. )", 0, \ {"25.9", "none", "none", "New setting."}) \ \ DECLARE(Bool, iceberg_delete_data_on_drop, false, R"( Whether to delete all iceberg files on drop or not. )", 0, \ {"25.9", false, false, "New setting"}) \ DECLARE(Int64, iceberg_expire_default_min_snapshots_to_keep, 1, R"( Default value for Iceberg table property `history.expire.min-snapshots-to-keep` used by `expire_snapshots` when that property is absent. )", 0, \ {"26.3", 1, 1, "New setting."}) \ DECLARE(Int64, iceberg_expire_default_max_snapshot_age_ms, 432000000, R"( Default value for Iceberg table property `history.expire.max-snapshot-age-ms` used by `expire_snapshots` when that property is absent. )", 0, \ {"26.3", 432000000, 432000000, "New setting."}) \ DECLARE(Int64, iceberg_expire_default_max_ref_age_ms, std::numeric_limits::max(), R"( Default value for Iceberg table property `history.expire.max-ref-age-ms` used by `expire_snapshots` when that property is absent. )", 0, \ {"26.3", 9223372036854775807, 9223372036854775807, "New setting."}) \ DECLARE(UInt64, iceberg_data_file_size_lower_threshold_compaction, 384_MiB, R"( Data files smaller than this are selected for compaction. The default is `0.75` of the documented default of the Iceberg table property `write.target-file-size-bytes` (512 MiB), which is how the `rewrite_data_files` procedure derives its `min-file-size-bytes` option, see https://iceberg.apache.org/docs/1.5.2/configuration/. )", 0, \ {"26.9", 10 * 1024 * 1024, 384 * 1024 * 1024, "Aligned with how the Iceberg `rewrite_data_files` procedure derives `min-file-size-bytes`: 0.75 of the target file size (512 MiB). Compaction now selects files below 384 MiB instead of below 10 MiB."}, \ {"26.5", 10_MiB, 10_MiB, "New setting"}) \ DECLARE(UInt64, iceberg_max_number_datafiles_to_compact, 100, R"( Max number of data files merged by one compaction merge of an Iceberg table, the same as `max_parts_to_merge_at_once` for `MergeTree`. A merge reads all its input files at once, so its memory grows with the number of inputs. )", 0, \ {"26.11", 1000, 100, "The same as `max_parts_to_merge_at_once` for `MergeTree`: a merge reads all its inputs at once, and the selection of merges keeps the candidate ranges of every partition."}, \ {"26.5", 1000, 1000, "New setting"}) \ DECLARE(UInt64, iceberg_compaction_max_bytes_to_merge, 150_GiB, R"( Max total size of the data files merged by one compaction merge of an Iceberg table, the sum of their sizes in the object storage. The same as `max_bytes_to_merge_at_max_space_in_pool` for `MergeTree`: when the background pool has fewer free entries than `number_of_free_entries_in_pool_to_lower_max_size_of_merge`, the limit is lowered down to `max_bytes_to_merge_at_min_space_in_pool` (both from the `merge_tree` section of the config). The files of a partition that do not fit are merged by the next merges. Does not apply to a merge that applies position delete files. )", 0, \ {"26.11", 150_GiB, 150_GiB, "New setting. Limits the total size of the files of a compaction merge, the same way as `max_bytes_to_merge_at_max_space_in_pool` does for `MergeTree`."}) \ DECLARE(UInt64, iceberg_compaction_max_rows_to_merge, std::numeric_limits::max(), R"( Max total number of rows of the data files merged by one compaction merge of an Iceberg table. The files of a partition that do not fit are merged by the next merges. Does not apply to a merge that applies position delete files. )", 0, \ {"26.11", std::numeric_limits::max(), std::numeric_limits::max(), "New setting. Restores the limit on the total number of rows of the files of a compaction merge, which was decided by `iceberg_compaction_max_rows_in_data_file` before."}) \ DECLARE(Bool, use_iceberg_metadata_files_cache, true, R"( If turned on, iceberg table function and iceberg storage may utilize the iceberg metadata files cache. Possible values: - 0 - Disabled - 1 - Enabled )", 0, \ {"25.4", true, true, "New setting"}) \ DECLARE(Bool, use_paimon_metadata_files_cache, false, R"( If turned on, paimon table function and paimon storage may utilize the paimon metadata files cache. Paimon table functions evaluate this setting per query, while persistent Paimon table engines latch it at metadata initialization: to change the decision for an already-created table, it must be dropped and recreated. Possible values: - 0 - Disabled - 1 - Enabled )", 0, \ {"26.7", false, false, "New setting to enable in-memory caching of parsed Paimon metadata files (manifest lists and manifests). For persistent Paimon table engines it must be enabled before metadata initialization; table functions evaluate it per query. Avoids repeated downloads and deserialization of metadata files from object storage on subsequent queries."}) \ DECLARE(UInt64, iceberg_metadata_staleness_ms, 0, R"( If non-zero, skip fetching the latest Iceberg metadata version (from the remote catalog, from `metadata/version-hint.text` with `iceberg_use_version_hint`, or by listing the metadata files) if there is a cached one, more recent than the given staleness window. Zero means to always fetch the latest metadata version. Setting this a non-zero trades staleness to a lower latency of read operations. )", 0, \ {"26.3", 0, 0, "New setting allowing using cached metadata version at READ operations to prevent fetching from remote catalog"}) \ DECLARE(Bool, iceberg_list_only_v_prefixed_metadata_files, false, R"( Find the latest metadata file of an Iceberg table read by path on S3 or Azure by listing only the key prefix `metadata/v`, so that the manifests stored in the same `metadata` directory are not listed. If it holds `.metadata.json` files, only they are candidates; otherwise the whole directory is listed. Does not apply with `iceberg_use_version_hint`, `iceberg_metadata_file_path`, `iceberg_metadata_table_uuid` or `iceberg_recent_metadata_file_by_last_updated_ms_field`, nor to the tables of a data lake catalog database. Enable it only for tables whose metadata files are all named `v...` (as ClickHouse and Hadoop catalogs name them): in a directory that also holds `-.metadata.json` files, those files are never candidates, so the commits of their writer are not seen. )", 0, \ {"26.11", false, false, "New setting to list only the `metadata/v` key prefix when looking for the latest metadata file of an Iceberg table read by path."}) \ DECLARE(Bool, use_parquet_metadata_cache, true, R"( If turned on, parquet format may utilize the parquet metadata cache. For the `File` table engine and the `file` table function, a read with a filter also keeps the min/max statistics of the filter columns in the cache, and a later query skips a file without opening it if these statistics show that no row group of the file can match its filter. Errors that only opening such a file would raise (for example, a selected column missing from the file with `input_format_parquet_allow_missing_columns` disabled) then depend on whether the cache holds its statistics. Disabling this setting also disables keeping the statistics and skipping files. Possible values: - 0 - Disabled - 1 - Enabled )", 0, \ {"26.3", false, true, "Enables cache of parquet file metadata."}) \ DECLARE(Seconds, iceberg_compaction_delay_bias, 60 * 60 * 3, R"( Minimum time of delay between 2 background compaction operations. )", 0, \ {"26.5", 60 * 60 * 3, 60 * 60 * 3, "New setting"}) \ DECLARE(Seconds, iceberg_compaction_data_cleanup, 60 * 60 * 3, R"( With `enable_cleanup_old_data_files_compaction`, the time after which a snapshot of an Iceberg table that a newer one replaced is expired, together with the files that only it references. The longer of this and `iceberg_outdated_snapshot_lifetime_seconds` applies. )", 0, \ {"26.5", 60 * 60 * 3, 60 * 60 * 3, "New setting"}) \ DECLARE(UInt64, iceberg_compaction_commit_batch_size, 100, R"( Number of merged data files that background Iceberg compaction accumulates before publishing them in a new snapshot. Compaction results are published in any case once there are no candidates left to compact, so this setting only bounds how long already merged files stay unpublished while compaction keeps finding new work. `0` restores the old behaviour of publishing only when compaction runs out of candidates - a state that is never reached while the table keeps receiving new data files, so every merged output is then written to object storage and never referenced by a snapshot. )", 0, \ {"26.9", 100, 100, "New setting"}, \ {"26.8", 100, 100, "New setting"}) \ DECLARE(Bool, use_query_cache, false, R"( If turned on, `SELECT` queries may utilize the [query cache](/concepts/features/performance/caches/query-cache). Parameters [enable_reads_from_query_cache](#enable_reads_from_query_cache) and [enable_writes_to_query_cache](#enable_writes_to_query_cache) control in more detail how the cache is used. Possible values: - 0 - Disabled - 1 - Enabled )", 0) \ DECLARE(Bool, enable_writes_to_query_cache, true, R"( If turned on, results of `SELECT` queries are stored in the [query cache](/concepts/features/performance/caches/query-cache). Possible values: - 0 - Disabled - 1 - Enabled )", 0) \ DECLARE(Bool, enable_reads_from_query_cache, true, R"( If turned on, results of `SELECT` queries are retrieved from the [query cache](/concepts/features/performance/caches/query-cache). Possible values: - 0 - Disabled - 1 - Enabled )", 0) \ DECLARE(String, query_cache_on_disk_cache_name, "", R"( The name of a filesystem cache (an entry of the `filesystem_caches` section of the server configuration) which stores entries of the [query cache](/concepts/features/performance/caches/query-cache) on disk. If a name is given (and [use_query_cache](#use_query_cache) is enabled), query results are additionally cached in (and served from) the specified filesystem cache. The on-disk query cache provides more space than the in-memory query cache, survives server restarts, and works independently of the in-memory query cache: settings [enable_reads_from_query_cache_on_disk](#enable_reads_from_query_cache_on_disk) and [enable_writes_to_query_cache_on_disk](#enable_writes_to_query_cache_on_disk) control it separately from the in-memory query cache. The entries in the filesystem cache are ordinary entries of the filesystem cache: they are not held from deletion and they are evicted by the same rules as any other data in it. `SYSTEM CLEAR FILESYSTEM CACHE ''` removes them together with everything else in the filesystem cache, and `SYSTEM CLEAR QUERY CACHE` removes the entries of the query cache on disk from the filesystem cache named by this setting, leaving all other data in place. A dedicated filesystem cache for query results is recommended. Possible values: - Empty string - The query cache on disk is disabled - The name of a preconfigured filesystem cache )", 0, \ {"26.10", "", "", "New setting to store entries of the query cache on disk in the named filesystem cache."}) \ DECLARE(String, query_cache_on_disk_codec, "ZSTD(3)", R"( The compression codec for entries of the [query cache](/concepts/features/performance/caches/query-cache) on disk (see [query_cache_on_disk_cache_name](#query_cache_on_disk_cache_name)). Only affects writing; reading is independent of this setting because the compressed data is self-describing. )", 0, \ {"26.10", "ZSTD(3)", "ZSTD(3)", "New setting to control the compression codec of query cache entries on disk."}) \ DECLARE(Bool, enable_writes_to_query_cache_on_disk, true, R"( If turned on (and [query_cache_on_disk_cache_name](#query_cache_on_disk_cache_name) is set), results of `SELECT` queries are stored in the [query cache](/concepts/features/performance/caches/query-cache) on disk. Possible values: - 0 - Disabled - 1 - Enabled )", 0, \ {"26.10", true, true, "New setting to control whether query results are written to the query cache on disk."}) \ DECLARE(Bool, enable_reads_from_query_cache_on_disk, true, R"( If turned on (and [query_cache_on_disk_cache_name](#query_cache_on_disk_cache_name) is set), results of `SELECT` queries are retrieved from the [query cache](/concepts/features/performance/caches/query-cache) on disk. If reads are enabled for both the in-memory and the on-disk query cache, the lookup is attempted first from memory and only on a miss from disk. Possible values: - 0 - Disabled - 1 - Enabled )", 0, \ {"26.10", true, true, "New setting to control whether query results are read from the query cache on disk."}) \ DECLARE(Bool, query_cache_for_subqueries, false, R"( If turned on, subquery results may be written to and read from the [query cache](/concepts/features/performance/caches/query-cache). This enables propagation of `use_query_cache` into all subqueries. Possible values: - 0 - Disabled - 1 - Enabled )", 0, \ {"26.5", false, false, "New setting to enable propagation of `use_query_cache` into all subqueries. Without it, subqueries are only cached on explicit per-subquery `SETTINGS use_query_cache = true` opt-in."}) \ DECLARE(QueryResultCacheNondeterministicFunctionHandling, query_cache_nondeterministic_function_handling, QueryResultCacheNondeterministicFunctionHandling::Throw, R"( Controls how the [query cache](/concepts/features/performance/caches/query-cache) handles `SELECT` queries with non-deterministic functions like `rand()` or `now()`. Possible values: - `'throw'` - Throw an exception and don't cache the query result. - `'save'` - Cache the query result. - `'ignore'` - Don't cache the query result and don't throw an exception. )", 0) \ DECLARE(QueryResultCacheSystemTableHandling, query_cache_system_table_handling, QueryResultCacheSystemTableHandling::Throw, R"( Controls how the [query cache](/concepts/features/performance/caches/query-cache) handles `SELECT` queries against system tables, i.e. tables in databases `system.*` and `information_schema.*`. Possible values: - `'throw'` - Throw an exception and don't cache the query result. - `'save'` - Cache the query result. - `'ignore'` - Don't cache the query result and don't throw an exception. )", 0, \ {"24.4", "save", "throw", "The query cache no longer caches results of queries against system tables"}) \ DECLARE(UInt64, query_cache_max_size_in_bytes, 0, R"( The maximum amount of memory (in bytes) the current user may allocate in the in-memory [query cache](/concepts/features/performance/caches/query-cache). 0 means unlimited. This limit does not apply to the query cache on disk (setting `query_cache_on_disk_cache_name`), whose entries are bounded by the size of the underlying filesystem cache instead. Possible values: - Positive integer >= 0. )", 0) \ DECLARE(UInt64, query_cache_max_entries, 0, R"( The maximum number of query results the current user may store in the in-memory [query cache](/concepts/features/performance/caches/query-cache). 0 means unlimited. This limit does not apply to the query cache on disk (setting `query_cache_on_disk_cache_name`), whose entries are bounded by the size of the underlying filesystem cache instead. Possible values: - Positive integer >= 0. )", 0) \ DECLARE(UInt64, query_cache_min_query_runs, 0, R"( Minimum number of times a `SELECT` query must run before its result is stored in the [query cache](/concepts/features/performance/caches/query-cache). Possible values: - Positive integer >= 0. )", 0) \ DECLARE(Milliseconds, query_cache_min_query_duration, 0, R"( Minimum duration in milliseconds a query needs to run for its result to be stored in the [query cache](/concepts/features/performance/caches/query-cache). Possible values: - Positive integer >= 0. )", 0) \ DECLARE(Bool, query_cache_compress_entries, true, R"( Compress entries in the [query cache](/concepts/features/performance/caches/query-cache). Lessens the memory consumption of the query cache at the cost of slower inserts into / reads from it. Possible values: - 0 - Disabled - 1 - Enabled )", 0) \ DECLARE(Bool, query_cache_squash_partial_results, true, R"( Squash partial result blocks to blocks of size [max_block_size](#max_block_size). Reduces performance of inserts into the [query cache](/concepts/features/performance/caches/query-cache) but improves the compressibility of cache entries (see [query_cache_compress-entries](#query_cache_compress_entries)). Possible values: - 0 - Disabled - 1 - Enabled )", 0) \ DECLARE(Seconds, query_cache_ttl, 60, R"( After this time in seconds entries in the [query cache](/concepts/features/performance/caches/query-cache) become stale. Possible values: - Positive integer >= 0. )", 0) \ DECLARE(Bool, query_cache_share_between_users, false, R"( If turned on, the result of `SELECT` queries cached in the [query cache](/concepts/features/performance/caches/query-cache) can be read by other users. It is not recommended to enable this setting due to security reasons. Possible values: - 0 - Disabled - 1 - Enabled )", 0) \ DECLARE(String, query_cache_tag, "", R"( A string which acts as a label for [query cache](/concepts/features/performance/caches/query-cache) entries. The same queries with different tags are considered different by the query cache. Possible values: - Any string )", 0, \ {"24.8", "", "", "New setting for labeling query cache settings."}) \ DECLARE(Bool, enable_sharing_sets_for_mutations, true, R"( Allow sharing set objects build for IN subqueries between different tasks of the same mutation. This reduces memory usage and CPU consumption )", 0) \ DECLARE(Bool, use_query_condition_cache, true, R"( Enable the [query condition cache](/concepts/features/performance/caches/query-condition-cache). The cache stores ranges of granules in data parts which do not satisfy the condition in the `WHERE` clause, and reuse this information as an ephemeral index for subsequent queries. Possible values: - 0 - Disabled - 1 - Enabled )", 0, \ {"25.4", false, true, "A new optimization"}, \ {"25.3", false, false, "New setting."}) \ DECLARE(Bool, use_query_condition_cache_for_top_k, true, R"( Enable the [query condition cache](/concepts/features/performance/caches/query-condition-cache) for queries that use the `ORDER BY LIMIT n` (TopK) optimization (dynamic filtering or skip-index based). When disabled, such reads neither consult nor populate the cache. Reads of Parquet files that use the threshold only to skip row groups by their statistics (a `String` sort column with `use_top_k_dynamic_filtering_for_variable_length_types` disabled) use the cache like reads without TopK, whatever the value of this setting. Such queries can drop granules during execution depending on the running threshold, so their cache entries are partitioned by the TopK plan parameters and by the set of parts read (for a `File` table, by the set of files read and their versions; for a data lake table, by its snapshot; for object storage, by the set of objects read and their ETags). This setting has no effect unless `use_query_condition_cache` is also enabled. Possible values: - 0 - Disabled - 1 - Enabled )", 0, \ {"26.8", false, true, "New setting to gate the query condition cache for `ORDER BY ... LIMIT n` (TopK) reads; enabled by default. The gate is disabled in 26.7, so `compatibility` with an earlier version keeps it off."}) \ DECLARE(Bool, use_query_condition_cache_for_time_conditions, false, R"( Experimental. Enable the [query condition cache](/concepts/features/performance/caches/query-condition-cache) for conditions that involve the current time, e.g. `WHERE time >= now() - INTERVAL 10 DAY`, when reading from `MergeTree` tables. Reads from files and object storage (`file`, `s3`, and similar) use the query condition cache only for deterministic conditions and are not affected by this setting. Such conditions are non-deterministic (they change with the clock), so they cannot be cached directly. Instead, a deterministic condition is derived from them by rounding the folded current-time constant onto a time grid, e.g. `WHERE time >= '2026-08-09 12:34:56'` becomes `WHERE time >= '2026-08-09 00:00:00'` (rounding down for cache reads, up for cache writes, which keeps the cache sound). The grid step is proportional to the distance between the constant and the current time (see [`query_condition_cache_time_condition_grid_factor`](#query_condition_cache_time_condition_grid_factor)), clamped to between one second and one day. If the constant is already aligned to the grid (e.g. `WHERE time >= today() - 10` or `WHERE time >= toStartOfDay(now())`), the cache is effective for the whole grid cell, e.g. until the end of the day. Otherwise, the cache is reused only for lower bounds on the time, e.g. `WHERE time >= now() - INTERVAL 10 DAY`: cache entries written during one grid cell are used during the next one. An unaligned upper bound such as `WHERE time < now()`, alone or as a part of a sliding window like `WHERE time >= now() - INTERVAL 10 DAY AND time < now()`, is not reused by later queries, because their condition is not contained in the condition of the earlier ones. This setting has no effect unless `use_query_condition_cache` is also enabled. Possible values: - 0 - Disabled - 1 - Enabled )", EXPERIMENTAL, \ {"26.11", false, false, "Marked experimental and disabled by default, as in the 26.10 release."}, \ {"26.10", false, false, "New experimental setting to let the query condition cache serve conditions that involve the current time (e.g. `WHERE time >= now() - INTERVAL 10 DAY`) by deriving a deterministic condition with the time constant rounded onto a grid; disabled by default."}) \ DECLARE(Float, query_condition_cache_time_condition_grid_factor, 1.0, R"( For conditions involving the current time in the [query condition cache](/concepts/features/performance/caches/query-condition-cache) of `MergeTree` tables (see [`use_query_condition_cache_for_time_conditions`](#use_query_condition_cache_for_time_conditions)): the size of the grid onto which time constants are rounded, as a fraction of the distance between the constant and the current time. For example, with the default factor 1.0, the constant in `WHERE time >= now() - INTERVAL 10 DAY` is rounded onto a one day grid (capped at one day), and the constant in `WHERE time >= now() - INTERVAL 1 HOUR` onto a one hour grid. Smaller values keep the derived condition closer to the original one (less over-reading near the boundary) at the cost of the cache key rotating more frequently. The grid step is clamped to at least one second, so a small factor makes the derived condition converge to the original one instead of disabling it. Values less than or equal to 0 disable the derivation entirely. )", EXPERIMENTAL, \ {"26.10", 1., 1., "New experimental setting: the grid step used when deriving deterministic conditions from conditions involving the current time for the query condition cache, as a fraction of the distance between the time constant and the current time."}) \ DECLARE(Bool, enable_shared_storage_snapshot_in_query, true, R"( If enabled, all subqueries within a single query will share the same StorageSnapshot for each table. This ensures a consistent view of the data across the entire query, even if the same table is accessed multiple times. This is required for queries where internal consistency of data parts is important. Example: ```sql SELECT count() FROM events WHERE (_part, _part_offset) IN ( SELECT _part, _part_offset FROM events WHERE user_id = 42 ) ``` Without this setting, the outer and inner queries may operate on different data snapshots, leading to incorrect results. Possible values: - 0 - Disabled - 1 - Enabled )", 0, \ {"25.12", false, true, "Enable share storage snapshot in query by default"}, \ {"25.6", false, false, "A new setting to share storage snapshot in query"}) \ DECLARE(UInt64, merge_tree_storage_snapshot_sleep_ms, 0, R"( Inject artificial delay (in milliseconds) when creating a storage snapshot for MergeTree tables. Used for testing and debugging purposes only. Possible values: - 0 - No delay (default) - N - Delay in milliseconds )", 0, \ {"25.6", 0, 0, "A new setting to debug storage snapshot consistency in query"}) \ DECLARE(Bool, optimize_rewrite_sum_if_to_count_if, true, R"( Rewrite sumIf() and sum(if()) function countIf() function when logically equivalent )", 0, \ {"24.4", false, true, "Only available for the analyzer, where it works correctly"}) \ DECLARE(Bool, optimize_empty_string_comparisons, true, R"( Convert expressions like col = '' or '' = col into empty(col), and col != '' or '' != col into notEmpty(col), only when col is of String or FixedString type. )", 0, \ {"25.10", false, true, "A new setting."}) \ DECLARE(Bool, optimize_rewrite_aggregate_function_with_if, true, R"( Rewrite aggregate functions with if expression as argument when logically equivalent. For example, `avg(if(cond, col, null))` can be rewritten to `avgOrNullIf(cond, col)`. It may improve performance. )", 0) \ DECLARE(Bool, optimize_rewrite_array_exists_to_has, true, R"( Rewrite arrayExists() functions to has() when logically equivalent. For example, arrayExists(x -> x = 1, arr) can be rewritten to has(arr, 1) )", 0, \ {"26.4", false, true, "Enable arrayExists to has rewrite optimization by default, now that type compatibility is checked before rewriting."}) \ DECLARE(Bool, optimize_rewrite_array_filter_length_to_array_count, true, R"( Rewrite `length(arrayFilter(func, arr))` to `arrayCount(func, arr)`. `arrayFilter` builds an array of the matching elements only for `length` to throw it away, while `arrayCount` just counts them. )", 0, \ {"26.10", false, true, "New setting to rewrite `length(arrayFilter(func, arr))` into `arrayCount(func, arr)`, which does not build the filtered array."}) \ DECLARE(Bool, optimize_rewrite_has_to_in, true, R"( Rewrite `has` functions to `IN` when the first argument is a constant array. For example, `has([1, 2, 3], x)` can be rewritten to `x IN [1, 2, 3]` for better performance with constant arrays )", 0, \ {"26.6", false, true, "New setting"}) \ DECLARE(Bool, optimize_dictget_tuple_element, true, R"( Rewrite `tupleElement(dictGet('dict', ('a', 'b', 'c'), key), 2)` into `dictGet('dict', 'b', key)` to avoid fetching unnecessary dictionary attributes. Supports positional (`.1`, `.2`, ...) and named (`.b`) access, and also applies to `dictGetOrDefault` when the default argument is a constant tuple or a `tuple(...)` of constants. )", 0, \ {"26.5", false, true, "Rewrite tupleElement(dictGet(..., tuple_of_attrs, ...), N) into a single-attribute dictGet call."}) \ DECLARE(Bool, optimize_rewrite_like_perfect_affix, true, R"( Rewrite LIKE expressions with perfect prefix or suffix (e.g. `col LIKE 'ClickHouse%'`) to startsWith or endsWith functions (e.g. `startsWith(col, 'ClickHouse')`). )", 0, \ {"25.10", false, true, "New setting"}) \ DECLARE(Bool, execute_exists_as_scalar_subquery, true, R"( Execute non-correlated EXISTS subqueries as scalar subqueries. As for scalar subqueries, the cache is used, and the constant folding applies to the result. Cloud default value: `0`. )", 0, \ {"25.8", false, true, "New setting"}) \ DECLARE(Bool, optimize_rewrite_regexp_functions, true, R"( Rewrite regular expression related functions into simpler and more efficient forms )", 0, \ {"25.8", false, true, "A new setting"}) \ DECLARE(UInt64, insert_shard_id, 0, R"( If not `0`, specifies the shard of [Distributed](/reference/engines/table-engines/special/distributed) table into which the data will be inserted synchronously. If `insert_shard_id` value is incorrect, the server will throw an exception. To get the number of shards on `requested_cluster`, you can check server config or use this query: ```sql SELECT uniq(shard_num) FROM system.clusters WHERE cluster = 'requested_cluster'; ``` Possible values: - 0 — Disabled. - Any number from `1` to `shards_num` of corresponding [Distributed](/reference/engines/table-engines/special/distributed) table. **Example** Query: ```sql CREATE TABLE x AS system.numbers ENGINE = MergeTree ORDER BY number; CREATE TABLE x_dist AS x ENGINE = Distributed('test_cluster_two_shards_localhost', currentDatabase(), x); INSERT INTO x_dist SELECT * FROM numbers(5) SETTINGS insert_shard_id = 1; SELECT * FROM x_dist ORDER BY number ASC; ``` Result: ```text ┌─number─┐ │ 0 │ │ 0 │ │ 1 │ │ 1 │ │ 2 │ │ 2 │ │ 3 │ │ 3 │ │ 4 │ │ 4 │ └────────┘ ``` )", 0) \ \ DECLARE(Bool, collect_hash_table_stats_during_aggregation, true, R"( Enable collecting hash table statistics to optimize memory allocation )", 0) \ DECLARE(UInt64, max_size_to_preallocate_for_aggregation, 1'000'000'000'000, R"( For how many elements it is allowed to preallocate space in all hash tables in total before aggregation )", 0, \ {"24.12", 100'000'000, 1'000'000'000'000, "Enable optimisation for bigger tables."}, \ {"22.12", 10'000'000, 100'000'000, "This optimizes performance"}) \ \ DECLARE(Bool, collect_hash_table_stats_during_joins, true, R"( Enable collecting hash table statistics to optimize memory allocation )", 0, \ {"24.7", false, true, "New setting."}) \ DECLARE(Bool, use_hash_table_stats_for_join_reordering, true, R"( Enable using collected hash table statistics for cardinality estimation during join reordering )", 0, \ {"26.1", true, true, "New setting. Previously mirrored 'collect_hash_table_stats_during_joins' setting."}) \ DECLARE(UInt64, max_size_to_preallocate_for_joins, 1'000'000'000'000, R"( For how many elements it is allowed to preallocate space in all hash tables in total before join )", 0, \ {"24.12", 100'000'000, 1'000'000'000'000, "Enable optimisation for bigger tables."}, \ {"24.7", 0, 100'000'000, "New setting."}) \ \ DECLARE(Bool, kafka_disable_num_consumers_limit, false, R"( Disable limit on kafka_num_consumers that depends on the number of available CPU cores. )", 0) \ DECLARE_WITH_ALIAS(Bool, allow_kafka_offsets_storage_in_keeper, false, R"( Allow storing Kafka related offsets in ClickHouse Keeper. When enabled, a ClickHouse Keeper path and replica name can be specified to the Kafka table engine. As a result instead of the regular Kafka engine, a new type of storage engine will be used that stores the committed offsets primarily in ClickHouse Keeper )", EXPERIMENTAL, allow_experimental_kafka_offsets_storage_in_keeper, \ {"26.9", false, false, "Added an alias for setting `allow_experimental_kafka_offsets_storage_in_keeper`."}, \ {"24.8", false, false, "Allow the usage of experimental Kafka storage engine that stores the committed offsets in ClickHouse Keeper. At the time the setting was named `allow_experimental_kafka_offsets_storage_in_keeper`, which is now an alias of it."}) \ DECLARE(Bool, enable_software_prefetch_in_aggregation, true, R"( Enable use of software prefetch in aggregation )", 0) \ DECLARE(Bool, allow_aggregate_partitions_independently, true, R"( Enable independent aggregation of partitions on separate threads when partition key suits group by key. Beneficial when number of partitions close to number of cores and partitions have roughly the same size. Heuristics in `ReadFromMergeTree` automatically disable the optimization for unfavorable layouts (too few partitions, too many partitions, or significantly skewed partition sizes); see `force_aggregate_partitions_independently` to bypass those checks. )", 0, \ {"26.7", false, true, "Enable independent per-partition aggregation by default when the partition key suits the GROUP BY key. The existing runtime heuristics in `ReadFromMergeTree::requestOutputEachPartitionThroughSeparatePortForAggregation` already skip the optimization when the partition layout is unfavorable (too few partitions, too many partitions, or significantly skewed partition sizes), so enabling the setting is safe in the cases where it would otherwise be a no-op."}) \ DECLARE(Bool, force_aggregate_partitions_independently, false, R"( Force the use of optimization when it is applicable, but heuristics decided not to use it )", 0) \ DECLARE(Bool, allow_limit_by_partitions_independently, true, R"( Enable independent `LIMIT BY` evaluation per partition on separate threads when the partition expression is a deterministic function of the `LIMIT BY` columns. )", 0, \ {"26.6", false, true, "New setting to enable independent per-partition evaluation of `LIMIT BY` when the partition expression is a deterministic function of the `LIMIT BY` columns."}) \ DECLARE(Bool, allow_creating_set_partitions_independently, true, R"( Enable parallel per-partition pre-deduplication of the subquery result when building the set for `IN (subquery)`, when the partition expression of the subquery's `MergeTree` table is a deterministic function of the subquery output columns. Each partition is read through a separate stream and deduplicated independently, so the single set-filling transform only hashes unique rows. Not applied with `FINAL`, parallel replicas, or `GLOBAL IN`. The optimization requests the per-partition read itself only when the data has more than one partition and the largest partition holds at most twice the rows of the average partition (see [force_creating_set_partitions_independently](#force_creating_set_partitions_independently) to bypass the skew check); when the streams are already partition-disjoint because another per-partition feature split them (for example per-partition `LIMIT BY`), the pre-deduplication is applied regardless, since the read layout is already fixed. While the set is being built, the per-stream deduplication tables together hold roughly one extra copy of the unique keys. )", 0, \ {"26.8", false, true, "New setting to enable parallel per-partition pre-deduplication of the subquery result when building the set for `IN (subquery)`, when the partition expression is a deterministic function of the subquery output columns."}) \ DECLARE(Bool, force_creating_set_partitions_independently, false, R"( Force per-partition pre-deduplication for `IN (subquery)` set building when it is applicable, but the partition-skew check (largest partition more than twice the average) decided not to use it. Only bypasses the skew check of [allow_creating_set_partitions_independently](#allow_creating_set_partitions_independently); the remaining conditions still apply. )", 0, \ {"26.8", false, false, "New setting to force per-partition pre-deduplication for `IN (subquery)` set building even when the partition-skew check would skip it."}) \ DECLARE(Bool, allow_distinct_partitions_independently, true, R"( Enable independent `DISTINCT` evaluation per partition on separate threads when the partition expression is a deterministic function of the `DISTINCT` columns, skipping the cross-stream merge. Beneficial when the number of partitions is close to the number of cores and partitions have roughly the same size; otherwise a cost heuristic skips it, see [max_number_of_partitions_for_independent_distinct](#max_number_of_partitions_for_independent_distinct) and [force_distinct_partitions_independently](#force_distinct_partitions_independently). Not applied with `FINAL` or parallel replicas. [max_rows_in_distinct](#max_rows_in_distinct) and [max_bytes_in_distinct](#max_bytes_in_distinct) apply to the combined size of all partition sets while the streams remain separate. )", 0, \ {"26.8", false, true, "New setting to enable independent per-partition evaluation of `DISTINCT` when the partition expression is a deterministic function of the `DISTINCT` columns."}) \ DECLARE(Bool, force_distinct_partitions_independently, false, R"( Force independent `DISTINCT` evaluation per partition when it is applicable, but the cost heuristic decided not to use it. Only bypasses the cost heuristic of [allow_distinct_partitions_independently](#allow_distinct_partitions_independently); the remaining conditions still apply. )", 0, \ {"26.8", false, false, "New setting to force independent per-partition evaluation of `DISTINCT` even when the cost heuristic would skip it."}) \ DECLARE(Bool, optimize_uniq_exact_radix_partitioning, true, R"( Compute a single `uniqExact` (and `count(DISTINCT)`, which uses it by default) of a query without `GROUP BY` by partitioning the values by their hash instead of merging per-thread hash sets. Every thread routes its values into the partitions, then the partitions are deduplicated in parallel, each in a hash set small enough to stay in the CPU cache, and the result is the sum of their sizes. Applies to a single argument of a numeric type up to 64 bits, `Date`, `Date32`, `DateTime`, `Enum`, `IPv4`, `IPv6`, `UUID`, 128-bit integers, `String`, `FixedString`, or `Nullable` of them, when the result is finalized on the same server. A thread keeps inserting into its own small set, as the ordinary aggregation does, until the set outgrows the CPU cache, so the routing is only engaged for high-cardinality inputs, and a thread goes back to its own set if most of its values turn out to be repeated. )", 0, \ {"26.11", false, true, "New setting to compute a single `uniqExact` or `count(DISTINCT)` without `GROUP BY` by partitioning the values by their hash instead of merging per-thread hash sets."}) \ DECLARE(Bool, allow_preliminary_distinct_abandoning, true, R"( Let the preliminary (per-stream) `DISTINCT` give up deduplicating mostly-unique input, freeing its hash table and passing the remaining rows through. The preliminary `DISTINCT` is best-effort by design - duplicates from different streams pass through it even when it deduplicates - and the final `DISTINCT` deduplicates its output again, so abandoning gives up the removal of almost nothing and saves the memory and hashing of a second copy of the unique keys. Not applied when the preliminary `DISTINCT` carries a limit hint (a plain `LIMIT` with no subsequent ordering). )", 0, \ {"26.9", false, true, "New setting that lets the preliminary `DISTINCT` give up deduplicating mostly-unique input, because the final `DISTINCT` deduplicates its output again."}) \ DECLARE(Bool, allow_parallel_distinct, true, R"( Evaluate the final `DISTINCT` on multiple threads by partitioning input streams by the hash of the `DISTINCT` columns. Equal keys reach the same stream, allowing each partition to be deduplicated independently. Unlike [allow_distinct_partitions_independently](#allow_distinct_partitions_independently), this does not require a relationship between the table's partition key and the `DISTINCT` columns. The number of input streams and hash partitions is capped independently of `max_threads` to bound the cost of splitting blocks and connecting streams. Hash partitioning is not applied to globally sorted input because `DISTINCT` preserves that order. [max_rows_in_distinct](#max_rows_in_distinct) and [max_bytes_in_distinct](#max_bytes_in_distinct) apply to the combined size of all hash partitions. `DISTINCT` without `ORDER BY` has no defined row order, so this optimization may return the same distinct values in a different order. As a result, `LIMIT`, `OFFSET`, or `LIMIT BY` over unordered `DISTINCT` results may select a different subset of rows. )", 0, \ {"26.11", false, true, "New setting to evaluate final `DISTINCT` in parallel using hash partitioning."}) \ DECLARE(Bool, allow_window_partitions_independently, true, R"( Enable independent evaluation of window functions per partition on separate threads when the partition expression of the `MergeTree` table is a deterministic function of the window `PARTITION BY` columns. Each partition is read through a separate stream, sorted independently by the window sort description, and processed by its own window transform, skipping the hash scatter that ordinarily reshuffles every row across threads. Beneficial when the number of partitions is close to the number of cores and partitions have roughly the same size; otherwise a cost heuristic skips it, see [max_number_of_partitions_for_independent_window](#max_number_of_partitions_for_independent_window) and [force_window_partitions_independently](#force_window_partitions_independently). Not applied with `FINAL` or parallel replicas. )", 0, \ {"26.8", false, true, "New setting to evaluate window functions per partition independently (skipping the hash scatter) when the partition expression is a deterministic function of the window `PARTITION BY` columns."}) \ DECLARE(Bool, force_window_partitions_independently, false, R"( Force independent evaluation of window functions per partition when it is applicable, but the cost heuristic decided not to use it. Only bypasses the cost heuristic of [allow_window_partitions_independently](#allow_window_partitions_independently); the remaining conditions still apply. )", 0, \ {"26.8", false, false, "New setting to force independent per-partition evaluation of window functions even when the cost heuristic would skip it."}) \ DECLARE(UInt64, max_number_of_partitions_for_independent_aggregation, 128, R"( Maximal number of partitions in table to apply independent aggregation per partition. Part of the cost heuristic of [allow_aggregate_partitions_independently](#allow_aggregate_partitions_independently). )", 0) \ DECLARE(UInt64, max_number_of_partitions_for_independent_distinct, 128, R"( Maximal number of partitions in table to apply independent `DISTINCT` per partition. Part of the cost heuristic of [allow_distinct_partitions_independently](#allow_distinct_partitions_independently). )", 0, \ {"26.8", 128, 128, "New setting: maximal number of partitions to apply independent per-partition `DISTINCT`."}) \ DECLARE(UInt64, max_number_of_partitions_for_independent_window, 128, R"( Maximal number of partitions in table to apply independent evaluation of window functions per partition. Part of the cost heuristic of [allow_window_partitions_independently](#allow_window_partitions_independently). )", 0, \ {"26.8", 128, 128, "New setting: maximal number of partitions to apply independent per-partition evaluation of window functions."}) \ DECLARE(Float, min_hit_rate_to_use_consecutive_keys_optimization, 0.5, R"( Minimal hit rate of a cache which is used for consecutive keys optimization in aggregation to keep it enabled )", 0) \ \ DECLARE(Bool, engine_file_empty_if_not_exists, false, R"( Allows to select data from a file engine table without file. Possible values: - 0 — `SELECT` throws exception. - 1 — `SELECT` returns empty result. )", 0) \ DECLARE(Bool, engine_file_truncate_on_insert, false, R"( Enables or disables truncate before insert in [File](/reference/engines/table-engines/special/file) engine tables. 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, engine_file_allow_create_multiple_files, false, R"( Enables or disables creating a new file on each insert in file engine tables if the format has the suffix (`JSON`, `ORC`, `Parquet`, etc.). If enabled, on each insert a new file will be created with a name following this pattern: `data.Parquet` -> `data.1.Parquet` -> `data.2.Parquet`, 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, engine_file_skip_empty_files, false, R"( Enables or disables skipping empty files in [File](/reference/engines/table-engines/special/file) 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, engine_url_skip_empty_files, false, R"( Enables or disables skipping empty files in [URL](/reference/engines/table-engines/special/url) 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, enable_url_encoding, false, R"( Allows to enable/disable decoding/encoding path in uri in [URL](/reference/engines/table-engines/special/url) engine tables. Disabled by default. )", 0, \ {"25.5", true, false, "Changed existing setting's default value"}) \ DECLARE(String, url_base, "", R"( The base URL used to resolve relative URLs in the [url](/reference/functions/table-functions/url) table function and the [URL](/reference/engines/table-engines/special/url) table engine. When set, relative URLs are resolved as follows: - Path-relative URL (e.g. `data.csv`): merged with the base URL path per RFC 3986. Everything after the last `/` in the base path is replaced by the relative URL, so a trailing slash matters: `https://example.com/dir/` + `data.csv` = `https://example.com/dir/data.csv`, but `https://example.com/dir` + `data.csv` = `https://example.com/data.csv`. If the base has no path (e.g. `https://example.com`), a `/` is inserted: `https://example.com/data.csv`. Dot segments (`./` and `../`) in the relative URL are normalized: `https://example.com/dir/` + `../a.csv` = `https://example.com/a.csv`. - Host-relative URL (e.g. `/test/data.csv`): resolved against the base URL's scheme and host. - Scheme-relative URL (e.g. `//other.com/test/data.csv`): resolved using the base URL's scheme. - Query-only reference (e.g. `?x=1`): appended to the base URL path (replacing any existing query/fragment). - Fragment-only reference (e.g. `#frag`): appended to the base URL, preserving any query string (replacing any existing fragment). - Empty reference: returns the base URL without fragment. - If the base URL is only a scheme (e.g. `file://`), a path-relative URL is appended to it directly: `file://` + `data.csv` = `file://data.csv`, which for the `file://` scheme means a path relative to the user_files directory (the current directory for clickhouse-local). Dot segments are kept as-is in this case, so the target engine resolves them against its own base directory. For example, if `url_base` is `https://example.com/def/`, then: - `data.csv` resolves to `https://example.com/def/data.csv` - `/test/data.csv` resolves to `https://example.com/test/data.csv` - `//other.com/test/data.csv` resolves to `https://other.com/test/data.csv` When the relative URL comes from a [named collection](/concepts/features/configuration/server-config/named-collections), resolving it counts as an override of the `url` key of the collection and requires the `SHOW NAMED COLLECTIONS SECRETS` privilege on that collection. )", 0, \ {"26.5", "", "", "New setting to specify the base URL for resolving relative URLs in the url table function and URL table engine."}) \ DECLARE(String, s3_base, "", R"( The base URL used to resolve relative URLs in the [s3](/reference/functions/table-functions/s3) table function and the [S3](/reference/engines/table-engines/integrations/s3) table engine, as well as in the table functions that share their configuration (`s3Cluster`, `gcs`, `oss`). When set, a URL without a scheme is resolved against `s3_base` per RFC 3986, using the same rules as [url_base](#url_base). URLs that already contain a scheme are used as-is. For example, if `s3_base` is `s3://clickhouse-public-datasets/`, then `s3('hits_compatible/hits.csv')` reads `s3://clickhouse-public-datasets/hits_compatible/hits.csv`. The base URL can use any form accepted by the `s3` table function, e.g. `s3://bucket/`, `https://bucket.s3.amazonaws.com/` or `https://endpoint/bucket/`. When the relative URL comes from a [named collection](/concepts/features/configuration/server-config/named-collections), resolving it counts as an override of the `url` key of the collection and requires the `SHOW NAMED COLLECTIONS SECRETS` privilege on that collection. )", 0, \ {"26.8", "", "", "New setting to specify the base URL for resolving relative URLs in the s3 table function and the S3 table engine."}) \ DECLARE(UInt64, database_replicated_initial_query_timeout_sec, 300, R"( Sets how long initial DDL query should wait for Replicated database to process previous DDL queue entries in seconds. Possible values: - Positive integer. - 0 — Unlimited. )", 0) \ DECLARE(Bool, database_replicated_enforce_synchronous_settings, false, R"( Enforces synchronous waiting for some queries (see also database_atomic_wait_for_drop_and_detach_synchronously, mutations_sync, alter_sync). Not recommended to enable these settings. )", 0) \ DECLARE(UInt64, max_distributed_depth, 5, R"( Limits the maximum depth of recursive queries for [Distributed](/reference/engines/table-engines/special/distributed) tables. If the value is exceeded, the server throws an exception. Possible values: - Positive integer. - 0 — Unlimited depth. )", 0) \ DECLARE(Bool, database_replicated_always_detach_permanently, false, R"( Execute DETACH TABLE as DETACH TABLE PERMANENTLY if database engine is Replicated )", 0) \ DECLARE(Bool, database_replicated_allow_only_replicated_engine, false, R"( Allow creating a table in a database with the `Replicated` engine only if the table either replicates its own data stored on disk or does not store its own data on disk. This restriction applies only to table-owned on-disk data, including data on remote disks. It does not guarantee the durability of in-memory data or data managed by external systems. For example, `ReplicatedMergeTree`, in-memory engines such as `Memory` and `Buffer`, metadata-only engines such as `Merge` and `Alias`, and external-storage or data lake engines such as `S3` and `AzureBlobStorage` are allowed. Non-replicated engines that store table data on disk, such as `MergeTree`, `Log`, `File`, and `Set`, are rejected, including when their writable storage policy uses remote disks. `Set` and `Join` tables created with `SETTINGS persistent = 0` keep their data only in memory and are allowed. `Distributed`, `Remote`, and `RemoteSecure` tables are allowed. Their optional local background `INSERT` queue is a transient send buffer, not data of the table itself. It is not replicated, and setting `distributed_foreground_insert = 1` avoids the queue. Cloud default value: `1`. )", 0) \ DECLARE(UInt64, database_replicated_allow_replicated_engine_arguments, 0, R"( 0 - Don't allow to explicitly specify ZooKeeper path and replica name for *MergeTree tables in Replicated databases. 1 - Allow. 2 - Allow, but ignore the specified path and use default one instead. 3 - Allow and don't log a warning. )", 0, \ {"24.9", 1, 0, "Don't allow explicit arguments by default"}) \ DECLARE(UInt64, database_replicated_allow_explicit_uuid, 0, R"( 0 - Don't allow to explicitly specify UUIDs for tables in Replicated databases. 1 - Allow. 2 - Allow, but ignore the specified UUID and generate a random one instead. )", 0, \ {"24.9", 1, 0, "Added a new setting to disallow explicitly specifying table UUID"}) \ DECLARE(Bool, database_replicated_allow_heavy_create, false, R"( Allow long-running DDL queries (CREATE AS SELECT and POPULATE) in Replicated database engine. Note that it can block DDL queue for a long time. )", 0, \ {"24.7", true, false, "Long-running DDL queries (CREATE AS SELECT and POPULATE) for Replicated database engine was forbidden"}) \ DECLARE(UInt64, database_shared_drop_table_delay_seconds, 8 * 60 * 60, R"( The delay in seconds before a dropped table is actually removed from a Shared database. This allows to recover the table within this time using `UNDROP TABLE` statement. )", 0, \ {"25.11", 8 * 60 * 60, 8 * 60 * 60, "New setting."}) \ DECLARE(Bool, cloud_mode, false, R"( Cloud mode Cloud default value: `1`. )", 0) \ DECLARE(UInt64, cloud_mode_engine, 1, R"( The engine family allowed in Cloud. - 0 - allow everything - 1 - rewrite DDLs to use *ReplicatedMergeTree - 2 - rewrite DDLs to use SharedMergeTree - 3 - rewrite DDLs to use SharedMergeTree except when explicitly passed remote disk is specified - 4 - same as 3, plus additionally use Alias instead of Distributed (the Alias table will point to the destination table of the Distributed table, so it will use the corresponding local table) UInt64 to minimize public part Cloud default value: `2`. )", 0) \ DECLARE(DistributedDDLOutputMode, distributed_ddl_output_mode, DistributedDDLOutputMode::THROW, R"( Sets format of distributed DDL query result. Possible values: - `throw` — Returns result set with query execution status for all hosts where query is finished. If query has failed on some hosts, then it will rethrow the first exception. If query is not finished yet on some hosts and [distributed_ddl_task_timeout](#distributed_ddl_task_timeout) exceeded, then it throws `TIMEOUT_EXCEEDED` exception. - `none` — Is similar to throw, but distributed DDL query returns no result set. - `null_status_on_timeout` — Returns `NULL` as execution status in some rows of result set instead of throwing `TIMEOUT_EXCEEDED` if query is not finished on the corresponding hosts. - `never_throw` — Do not throw `TIMEOUT_EXCEEDED` and do not rethrow exceptions if query has failed on some hosts. - `none_only_active` - similar to `none`, but doesn't wait for inactive replicas of the `Replicated` database. Note: with this mode it's impossible to figure out that the query was not executed on some replica and will be executed in background. - `null_status_on_timeout_only_active` — similar to `null_status_on_timeout`, but doesn't wait for inactive replicas of the `Replicated` database - `throw_only_active` — similar to `throw`, but doesn't wait for inactive replicas of the `Replicated` database Cloud default value: `none_only_active`. )", 0) \ DECLARE(UInt64, distributed_ddl_entry_format_version, 5, R"( Compatibility version of distributed DDL (ON CLUSTER) queries. Use a lower value to keep older servers in the cluster able to execute the queries. Servers do not execute entries with versions `1` and `2`. Older servers write those for the setting values `1`, `2` and `3`, so before upgrading set this setting to at least `4` on all servers and wait until the distributed DDL queue is processed. Possible values: - `3` — The same as `4`. It is written as `4`, because older servers reject entries with version `3`. - `4` — The entry carries the settings changed in the session and the OpenTelemetry tracing context, and `CREATE` queries are normalized on the initiator. - `5` — Also preserves the `initial_query_id` of the query. - `6` — Also carries whether the query is a part of `BACKUP` or `RESTORE`. - `7` — Also carries the UUID of the parent table, which a `Replicated` database uses to execute the query only if the table exists. - `8` — Also carries the user and the roles of the initiator, which the hosts use with the server setting `distributed_ddl_use_initial_user_and_roles`. Cloud default value: `6`. )", 0) \ \ DECLARE(UInt64, external_storage_max_read_rows, 0, R"( Limit maximum number of rows when table with external engine should flush history data. Now supported only for MySQL table engine, database engine, and dictionary. If equal to 0, this setting is disabled )", 0) \ DECLARE(UInt64, external_storage_max_read_bytes, 0, R"( Limit maximum number of bytes when table with external engine should flush history data. Now supported only for MySQL table engine, database engine, and dictionary. If equal to 0, this setting is disabled )", 0) \ DECLARE(UInt64, external_storage_connect_timeout_sec, DBMS_DEFAULT_CONNECT_TIMEOUT_SEC, R"( Connect timeout in seconds. Now supported only for MySQL )", 0) \ DECLARE(UInt64, external_storage_rw_timeout_sec, DBMS_DEFAULT_RECEIVE_TIMEOUT_SEC, R"( Read/write timeout in seconds. Now supported only for MySQL )", 0) \ DECLARE(Bool, external_storage_push_down_limit, true, R"( Allow to push the query's `LIMIT` clause down into the query sent to an external database (such as MySQL, PostgreSQL or SQLite). The push-down is not performed for the generic ODBC/JDBC bridges, because they do not expose the remote `LIMIT` syntax, and some of the supported databases do not accept a `LIMIT` clause at all. The `LIMIT` is pushed down only when it is guaranteed to be safe, i.e. when every clause that logically applies before it is copied to the external query without changes. Precisely, the query must be a plain single-table `SELECT`: - there is no `JOIN`, `ARRAY JOIN`, `SAMPLE` or `FINAL` (otherwise rows could be dropped or transformed locally, so pre-limiting is unwanted); - the `WHERE` clause, if any, is fully compatible and copied into the rewritten query unchanged (otherwise filtering after the remote `LIMIT` would drop some rows); - there is no other clause or modifier (like `DISTINCT`, `GROUP BY`, `ORDER BY`, `LIMIT BY`, `WITH TIES`, etc.) that may break the remote pre-limiting logic due to data reordering, aggregation or filtration; - an `OFFSET` is allowed: it is applied locally, so the rows it skips have to be read as well, and the limit sent to the external database is `offset + length`; - the `SELECT` list maps one source row to one result row, i.e. it contains no aggregate functions, window functions or `arrayJoin` (also spelled `unnest`) (they are evaluated locally over all the rows read from the external table); - there is no filter that is applied locally on top of the rows read from the external table, such as a row policy or `additional_table_filters` (such a filter runs before the `LIMIT`, so pre-limiting remotely could discard rows that it would have kept). This reduces the amount of data read from and sent by the external database. Disable this setting to restore the previous behavior in case of compatibility issues. )", 0, \ {"26.10", false, true, "New setting to push the query's `LIMIT` down into the query sent to an external database when it is safe. previous_value=false so `compatibility` with versions before 26.10 restores the pre-existing behavior (no push-down)."}) \ \ DECLARE_WITH_ALIAS(Bool, allow_correlated_subqueries, true, R"( Allow to execute correlated subqueries. )", BETA, allow_experimental_correlated_subqueries, \ {"26.9", true, true, "Added an alias for setting `allow_experimental_correlated_subqueries`."}, \ {"25.8", false, true, "Mark correlated subqueries support as Beta. At the time the setting was named `allow_experimental_correlated_subqueries`, which is now an alias of it."}, \ {"25.4", false, false, "Added new setting to allow correlated subqueries execution. At the time the setting was named `allow_experimental_correlated_subqueries`, which is now an alias of it."}) \ \ DECLARE_WITH_ALIAS(Bool, enable_lateral_join, false, R"( Allow LATERAL JOIN syntax. When enabled, subqueries in the right side of a JOIN can reference columns from the left side, enabling correlated subqueries in the FROM clause (SQL standard LATERAL JOIN). )", EXPERIMENTAL, allow_experimental_lateral_join, \ {"26.11", false, false, "Added an alias for setting `allow_experimental_lateral_join`."}, \ {"26.10", false, false, "New setting to allow `LATERAL JOIN` syntax."}) \ \ DECLARE(SetOperationMode, union_default_mode, SetOperationMode::Unspecified, R"( Sets a mode for combining `SELECT` query results. The setting is only used when shared with [UNION](/reference/statements/select/union) without explicitly specifying the `UNION ALL` or `UNION DISTINCT`. Possible values: - `'DISTINCT'` — ClickHouse outputs rows as a result of combining queries removing duplicate rows. - `'ALL'` — ClickHouse outputs all rows as a result of combining queries including duplicate rows. - `''` — ClickHouse generates an exception when used with `UNION`. See examples in [UNION](/reference/statements/select/union). )", 0) \ DECLARE(SetOperationMode, intersect_default_mode, SetOperationMode::ALL, R"( Set default mode in INTERSECT query. Possible values: empty string, 'ALL', 'DISTINCT'. If empty, query without mode will throw exception. )", 0) \ DECLARE(SetOperationMode, except_default_mode, SetOperationMode::ALL, R"( Set default mode in EXCEPT query. Possible values: empty string, 'ALL', 'DISTINCT'. If empty, query without mode will throw exception. )", 0) \ DECLARE(UInt64, max_streams_for_union_step, 0, R"( Limits the number of simultaneously active data streams in a `UNION` step (applies to `UNION ALL`, to `UNION DISTINCT`, because it is implemented via a `UNION ALL` step followed by a `DISTINCT` step, and to a `Merge` table read with plan-based parallel replicas, which is expanded into a union of the reads from its underlying tables). When a `UNION` query has many subqueries, all of them open their read buffers at the same time, leading to memory usage proportional to the number of subqueries. This setting inserts `Concat` processors to narrow the pipeline so that at most this many streams are active at once, drastically reducing peak memory. The actual limit is the minimum of this value and `max_threads * max_streams_for_union_step_to_max_threads_ratio` (either one being 0 means it is ignored). When both are 0, no narrowing is applied. The limit is also not applied when the query plan requires each output stream of the `UNION` to stay individually sorted (for example, when the read-in-order optimization is applied across the `UNION`); in that case correctness of the ordering takes precedence and narrowing is skipped. )", 0, \ {"26.5", 0, 0, "New setting to limit the number of simultaneously active data streams in a UNION step to reduce peak memory usage."}) \ DECLARE(Float, max_streams_for_union_step_to_max_threads_ratio, 8, R"( This ratio multiplied by `max_threads` determines a limit on simultaneously active streams in a `UNION` step (applies to both `UNION ALL` and `UNION DISTINCT`). The actual limit is the minimum of this computed value and `max_streams_for_union_step` (either one being 0 means it is ignored). For example, with `max_threads = 8` and this ratio set to 1, at most 8 streams will be active. Set to 0 to disable this ratio-based limit. Like `max_streams_for_union_step`, the limit is not applied when the query plan requires each output stream of the `UNION` to stay individually sorted. )", 0, \ {"26.5", 0, 8, "New setting: the limit on simultaneously active streams in a UNION step is computed as min(max_streams_for_union_step, max_threads * max_streams_for_union_step_to_max_threads_ratio), either being 0 disables that input."}) \ DECLARE(Bool, optimize_aggregators_of_group_by_keys, true, R"( Eliminates min/max/any/anyLast aggregators of GROUP BY keys in SELECT section )", 0) \ DECLARE(Bool, optimize_injective_functions_in_group_by, true, R"( Replaces injective functions by it's arguments in GROUP BY section )", 0, \ {"24.1", false, true, "Replace injective functions by it's arguments in GROUP BY section in analyzer"}) \ DECLARE(Bool, optimize_group_by_function_keys, true, R"( Eliminates functions of other keys in GROUP BY section )", 0) \ DECLARE(Bool, optimize_limit_by_function_keys, true, R"( Eliminates functions of other keys in LIMIT BY section. Example: `LIMIT 5 BY x, f(x)` becomes `LIMIT 5 BY x`. )", 0, \ {"26.6", false, true, "New setting that eliminates LIMIT BY keys that are functions of other LIMIT BY keys."}) \ DECLARE(Bool, optimize_injective_functions_in_limit_by, true, R"( Replaces injective functions by their arguments in LIMIT BY section. Example: `LIMIT 5 BY toString(x)` becomes `LIMIT 5 BY x`. )", 0, \ {"26.6", false, true, "New setting that replaces injective functions by their arguments in the LIMIT BY keys."}) \ DECLARE(Bool, optimize_group_by_constant_keys, true, R"( Optimize GROUP BY when all keys in block are constant )", 0, \ {"23.9", false, true, "Optimize group by constant keys by default"}) \ DECLARE(Bool, optimize_constant_columns_after_filter, true, R"( Replace filtered columns with `ColumnConst` when an equality predicate proves that all passed values are equal to a constant. )", 0, \ {"26.11", false, true, "New setting to replace filtered columns with `ColumnConst` when an equality predicate proves that all passed values are equal to a constant."}) \ DECLARE(Bool, legacy_column_name_of_tuple_literal, false, R"( List all names of element of large tuple literals in their column names instead of hash. This settings exists only for compatibility reasons. It makes sense to set to 'true', while doing rolling update of cluster from version lower than 21.7 to higher. )", 0, \ {"21.7", true, false, "Add this setting only for compatibility reasons. It makes sense to set to 'true', while doing rolling update of cluster from version lower than 21.7 to higher"}) \ DECLARE(Bool, enable_named_columns_in_function_tuple, false, R"( Generate named tuples in function tuple() when all names are unique and can be treated as unquoted identifiers. )", 0, \ {"24.10", false, false, "Disabled pending usability improvements"}, \ {"24.7", false, false, "Generate named tuples in function tuple() when all names are unique and can be treated as unquoted identifiers."}) \ \ DECLARE(Bool, query_plan_enable_optimizations, true, R"( Toggles query optimization at the query plan level. This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed. Possible values: - 0 - Disable all optimizations at the query plan level - 1 - Enable optimizations at the query plan level (but individual optimizations may still be disabled via their individual settings) )", 0) \ DECLARE(UInt64, query_plan_max_optimizations_to_apply, 10'000, R"( Limits the total number of optimizations applied to query plan, see setting [query_plan_enable_optimizations](#query_plan_enable_optimizations). Useful to avoid long optimization times for complex queries. In the EXPLAIN PLAN query, stop applying optimizations after this limit is reached and return the plan as is. For regular query execution if the actual number of optimizations exceeds this setting, an exception is thrown. This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed. )", 0) \ DECLARE(Bool, query_plan_lift_up_array_join, true, R"( Toggles a query-plan-level optimization which moves ARRAY JOINs up in the execution plan. Only takes effect if setting [query_plan_enable_optimizations](#query_plan_enable_optimizations) is 1. This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed. Possible values: - 0 - Disable - 1 - Enable )", 0) \ DECLARE(Bool, query_plan_push_down_limit, true, R"( Toggles a query-plan-level optimization which moves LIMITs down in the execution plan. Only takes effect if setting [query_plan_enable_optimizations](#query_plan_enable_optimizations) is 1. This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed. Possible values: - 0 - Disable - 1 - Enable )", 0) \ DECLARE(Bool, query_plan_top_k_through_join, true, R"( Toggles a query-plan-level optimization which pushes `ORDER BY ... LIMIT n` down through a join when the sort key only references columns from the side preserved by the join (LEFT/RIGHT). Restricts how many rows the preserved-side input must produce before joining. Only takes effect if setting [query_plan_enable_optimizations](#query_plan_enable_optimizations) is 1. Possible values: - 0 - Disable - 1 - Enable )", 0, \ {"26.5", false, true, "New setting to enable a query-plan-level optimization that pushes ORDER BY ... LIMIT n through a LEFT/RIGHT join when the sort key only references the preserved side."}) \ DECLARE(Bool, query_plan_top_k_through_array_join, true, R"( Toggles a query-plan-level optimization which moves `ORDER BY ... LIMIT n` below an `ARRAY JOIN` when the sort key does not read a joined column. For an inner `ARRAY JOIN`, the optimization also adds a filter below the moved sort. This filter removes the rows whose arrays are all empty, because these rows give no output. Only takes effect if setting [query_plan_enable_optimizations](#query_plan_enable_optimizations) is 1. Possible values: - 0 - Disable - 1 - Enable )", 0, \ {"26.11", false, true, "New setting to move bounded sorting below `ARRAY JOIN` when its keys do not depend on expanded columns."}) \ DECLARE(Bool, query_plan_aggregation_bucket_top_k, true, R"( Toggles a query-plan-level optimization which, when a final aggregation feeds `ORDER BY` over the aggregation's outputs with `LIMIT n` and the plan proves the per-bucket selection exact, keeps only each two-level bucket's best n groups during the aggregation's final merge or conversion. The result is exact: a group outside its own bucket's best n has at least n groups ahead of it globally, so it cannot be in the global top n. For ordering by `count`, the optimization can select the best groups during the final conversion. For aggregates whose merged values can be bounded from their partial states, it can instead use a threshold merge (Fagin's Threshold Algorithm), which skips merging groups that cannot reach the top n. This supports `count`, `sum` of unsigned integers whose result is `UInt64` (`UInt8` to `UInt64` arguments; wide unsigned integers such as `UInt128` are excluded), and `uniqExact` in descending order, and `max` in descending and `min` in ascending order for integer, date, date-time, decimal, and enum types (floating point, `UUID`, `IPv4`, `IPv6`, `String`, `FixedString`, and other types are excluded). The `If` and `Null` combinators keep the threshold merge only for `count`, unsigned `sum`, and `uniqExact`, and only when the result is not nullable (for example `countIf`, `sumIf` of a non-`Nullable` argument, or `uniqExact` of a `Nullable` argument); `sum` and `sumIf` of a `Nullable` argument (whose result is `Nullable`), `maxIf`, `minIf`, and `max` or `min` of a `Nullable` argument use the ordinary merge. The algorithm is chosen automatically according to the aggregate, query shape, and distribution of partial states. A group outside its bucket's best n is neither merged nor finalized, so this is not only a performance toggle: the other aggregates of the query stop being merged and finalized on the groups that cannot reach the top n. A query that raised an exception while merging or finalizing one of those aggregates on such a group can return rows instead. Setting this to 0 keeps the previous behavior. Only takes effect if setting [query_plan_enable_optimizations](#query_plan_enable_optimizations) is 1. Possible values: - 0 - Disable - 1 - Enable )", 0, \ {"26.8", false, true, "New setting to toggle the plan optimization that materializes only each two-level bucket's best n groups when a final aggregation feeds ORDER BY over its outputs with LIMIT n and the per-bucket selection is provably exact."}) \ DECLARE(Bool, query_plan_aggregation_having_prefilter, true, R"( Toggles a query-plan-level optimization for `HAVING count() ` over a `GROUP BY`. While a two-level bucket of the aggregation result is converted to chunks, a group whose count cannot satisfy the bound is skipped before its key columns are materialized, instead of being materialized and then discarded by the filter above. Speeds up "groups above a threshold" queries over a high-cardinality `GROUP BY`, where most groups are discarded and the discarded keys are most of the conversion. A skipped group is neither filtered nor finalized, so this is not only a performance toggle: a `HAVING` conjunct written before the bound, and a sibling aggregate's finalization, stop being evaluated on the groups the bound rejects. A query that raised an exception from one of those can return rows instead, for example `HAVING throwIf(cnt = 3) = 0 AND count() > 3` over a `count() AS cnt`. Setting this to 0, or `compatibility` to a version below `26.10`, keeps the previous behavior. Only takes effect if setting [query_plan_enable_optimizations](#query_plan_enable_optimizations) is 1. Possible values: - 0 - Disable - 1 - Enable )", 0, \ {"26.10", false, true, "New setting to toggle the plan optimization that skips a group's key materialization while a two-level bucket of a final aggregation is converted, when a HAVING bound on that aggregation's own no-argument count() already rejects the group. A skipped group is neither filtered nor finalized, so a HAVING conjunct written before the bound, and a sibling aggregate's finalization, stop being evaluated on the groups the bound rejects. A query that raised an exception from one of those can now succeed; `compatibility` below 26.10 keeps the previous behavior."}) \ DECLARE(Bool, query_plan_split_filter, true, R"( This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed. Toggles a query-plan-level optimization which splits filters into expressions. Only takes effect if setting [query_plan_enable_optimizations](#query_plan_enable_optimizations) is 1. Possible values: - 0 - Disable - 1 - Enable )", 0) \ DECLARE(Bool, query_plan_merge_expressions, true, R"( Toggles a query-plan-level optimization which merges consecutive filters. Only takes effect if setting [query_plan_enable_optimizations](#query_plan_enable_optimizations) is 1. This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed. Possible values: - 0 - Disable - 1 - Enable )", 0) \ DECLARE(Bool, query_plan_merge_filters, true, R"( Allow to merge filters in the query plan. )", 0, \ {"24.11", false, true, "Allow to merge filters in the query plan. This is required to properly support filter-push-down with the analyzer."}, \ {"24.7", false, false, "Allow to merge filters in the query plan"}) \ DECLARE(Bool, query_plan_push_limit_by_into_sort, true, R"( Toggles a query-plan-level optimization for `ORDER BY ... LIMIT BY` queries. When `LIMIT BY` columns are a prefix of the `ORDER BY` clause, each parallel sorted stream applies `LIMIT BY` before the streams are merged into one, reducing rows processed by the final merge and later pipeline stages. Speeds up queries where `LIMIT BY` discards a large fraction of rows. Only takes effect if setting [query_plan_enable_optimizations](#query_plan_enable_optimizations) is 1. Possible values: - 0 - Disable - 1 - Enable )", 0, \ {"26.6", false, true, "New setting that pushes a per-stream LIMIT BY into the sort pipeline when LIMIT BY's columns are a prefix of ORDER BY, reducing rows flowing through the final merge."}) \ DECLARE(Bool, query_plan_fuse_filter_into_array_join, true, R"( Toggles a query-plan-level optimization which fuses a filter on `ARRAY JOIN`ed element columns into the `ARRAY JOIN` step, filtering the arrays in element space before expansion so that filtered-out elements are never expanded or replicated. Only takes effect if setting [query_plan_enable_optimizations](#query_plan_enable_optimizations) is 1. This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed. )", 0, \ {"26.9", false, true, "New optimization to fuse a filter on ARRAY JOINed columns into the ARRAY JOIN step, enabled by default."}) \ DECLARE(Bool, query_plan_lower_array_join_function, true, R"( Runs the `arrayJoin` function in the same way as the `ARRAY JOIN` clause: as a separate `ARRAY JOIN` step of the query plan. When disabled, the function is calculated inside the expression that contains it, as in older versions. This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed. )", 0, \ {"26.10", false, true, "Enable query_plan_lower_array_join_function by default."}, \ {"26.9", false, false, "New optimization to lower an arrayJoin function into a real ARRAY JOIN step; disabled by default."}) \ DECLARE(Bool, legacy_array_join_function_nondeterministic_evaluation, false, R"( How non-deterministic and block-dependent functions next to the `arrayJoin` function are evaluated. By default `rand()` gives a different value on every output row and `runningDifference` or `neighbor` see the blocks of the expansion, like with the `ARRAY JOIN` clause. Enable to get the behavior of older versions. )", 0, \ {"26.10", true, false, "Non-deterministic and block-dependent functions next to the `arrayJoin` function are evaluated like with the `ARRAY JOIN` clause."}) \ DECLARE(Bool, query_plan_filter_push_down, true, R"( Toggles a query-plan-level optimization which moves filters down in the execution plan. Only takes effect if setting [query_plan_enable_optimizations](#query_plan_enable_optimizations) is 1. This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed. Possible values: - 0 - Disable - 1 - Enable )", 0) \ DECLARE(Bool, query_plan_filter_push_down_below_limit_by, true, R"( Toggles pushing filters on `LIMIT BY` key columns below the `LIMIT BY` step. Only takes effect if setting [query_plan_enable_optimizations](#query_plan_enable_optimizations) is 1. It is read independently of [query_plan_filter_push_down](#query_plan_filter_push_down): the push-down pass also runs, with that setting off, once a `JOIN` runtime filter has been added. This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed. Possible values: - 0 - Disable - 1 - Enable )", 0, \ {"26.10", true, true, "New setting to control pushing a filter on the `LIMIT BY` key columns below the `LIMIT BY` step. Set it to false to keep the filter above the `LIMIT BY`."}, \ {"26.8", false, true, "New setting to control pushing a filter on the `LIMIT BY` key columns below the `LIMIT BY` step. Set it to false to keep the filter above the `LIMIT BY`."}) \ DECLARE(Bool, query_plan_propagate_predicate_across_join, true, R"( Toggles a query-plan-level optimization which copies filter conjuncts from one side of an equi-join onto the other side via equi-key substitution, so that primary-key/index pruning on the other side can use them. Applies when the filter and the read are separated from the join only by expression and filter steps, and when the copied conjunct compares a constant (including `IN` with a constant set) with either a primary key column of a `MergeTree` read, or a column of a `Parquet` read (`file`, `url`, object storage that is not a data lake) of an integer of up to 64 bits, `Date`, `Date32` or `Decimal` type without a default expression, whose row groups the read can skip by min/max statistics. A predicate below a nested join or below `DISTINCT`, or a comparison between two key columns, is left alone: it could not drive pruning on the other side, so copying it would only add work. Only takes effect if `query_plan_enable_optimizations` is 1. )", 0, \ {"26.11", true, true, "Also copies filter conjuncts onto integer, Date and Decimal columns of Parquet reads, which skip row groups by their statistics."}, \ {"26.9", false, true, "New setting that lifts filter conjuncts across equi-join keys so primary-key pruning fires on both sides."}) \ DECLARE(Bool, query_plan_push_down_volume_reducing_functions, true, R"( Toggles a query-plan-level optimization which moves volume-reducing functions (`length`, `lengthUTF8`, `empty`, `notEmpty`) down in the execution plan, below `Sorting` and `Filter` steps. The fixed-size result replaces the wide `String` / `FixedString` argument, so the argument is no longer carried through those steps. The rewrite is only applied when the argument column is not needed above the step it is pushed below. Only takes effect if setting [query_plan_enable_optimizations](#query_plan_enable_optimizations) is 1. Possible values: - 0 - Disable - 1 - Enable )", 0, \ {"26.8", false, true, "New setting to push volume-reducing functions (`length`, `lengthUTF8`, `empty`, `notEmpty`) below `Sorting` and `Filter` steps, so the wide argument column is replaced by the fixed-size result. previous_value=false so `compatibility` with versions before 26.8 restores the pre-existing behavior (no push down)."}) \ DECLARE(Bool, query_plan_convert_outer_join_to_inner_join, true, R"( Allow to convert `OUTER JOIN` to `INNER JOIN` if filter after `JOIN` always filters default values )", 0, \ {"24.4", false, true, "Allow to convert OUTER JOIN to INNER JOIN if filter after JOIN always filters default values"}) \ DECLARE(Bool, query_plan_convert_outer_join_to_inner_join_transitively, true, R"( Extend `query_plan_convert_outer_join_to_inner_join` to consider a filter further up the plan and conditions of an enclosing `JOIN`. Only has an effect when `query_plan_convert_outer_join_to_inner_join` is enabled. )", 0, \ {"26.10", false, true, "New setting to extend `query_plan_convert_outer_join_to_inner_join` to consider a filter further up the plan and conditions of an enclosing `JOIN`. Only has an effect when `query_plan_convert_outer_join_to_inner_join` is enabled."}) \ DECLARE(Bool, query_plan_short_circuit_constant_false_join, true, R"( Short-circuit a `JOIN` whose `ON` condition folds to a constant false by replacing each input side that cannot contribute a row (both sides for `INNER`/`CROSS`/`SEMI`, the non-preserved side for `LEFT`/`RIGHT`) with an empty source, so the non-contributing side is not read. Applies to non-distributed plans. )", 0, \ {"26.8", false, true, "New setting to short-circuit a JOIN with a constant-false ON condition so the non-contributing side is not read. previous_value=false so `compatibility` with versions before 26.8 restores the pre-existing behavior (no short-circuit)."}) \ DECLARE(Bool, query_plan_convert_any_join_to_semi_or_anti_join, true, R"( Allow to convert ANY JOIN to SEMI or ANTI JOIN if filter after JOIN always evaluates to false for not-matched or matched rows )", 0, \ {"25.9", true, true, "New setting."}) \ DECLARE(Bool, query_plan_merge_filter_into_join_condition, true, R"( Allow to merge filter into `JOIN` condition and convert `CROSS JOIN` to `INNER`. )", 0, \ {"25.4", false, true, "Added new setting to merge filter into join condition"}) \ DECLARE(Bool, query_plan_replace_always_true_filter, true, R"( Replace a filter step with an expression step when the filter condition is always true and the query does not use the filter column. Such a filter step does not remove rows, but it stops join reordering. )", 0, \ {"26.10", true, true, "New setting."}) \ DECLARE(Bool, query_plan_merge_expression_into_join, true, R"( Allow to merge expressions into JOIN step during join reordering optimization. )", 0, \ {"26.7", false, true, "New setting. Allow to merge Expression step into JOIN step during join reordering optimization."}) \ DECLARE(Bool, query_plan_convert_join_to_in, false, R"( Allow to convert `JOIN` to subquery with `IN` if output columns tied to only left table. May cause wrong results with non-ANY JOINs (e.g. ALL JOINs which is the default). )", 0, \ {"25.4", false, false, "New setting"}) \ DECLARE(Bool, optimize_prewhere_after_pushdown, false, R"( Run a second `PREWHERE` promotion pass after later query plan optimizations may have deposited additional filters above a `MergeTree` read step (e.g. predicate pushdown through `JOIN`, projection rewrites). When an existing `PREWHERE` is already present, the new filter is `AND`-merged into it instead of staying as a separate filter step. )", 0, \ {"26.6", false, false, "New setting that enables a second PREWHERE promotion pass to merge filters deposited above a MergeTree read step by later optimizations (predicate pushdown through JOIN, projection rewrites) into the existing PREWHERE chain."}) \ DECLARE(Bool, query_plan_execute_functions_after_sorting, true, R"( Toggles a query-plan-level optimization which moves expressions after sorting steps. Only takes effect if setting [`query_plan_enable_optimizations`](#query_plan_enable_optimizations) is 1. This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed. Possible values: - 0 - Disable - 1 - Enable )", 0) \ DECLARE_WITH_ALIAS(Bool, query_plan_reuse_storage_ordering_for_window_functions, true, R"( Toggles a query-plan-level optimization which uses storage sorting when sorting for window functions. Only takes effect if setting [`query_plan_enable_optimizations`](#query_plan_enable_optimizations) is 1. This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed. Possible values: - 0 - Disable - 1 - Enable )", 0, optimize_read_in_window_order, \ {"26.11", false, true, "Enable by default again: the sorting now scatters the merged stream by the `PARTITION BY` columns, so the window functions run in parallel. This also applies to the alias `optimize_read_in_window_order`."}, \ {"26.1", true, false, "Disable this logic by default. This also applies to the alias `optimize_read_in_window_order`."}) \ DECLARE(Bool, query_plan_lift_up_union, true, R"( Toggles a query-plan-level optimization which moves larger subtrees of the query plan into union to enable further optimizations. Only takes effect if setting [`query_plan_enable_optimizations`](#query_plan_enable_optimizations) is 1. This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed. Possible values: - 0 - Disable - 1 - Enable )", 0) \ DECLARE(BoolForce, query_plan_read_in_order_through_join, true, R"( Keep reading in order from the left table in JOIN operations, which can be utilized by subsequent steps. For a join other than `LEFT`, the read stays in order only when every part of the left table announces a virtual row (see [`read_in_order_use_virtual_row`](#read_in_order_use_virtual_row)); without the virtual rows the merge after the join may read far more than the limit needs. The value `force` keeps the read in order regardless. )", 0, \ {"26.10", true, true, "Added the value `force`: keep reading in order through a join even when the parts announce no virtual rows."}, \ {"25.12", false, true, "New setting"}) \ DECLARE(Bool, query_plan_remove_redundant_sorting, true, R"( Toggles a query-plan-level optimization which removes redundant sorting steps, e.g. in subqueries. Only takes effect if setting [`query_plan_enable_optimizations`](#query_plan_enable_optimizations) is 1. This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed. Possible values: - 0 - Disable - 1 - Enable )", 0, \ {"23.1", false, true, "Remove redundant sorting in query plan. For example, sorting steps related to ORDER BY clauses in subqueries"}) \ DECLARE(Bool, query_plan_use_shuffle_for_order_by_rand, true, R"( Toggles a query-plan-level optimization which executes `ORDER BY rand()` and `ORDER BY rand64()` by shuffling the rows (the same way as the `SHUFFLE` clause) instead of sorting them, which takes O(n) time instead of O(n * log(n)). The result has the same distribution: the values of the `rand()` column are replaced by other random values in sorted order. Applies when the `rand()` value is not used in other expressions, and when there is a `LIMIT` or the external sorting is disabled (the shuffle does not spill to disk). Only takes effect if setting [`query_plan_enable_optimizations`](#query_plan_enable_optimizations) is 1. This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed. Possible values: - 0 - Disable - 1 - Enable )", 0, \ {"26.11", false, true, "New setting to execute `ORDER BY rand()` by shuffling the rows instead of sorting them."}) \ DECLARE(Bool, query_plan_remove_redundant_distinct, true, R"( Toggles a query-plan-level optimization which removes redundant DISTINCT steps. Only takes effect if setting [`query_plan_enable_optimizations`](#query_plan_enable_optimizations) is 1. This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed. Possible values: - 0 - Disable - 1 - Enable )", 0, \ {"23.2", false, true, "Remove redundant Distinct step in query plan"}) \ DECLARE(Bool, query_plan_try_use_vector_search, true, R"( Toggles a query-plan-level optimization which tries to use the vector similarity index. Only takes effect if setting [`query_plan_enable_optimizations`](#query_plan_enable_optimizations) is 1. This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed. Possible values: - 0 - Disable - 1 - Enable )", 0, \ {"25.1", false, true, "New setting."}) \ DECLARE(Bool, query_plan_enable_multithreading_after_window_functions, true, R"( Enable multithreading after evaluating window functions to allow parallel stream processing )", 0) \ DECLARE(Bool, query_plan_optimize_lazy_materialization, true, R"( Use query plan for lazy materialization optimization. )", 0, \ {"25.4", false, true, "Added new setting to use query plan for lazy materialization optimisation"}) \ DECLARE(Bool, query_plan_optimize_lazy_materialization_for_object_storage, true, R"( Use lazy materialization optimization for reading Parquet and Vortex files from object storage (including Iceberg tables): for `ORDER BY ... LIMIT n` queries, the columns that are not needed for sorting and filtering are read only for the `n` rows that survive the `LIMIT`. Takes effect only if `query_plan_optimize_lazy_materialization` is enabled. )", 0, \ {"26.8", false, true, "New setting to use lazy materialization for `ORDER BY ... LIMIT n` queries reading Parquet files from object storage (including Iceberg tables)."}) \ DECLARE(Bool, query_plan_optimize_lazy_materialization_for_file, true, R"( Use lazy materialization optimization for reading local Parquet and Vortex files with the `file` table function and the `File` table engine: for `ORDER BY ... LIMIT n` queries, the columns that are not needed for sorting and filtering are read only for the `n` rows that survive the `LIMIT`. Takes effect only if `query_plan_optimize_lazy_materialization` is enabled. )", 0, \ {"26.8", false, true, "New setting to use lazy materialization for `ORDER BY ... LIMIT n` queries reading local Parquet files with the `file` table function and the `File` table engine."}) \ DECLARE(Bool, query_plan_lazy_materialization_for_join, true, R"( Use lazy materialization for `LIMIT n` queries over joins, with or without `ORDER BY`: the columns of the `MergeTree` tables, and of the object storage tables if `query_plan_optimize_lazy_materialization_for_object_storage` is enabled, are read only for the `n` rows that survive the `LIMIT`, rather than for every row the joins produce. The decision is made on one merged `ActionsDAG` for the whole subtree below the `LIMIT`, so a value that a filter needs and the result needs again is computed twice, cheaply, above the `LIMIT`, instead of becoming a column carried through every join in between. Takes effect only if `query_plan_optimize_lazy_materialization` is enabled. )", 0, \ {"26.11", false, true, "New setting to use lazy materialization for `LIMIT n` queries over joins."}) \ DECLARE(UInt64, query_plan_max_limit_for_lazy_materialization, 10000, R"(Control maximum limit value that allows to use query plan for lazy materialization optimization. If zero, there is no limit. )", 0, \ {"25.12", 100, 10000, "Increase the limit after performance improvement"}, \ {"25.11", 10, 100, "More optimal"}, \ {"25.4", 10, 10, "Added new setting to control maximum limit value that allows to use query plan for lazy materialization optimisation. If zero, there is no limit"}) \ DECLARE(Bool, query_plan_optimize_lazy_final, false, R"( Optimize reading with FINAL from ReplacingMergeTree by building a set of primary keys and using it for index analysis. )", 0, \ {"26.4", false, false, "New setting to optimize reading with FINAL from ReplacingMergeTree using set-based index analysis"}) \ DECLARE(UInt64, max_rows_for_lazy_final, 10000000, R"( Maximum number of rows in the set for lazy FINAL optimization. If exceeded, falls back to normal FINAL. )", 0, \ {"26.4", 10000000, 10000000, "New setting for maximum number of rows in the set for lazy FINAL optimization"}) \ DECLARE(UInt64, max_bytes_for_lazy_final, 256000000, R"( Maximum number of bytes in the set for lazy FINAL optimization. If exceeded, falls back to normal FINAL. )", 0, \ {"26.4", 256000000, 256000000, "New setting for maximum number of bytes in the set for lazy FINAL optimization"}) \ DECLARE(Float, min_filtered_ratio_for_lazy_final, 0.5, R"( Minimum ratio of marks filtered by index analysis for lazy FINAL optimization. If less than this fraction of marks is filtered, falls back to normal FINAL. Value 0 disables this check. )", 0, \ {"26.4", 0.5, 0.5, "New setting for minimum ratio of marks filtered for lazy FINAL optimization to proceed"}) \ DECLARE(Bool, enable_lazy_columns_replication, true, R"( Enables lazy columns replication in `JOIN`, `ARRAY JOIN` and lambda captures of higher-order functions (e.g. `arrayMap`), it allows to avoid unnecessary copy of the same rows multiple times in memory. )", 0, \ {"25.11", false, true, "Enable lazy columns replication in JOIN and ARRAY JOIN by default"}, \ {"25.10", false, false, "Add a setting to enable lazy columns replication in JOIN and ARRAY JOIN"}) \ DECLARE(UInt64, query_plan_max_set_size_for_projection_match, 10000, R"( Maximum number of rows in an `IN`-clause set for which the projection matcher computes and compares content hashes when deciding whether two sets are equal. Sets larger than this are treated as non-matching and skip the projection. Zero disables content-hash comparison entirely: a projection match never succeeds for nodes containing `IN`-clause sets. Used by the aggregate projection matcher (and any future projection matcher that needs to compare `IN`-clause sets). Computing the content hash is `O(N log N)` in the number of set elements; this setting bounds the cost paid during planning when many `IN`-clauses appear in the query or the projection. )", 0, \ {"26.6", 0, 10000, "Added new setting that bounds the cost of content-hashing IN-clause sets in the projection matcher (today: aggregate projection). Sets larger than the limit are treated as non-matching. Zero disables content-hash comparison entirely (compatibility value: projection match never succeeds for nodes with IN-sets)."}) \ DECLARE(Bool, enable_software_prefetch_in_join, true, R"( Enable use of software prefetch in hash join probe phase to hide memory access latency for large hash tables. )", 0, \ {"26.5", false, true, "Enable use of software prefetch in hash join probe phase."}) \ DECLARE(Bool, legacy_join_size_limits_trigger_spilling, false, R"( Restores how `max_rows_in_join` and `max_bytes_in_join` worked before the spill threshold became the trigger, for the part of a join that runs on disk: reaching one of them makes the join spill further instead of stopping the query. `join_algorithm = 'grace_hash'` then spills on those two alone and ignores `max_bytes_before_external_join` entirely, zero included. `hash` / `parallel_hash` still go to disk on the spill threshold and spill on either one afterwards; their in-memory phase keeps treating the two as a hard cap, as it did before. For queries written against the earlier meaning of these two settings; `compatibility` enables it automatically. A server that predates this setting applies the old meaning, and cannot be told otherwise, so with `serialize_query_plan = 1` a join whose spilling depends on the new meaning is not sent to such a server at all: the query fails instead of quietly running with the other contract. Turning this setting on makes those queries work across the two versions, with the old meaning on both sides. )", 0, \ {"26.10", true, false, "`max_rows_in_join` / `max_bytes_in_join` are now hard caps for every hash join, including the ones that spill to disk, where they used to act as the spill trigger. Spilling is driven by `max_bytes_before_external_join` / `max_bytes_ratio_before_external_join` alone."}) \ DECLARE(Bool, serialize_query_plan, false, R"( Serialize query plan for distributed processing )", 0, \ {"25.4", false, false, "NewSetting"}) \ DECLARE(Bool, correlated_subqueries_substitute_equivalent_expressions, true, R"( Use filter expressions to inference equivalent expressions and substitute them instead of creating a CROSS JOIN. )", 0, \ {"25.7", false, true, "New setting to correlated subquery planning optimization."}) \ DECLARE(DecorrelationJoinKind, correlated_subqueries_default_join_kind, DecorrelationJoinKind::RIGHT, R"( Controls the kind of joins in the decorrelated query plan. The default value is `right`, which means that decorrelated plan will contain RIGHT JOINs with subquery input on the right side. Possible values: - `left` - Decorrelation process will produce LEFT JOINs and input table will appear on the left side. - `right` - Decorrelation process will produce RIGHT JOINs and input table will appear on the right side. When the subquery input is shared through an in-memory buffer (see `correlated_subqueries_use_in_memory_buffer`), `right` is used regardless of this setting, because only that layout evaluates the buffer writer before its reader. The join kind is an internal detail of the decorrelated plan and does not change the result. )", 0, \ {"25.11", "left", "right", "New setting. Default join kind for decorrelated query plan."}, \ {"25.10", "left", "right", "New setting. Default join kind for decorrelated query plan."}) \ DECLARE(Bool, correlated_subqueries_use_in_memory_buffer, true, R"( Use in-memory buffer for correlated subquery input to avoid its repeated evaluation. )", 0, \ {"26.1", false, true, "Use in-memory buffer for input of correlated subqueries by default."}) \ DECLARE(Bool, optimize_qbit_distance_function_reads, true, R"( Replace distance functions on `QBit` data type with equivalent ones that only read the columns necessary for the calculation from the storage. )", 0, \ {"25.10", true, true, "New setting"}) \ DECLARE(Bool, qbit_one_bit_symmetric_distance, false, R"( When a `QBit` distance function (`L2DistanceTransposed`, `cosineDistanceTransposed`, `dotProductTransposed` and their `...Quantized` variants) is called with precision 1, also reduce the reference vector to the signs of its elements and derive the result from the Hamming distance between the two sign vectors, computed with XOR and popcount. By default the reference vector keeps its full precision at precision 1 and only the stored vector is reduced to signs (an asymmetric distance). The symmetric distance is several times faster, but it ignores the magnitudes of the reference elements: a dimension where the reference is large counts as much as one where it is close to zero. )", 0, \ {"26.10", false, false, "New setting: at precision 1 the QBit distance functions can reduce the reference vector to its signs as well and use the Hamming distance between the sign vectors (XOR + popcount) instead of keeping the reference at full precision"}) \ \ DECLARE(UInt64, regexp_max_matches_per_row, 1000, R"( Sets the maximum number of matches for a single regular expression per row. Use it to protect against memory overload when using greedy regular expression in the [extractAllGroupsHorizontal](/reference/functions/regular-functions/string-search-functions#extractAllGroupsHorizontal) function. Possible values: - Positive integer. )", 0) \ \ DECLARE(UInt64, highlight_max_matches_per_row, 10000, R"( Sets the maximum number of highlight matches per row in the [highlight](/reference/functions/regular-functions/string-search-functions#highlight) function. Use it to protect against excessive memory usage when highlighting highly repetitive patterns in large texts. Possible values: - Positive integer. )", 0, \ {"26.4", 10000, 10000, "New setting to limit the number of highlight matches per row to protect against excessive memory usage."}) \ \ DECLARE(Double, limit, 0, R"( Sets the maximum number of rows to get from the query result. It adjusts the value set by the [LIMIT](/reference/statements/select/limit) clause. The value is passed through to `LIMIT` and accepts everything that `LIMIT` accepts, including negative values (count from the end of the result) and fractions in `(0, 1)` (interpreted as a share of the result). Possible values: - 0 — The number of rows is not limited. - Positive integer — exact number of rows. - Negative integer — return the last N rows. - A real number in the open range `(0, 1)` — return that fraction of the result. This setting shapes result-producing `SELECT` / `UNION` queries. For a write query (`INSERT … SELECT`, `CREATE … AS SELECT`) it takes effect only when the source `SELECT` carries it in its own `SETTINGS` clause; a value inherited from a profile or session, or set on the `INSERT` / `CREATE` statement itself, does not propagate into the source `SELECT` — the same non-propagation rule that applies to any other setting. )", 0, \ {"26.8", 0., 0., "Type widened from UInt64 to Float to support negative and fractional values, passed through to ClickHouse's native negative/fractional `LIMIT` support."}) \ DECLARE(Double, offset, 0, R"( Sets the number of rows to skip before starting to return rows from the query. It adjusts the offset set by the [OFFSET](/reference/statements/select/offset) clause. The value is passed through to `OFFSET` and accepts everything that `OFFSET` accepts, including negative values and fractions in `(0, 1)`. Possible values: - 0 — No rows are skipped. - Positive integer. - Negative integer. - A real number in the open range `(0, 1)` — skip that fraction of the result. **Example** Input table: ```sql CREATE TABLE test (i UInt64) ENGINE = MergeTree() ORDER BY i; INSERT INTO test SELECT number FROM numbers(500); ``` Query: ```sql SET limit = 5; SET offset = 7; SELECT * FROM test LIMIT 10 OFFSET 100; ``` Result: ```text ┌───i─┐ │ 107 │ │ 108 │ │ 109 │ └─────┘ ``` This setting shapes result-producing `SELECT` / `UNION` queries. For a write query (`INSERT … SELECT`, `CREATE … AS SELECT`) it takes effect only when the source `SELECT` carries it in its own `SETTINGS` clause; a value inherited from a profile or session, or set on the `INSERT` / `CREATE` statement itself, does not propagate into the source `SELECT` — the same non-propagation rule that applies to any other setting. )", 0, \ {"26.8", 0., 0., "Type widened from UInt64 to Float to support negative and fractional values, passed through to ClickHouse's native negative/fractional `OFFSET` support."}) \ \ DECLARE(Double, page, 0, R"( Sets the page number for paginated results. Equivalent to `offset = limit * (page - 1)`. Can only be specified when `limit` is set and `offset` is not. Pages are 1-based. Inherits the same negative/fractional support as `limit` and `offset`. This is a query-construction setting applied by the engine on the parsed query (wrapping it as a derived table), so it composes with the existing query and works on every protocol: it can be supplied via the HTTP URL parameter, an in-query `SETTINGS` clause, or a user profile. It shapes result-producing `SELECT` / `UNION` queries. For a write query (`INSERT … SELECT`, `CREATE … AS SELECT`) it takes effect only when the source `SELECT` carries it in its own `SETTINGS` clause; a value inherited from a profile or session, or set on the `INSERT` / `CREATE` statement itself, does not propagate into the source `SELECT` — the same non-propagation rule that applies to any other setting. )", 0, \ {"26.8", 0., 0., "New setting for paginated HTTP responses, equivalent to offset = limit * (page - 1). Float so it can hold negative or fractional values (passed through to SQL `LIMIT`/`OFFSET`)."}) \ DECLARE(String, select, "", R"( Wraps the query as a subquery with an explicit `SELECT` expression list. When non-empty, the result-producing query is wrapped as `SELECT FROM ()`. This is a query-construction setting applied by the engine on the parsed query (wrapping it as a derived table), so it composes with the existing query and works on every protocol: it can be supplied via the HTTP URL parameter, an in-query `SETTINGS` clause, or a user profile. It shapes result-producing `SELECT` / `UNION` queries. For a write query (`INSERT … SELECT`, `CREATE … AS SELECT`) it takes effect only when the source `SELECT` carries it in its own `SETTINGS` clause; a value inherited from a profile or session, or set on the `INSERT` / `CREATE` statement itself, does not propagate into the source `SELECT` — the same non-propagation rule that applies to any other setting. )", 0, \ {"26.8", "", "", "New setting to wrap a query in `SELECT FROM ()`."}) \ DECLARE(String, order, "", R"( Adds an `ORDER BY` clause to the query as a wrapping subquery. Accepts an arbitrary expression list. This is a query-construction setting applied by the engine on the parsed query (wrapping it as a derived table), so it composes with the existing query and works on every protocol: it can be supplied via the HTTP URL parameter, an in-query `SETTINGS` clause, or a user profile. It shapes result-producing `SELECT` / `UNION` queries. For a write query (`INSERT … SELECT`, `CREATE … AS SELECT`) it takes effect only when the source `SELECT` carries it in its own `SETTINGS` clause; a value inherited from a profile or session, or set on the `INSERT` / `CREATE` statement itself, does not propagate into the source `SELECT` — the same non-propagation rule that applies to any other setting. )", 0, \ {"26.8", "", "", "New setting to add an ORDER BY clause around a query."}) \ DECLARE(String, sort, "", R"( Adds a simple `ORDER BY` clause to the query as a wrapping subquery. Accepts a comma-separated list of identifiers or positional column references (positive integers) with an optional `+` (ASC) or `-` (DESC) prefix. Example: `sort=a,-b` orders by `a` ascending and `b` descending; `sort=1,-2` orders by the first column ascending and the second descending. Cannot be combined with `order`. This is a query-construction setting applied by the engine on the parsed query (wrapping it as a derived table), so it composes with the existing query and works on every protocol: it can be supplied via the HTTP URL parameter, an in-query `SETTINGS` clause, or a user profile. It shapes result-producing `SELECT` / `UNION` queries. For a write query (`INSERT … SELECT`, `CREATE … AS SELECT`) it takes effect only when the source `SELECT` carries it in its own `SETTINGS` clause; a value inherited from a profile or session, or set on the `INSERT` / `CREATE` statement itself, does not propagate into the source `SELECT` — the same non-propagation rule that applies to any other setting. )", 0, \ {"26.8", "", "", "New setting to add a simple ORDER BY clause around a query."}) \ DECLARE(String, filter, "", R"( Adds a `WHERE` clause to the query as a wrapping subquery. Multiple filters are combined with AND. The HTTP interface allows multiple `filter` URL parameters which are combined with AND in order, and with the value of this setting. This is a query-construction setting applied by the engine on the parsed query (wrapping it as a derived table), so it composes with the existing query and works on every protocol: it can be supplied via the HTTP URL parameter, an in-query `SETTINGS` clause, or a user profile. It shapes result-producing `SELECT` / `UNION` queries. For a write query (`INSERT … SELECT`, `CREATE … AS SELECT`) it takes effect only when the source `SELECT` carries it in its own `SETTINGS` clause; a value inherited from a profile or session, or set on the `INSERT` / `CREATE` statement itself, does not propagate into the source `SELECT` — the same non-propagation rule that applies to any other setting. `filter` is **not** an access-control mechanism and must not be used as a substitute for [row-level security policies](/concepts/features/security/access-rights#row-policy-management) or the `additional_table_filters` setting. It only adds a `WHERE` over the wrapping subquery, so the underlying data is still read and processed before the filter is applied — a query can observe the filtered-out rows during processing (for example with `throwIf` to leak information through the error path). Use row-level security or `additional_table_filters` when the goal is to restrict which rows a user may access. )", 0, \ {"26.8", "", "", "New setting to add a WHERE clause around a query."}) \ DECLARE(String, database, "", R"( Sets the current database for the query — the database in which unqualified table names are resolved, the same effect as `USE `. Unlike the `USE` statement, this is an ordinary session setting: like any other setting it accepts a value without validating it, and an unknown database is reported when the setting takes effect (when a query runs), not at `SET` time. It follows the privilege contract of the client-supplied default database (which it generalizes), not of `USE`: selecting the current database does not require the `SHOW_DATABASES` privilege, while access to the tables inside it is checked as usual. Used as the destination for the HTTP interface `database` URL parameter and the `X-ClickHouse-Database` header. )", 0, \ {"26.8", "", "", "New setting that specifies the current database for the query. Replaces the special handling of the HTTP `database` URL parameter and `X-ClickHouse-Database` header."}) \ DECLARE(String, default_format, "", R"( Specifies the format of the query result when the query has no `FORMAT` clause and no other format override is applied. )", 0, \ {"26.8", "", "", "New setting for the default format when the query has no FORMAT clause."}) \ DECLARE(String, format, "", R"( Overrides the `FORMAT` of the query for both input and output. Wins over the format specified in the query and in the file extension. The more specific `input_format` and `output_format` settings take precedence over this generic `format` setting for their respective direction. )", 0, \ {"26.8", "", "", "New setting to override the FORMAT of the query for both input and output."}) \ DECLARE(String, input_format, "", R"( Overrides the input format of the query. Wins over the format specified in the query. )", 0, \ {"26.8", "", "", "New setting to override the input format of the query."}) \ DECLARE(String, output_format, "", R"( Overrides the output format of the query. Wins over the format specified in the query, in the file extension, or via `default_format`. )", 0, \ {"26.8", "", "", "New setting to override the output format of the query."}) \ DECLARE(String, compression, "", R"( Applies a generic compression to the response body, e.g., `compression=gz`. Note this is independent of `Content-Encoding` (HTTP compression) and the legacy `compress` parameter (ClickHouse-native compression). For response-producing path requests, specifying a compressed file extension in the URL path is equivalent. For a path-based HTTP `PUT` upload, the compression suffix describes the request body instead, which is decompressed before insertion. This is an HTTP-interface response-shaping setting: it is consumed before the query is executed (the response buffers are set up up-front), so it must be supplied via the HTTP URL parameter, the URL path file extension, or a user profile, not via an in-query `SETTINGS` clause (where it has no effect and is rejected). )", 0, \ {"26.8", "", "", "New setting to apply generic compression to the response body."}) \ DECLARE(Bool, http_allow_database_as_path, true, R"( If enabled, the HTTP interface recognizes a `/database/` component in the URL path and uses it as the current database. It also enables database-prefixed path-based `PUT` uploads such as `/database/table.CSV`. This is a per-user setting that controls whether a routed path-style request is interpreted. Routing itself is gated globally by the server-level `http_allow_path_requests` configuration setting (on by default), which must be enabled for the HTTP interface to route a path-style request (such as `/my_db/my_table.csv`) to the query handler at all — that routing decision is made before the request is authenticated, so it cannot depend on a per-user setting. When `http_allow_path_requests` is off, unknown paths return a plain `404`. After routing, this setting is re-checked against the authenticated user's effective settings, so it can be disabled selectively per user, role, or profile. )", 0, \ {"26.10", false, true, "Enabled by default: the HTTP interface interprets a `/database/` component of the URL path as the current database."}, \ {"26.8", false, false, "New setting to recognize a database name in the URL path of HTTP requests."}) \ DECLARE(Bool, http_allow_table_as_file, true, R"( If enabled, the HTTP interface recognizes the last URL path component as a table name in the form `table`, `table.format`, or `table.format.compression`. For `GET` and `HEAD`, the path is interpreted as `SELECT * FROM table`; for a path-based `PUT`, it identifies the existing destination table and input format for the upload. Like [`http_allow_database_as_path`](#http_allow_database_as_path), this is a per-user setting; routing of path-style requests is gated globally by the server-level `http_allow_path_requests` configuration setting (routing happens before authentication). )", 0, \ {"26.10", false, true, "Enabled by default: the HTTP interface interprets the last URL path component as `table[.format[.compression]]` and answers it with `SELECT * FROM table`."}, \ {"26.8", false, false, "New setting to recognize a table name in the URL path of HTTP requests, with optional format/compression extensions."}) \ DECLARE(Bool, http_allow_filters_as_path, true, R"( If enabled, the HTTP interface recognizes `/name=value/` components in the path (hive partitioning style) and translates them to filters combined with AND. Operators `>`, `<`, `>=`, `<=`, `!=`, `<>` are also recognized. Like [`http_allow_database_as_path`](#http_allow_database_as_path), this is a per-user setting; routing of path-style requests is gated globally by the server-level `http_allow_path_requests` configuration setting (routing happens before authentication). )", 0, \ {"26.10", false, true, "Enabled by default: the HTTP interface interprets `/name=value/` path components as filters combined with `AND`."}, \ {"26.8", false, false, "New setting to recognize hive-style `name=value` filters in the URL path of HTTP requests."}) \ DECLARE(Bool, http_allow_filters_as_unrecognized_url_parameters, false, R"( If enabled, any URL parameter not recognized as a known parameter, setting, or `param_*` prefix is treated as a filter and combined with AND. Two forms are accepted: - A plain `name=value` becomes the equality `` `name` = 'value' `` (the identifier is back-quoted, the value is quoted as a string literal). - A comparison operator (`!=`, `>`, `<`, `>=`, `<=`, `<>`) makes it a comparison: either split across the parameter (`?a!=2`, `?a>=2`) or written inline when the URL has no `=` to split on (`?a<>2`, `?f(x)>3`), in which case the reassembled `name[=value]` is parsed as a full SQL expression. Disabled by default, unlike the other `http_allow_*` settings: it applies to every request of the HTTP interface, including the `/?query=...` endpoint, so enabling it turns any unrecognized URL parameter a client appends (a request id, a signature, a cache buster) into a filter of the query. A misspelt setting name is then no longer reported as `UNKNOWN_SETTING` but fails with `UNKNOWN_IDENTIFIER` (or, if the name happens to match a column, silently filters the result), and the parameter value becomes part of the query text, where it is not masked like the `Request URI` in the log. )", 0, \ {"26.8", false, false, "New setting to treat unrecognized URL parameters as filter expressions in HTTP requests."}) \ DECLARE(Bool, http_x_clickhouse_format_overrides_output_format, true, R"( Controls which setting the `X-ClickHouse-Format` HTTP header maps to. If enabled (the default), the header is an alias for the `output_format` setting: it is an explicit override of the response format that wins over the `FORMAT` clause in the query and over the file extension in the URL path. If disabled, the header is an alias for the `default_format` setting, as it was before version 26.8: it only selects the format used when the query has no `FORMAT` clause and no other format override is applied. In both cases the header overrides the URL parameter of the same name (`output_format` or `default_format`, respectively) and never changes how the request body of an `INSERT` is parsed. This is a compatibility setting for the HTTP interface: the header is consumed before the query is parsed, so it must be supplied via a URL parameter or a user profile, not via an in-query `SETTINGS` clause. Like `output_format` and `default_format` themselves, it can always be changed in read-only mode (`readonly = 1`), so a read-only user can pass it as a URL parameter. )", 0, \ {"26.10", true, true, "Setting newly added in 26.10 to gate the `X-ClickHouse-Format` HTTP header change that shipped in 26.8. The meaningful semantic change is registered under the 26.8 block so `compatibility = '26.7'` reverts it while `compatibility = '26.8'` and `'26.9'` keep the behavior of those releases; this entry exists so the upgrade check accepts the newly-introduced name."}, \ {"26.8", false, true, "Controls whether the `X-ClickHouse-Format` HTTP header is an alias for `output_format` (overriding the query's `FORMAT` clause), as since 26.8, or for `default_format`, as before 26.8. This entry retroactively documents the 26.8 change so `compatibility` with versions before 26.8 restores the old header behavior."}) \ \ DECLARE(UInt64, function_range_max_elements_in_block, 500000000, R"( Sets the safety threshold for data volume generated by functions [range](/reference/functions/regular-functions/array-functions#range), [arrayPermutations](/reference/functions/regular-functions/array-functions#arrayPermutations), [arrayPartialPermutations](/reference/functions/regular-functions/array-functions#arrayPartialPermutations), [arrayCombinations](/reference/functions/regular-functions/array-functions#arrayCombinations), [timeSeriesRange](/reference/functions/regular-functions/time-series-functions#timeSeriesRange), and [timeSeriesFromGrid](/reference/functions/regular-functions/time-series-functions#timeSeriesFromGrid). Defines the maximum number of values generated by functions per block of data (sum of array sizes for every row in a block). For the combinatorics functions, which return `Array(Array(T))`, every generated inner array counts as its size plus one, so zero-length results still consume the limit. Possible values: - Positive integer. **See Also** - [`max_block_size`](#max_block_size) - [`min_insert_block_size_rows`](#min_insert_block_size_rows) )", 0) \ DECLARE(UInt64, function_sleep_max_microseconds_per_block, 3000000, R"( Maximum number of microseconds the function `sleep` is allowed to sleep for each block. If a user called it with a larger value, it throws an exception. It is a safety threshold. )", 0, \ {"23.7", 0, 3000000, "In previous versions, the maximum sleep time of 3 seconds was applied only for `sleep`, but not for `sleepEachRow` function. In the new version, we introduce this setting. If you set compatibility with the previous versions, we will disable the limit altogether."}) \ DECLARE(UInt64, function_base58_max_input_size, 10000, R"( Maximum size, in bytes, of a single input value for the functions `base58Encode`, `base58Decode` and `tryBase58Decode`. The generic `base58` conversion is quadratic in the input length, so a single large value can run for a very long time. `base58` is meant for short data (keys, hashes, addresses), so the default of 10 KB is a generous safety threshold. `base58Encode` and `base58Decode` throw `TOO_LARGE_STRING_SIZE` for larger inputs, while `tryBase58Decode` returns an empty string. A value of `0` disables the limit (the behavior before this setting was introduced). The linear `base32` and `base64` functions are unaffected. )", 0, \ {"26.6", 0, 10000, "New setting that limits the input size of `base58Encode`, `base58Decode` and `tryBase58Decode` (whose conversion is quadratic in the input length) to 10 KB by default. The compatibility value `0` disables the limit, restoring the previous behavior of accepting arbitrarily large inputs."}) \ DECLARE(UInt64, function_visible_width_behavior, 1, R"( The version of `visibleWidth` behavior. 0 - only count the number of code points; 1 - correctly count zero-width and combining characters, count full-width characters as two, estimate the tab width, count delete characters. )", 0, \ {"24.1", 0, 1, "We changed the default behavior of `visibleWidth` to be more precise"}) \ DECLARE(ShortCircuitFunctionEvaluation, short_circuit_function_evaluation, ShortCircuitFunctionEvaluation::ENABLE, R"( Allows calculating the [if](/reference/functions/regular-functions/conditional-functions#if), [multiIf](/reference/functions/regular-functions/conditional-functions#multiIf), [and](/reference/functions/regular-functions/logical-functions#and), [or](/reference/functions/regular-functions/logical-functions#or), [coalesce](/reference/functions/regular-functions/functions-for-nulls#coalesce), and [ifNull](/reference/functions/regular-functions/functions-for-nulls#ifNull) functions according to a [short scheme](https://en.wikipedia.org/wiki/Short-circuit_evaluation). This helps optimize the execution of complex expressions in these functions and prevent possible exceptions (such as division by zero when it is not expected). Possible values: - `enable` — Enables short-circuit function evaluation for functions that are suitable for it (can throw an exception or computationally heavy). - `force_enable` — Enables short-circuit function evaluation for all functions. - `disable` — Disables short-circuit function evaluation. )", 0) \ \ DECLARE(LocalFSReadMethod, storage_file_read_method, LocalFSReadMethod::pread, R"( Method of reading data from storage file, one of: `read`, `pread`, `mmap`. The mmap method does not apply to clickhouse-server (it's intended for clickhouse-local). )", 0) \ DECLARE(String, local_filesystem_read_method, "pread_threadpool", R"( Method of reading data from local filesystem, one of: read, pread, mmap, io_uring, pread_threadpool. The 'pread_threadpool' method hands a read off to a thread pool, unless the data is already in the page cache, which is checked with the `preadv2` system call and the `RWF_NOWAIT` flag. That check needs Linux 5.11 or newer, and the system call must not be rejected by a `seccomp` profile of a container runtime. It is checked on startup whether the system call can be used, and if it cannot, the default value of this setting is switched to 'pread', because a thread pool hand-off for every read, including the reads that are served from the page cache, is expensive; the reason is reported in the server log. A `seccomp` profile is detected only if it rejects the system call with an error code, which is what container runtimes do; a profile that terminates the process instead cannot be detected. A value set explicitly, in the configuration or with `SET`, is not switched. The 'io_uring' method is experimental and does not work for Log, TinyLog, StripeLog, File, Set and Join, and other tables with append-able files in presence of concurrent reads and writes. If you read various articles about 'io_uring' on the Internet, don't be blinded by them. It is not a better method of reading files, unless the case of a large amount of small IO requests, which is not the case in ClickHouse. There are no reasons to enable 'io_uring'. )", 0) \ DECLARE(String, remote_filesystem_read_method, "threadpool", R"( Method of reading data from remote filesystem, one of: read, threadpool. )", 0) \ DECLARE(Bool, local_filesystem_read_prefetch, false, R"( Should use prefetching when reading data from local filesystem. )", 0) \ DECLARE(Bool, remote_filesystem_read_prefetch, true, R"( Should use prefetching when reading data from remote filesystem. )", 0) \ DECLARE(Int64, read_priority, 0, R"( Priority to read data from local filesystem or remote filesystem. Only supported for 'pread_threadpool' method for local filesystem and for `threadpool` method for remote filesystem. )", 0) \ DECLARE(UInt64, merge_tree_min_rows_for_concurrent_read_for_remote_filesystem, 0, R"( The minimum number of lines to read from one file before the [MergeTree](/reference/engines/table-engines/mergetree-family/mergetree) engine can parallelize reading, when reading from remote filesystem. We do not recommend using this setting. Possible values: - Positive integer. )", 0, \ {"24.10", (20 * 8192), 0, "Setting is deprecated"}) \ DECLARE(UInt64, merge_tree_min_bytes_for_concurrent_read_for_remote_filesystem, 0, R"( The minimum number of bytes to read from one file before [MergeTree](/reference/engines/table-engines/mergetree-family/mergetree) engine can parallelize reading, when reading from remote filesystem. We do not recommend using this setting. Possible values: - Positive integer. )", 0, \ {"24.10", (24 * 10 * 1024 * 1024), 0, "Setting is deprecated"}) \ DECLARE(UInt64, remote_read_min_bytes_for_seek, 4 * DBMS_DEFAULT_BUFFER_SIZE, R"( Min bytes required for remote read (url, s3) to do seek, instead of read with ignore. )", 0) \ DECLARE_WITH_ALIAS(UInt64, merge_tree_min_bytes_per_task_for_remote_reading, 2 * DBMS_DEFAULT_BUFFER_SIZE, R"( Min bytes to read per task. )", 0, filesystem_prefetch_min_bytes_for_single_read_task, \ {"24.8", 4194304, 2097152, "Value is unified with `filesystem_prefetch_min_bytes_for_single_read_task`"}) \ DECLARE(Bool, merge_tree_use_const_size_tasks_for_remote_reading, true, R"( Whether to use constant size tasks for reading from a remote table. )", 0) \ DECLARE(Bool, merge_tree_determine_task_size_by_prewhere_columns, true, R"( Whether to use only prewhere columns size to determine reading task size. )", 0) \ DECLARE(NonZeroUInt64, merge_tree_min_read_task_size, 8, R"( Hard lower limit on the task size (even when the number of granules is low and the number of available threads is high we won't allocate smaller tasks )", 0, \ {"24.10", 8, 8, "New setting"}) \ DECLARE(UInt64, merge_tree_read_end_tasks_per_stream, 32, R"( Makes the tasks at the end of a `MergeTree` read 1/N of one thread's share of the data (not smaller than `merge_tree_min_read_task_size`), so that all threads finish at about the same time. Larger values balance the threads better but add per-task overhead. 0 disables it. )", 0, \ {"26.11", 0, 32, "New setting: the tasks at the end of a `MergeTree` read are smaller, so that all threads finish at about the same time."}) \ DECLARE(UInt64, merge_tree_compact_parts_min_granules_to_multibuffer_read, 16, R"( Only has an effect in ClickHouse Cloud. Number of granules in stripe of compact part of MergeTree tables to use multibuffer reader, which supports parallel reading and prefetch. In case of reading from remote fs using of multibuffer reader increases number of read request. )", 0) \ \ DECLARE(Bool, send_table_structure_on_insert_with_inline_data, true, R"( If disabled and the INSERT query contains inline data, the server will not send the table structure and column defaults back to the client over the native protocol. Instead, the server will parse the inline data itself. This can improve performance for many small inserts over the native protocol. )", 0, \ {"26.5", true, true, "New setting to control whether server sends table structure for INSERT queries with inline data."}) \ \ DECLARE(Bool, async_insert, true, R"( If true, data from INSERT query is stored in queue and later flushed to table in background. If wait_for_async_insert is false, INSERT query is processed almost instantly, otherwise client will wait until data will be flushed to table )", 0, \ {"26.2", false, true, "Enable async inserts by default."}) \ DECLARE(Bool, async_insert_select_as_async_insert, true, R"( Whether a user-initiated `INSERT ... SELECT` may use the asynchronous insert queue when `async_insert` is enabled and the query is eligible (a single small block into a `MergeTree`-family destination with no dependent views). When disabled, `INSERT ... SELECT` always runs synchronously regardless of `async_insert`. Internal inserts (refreshable materialized view, `POPULATE`, `CREATE TABLE ... AS SELECT`) are always synchronous and ignore this setting. )", 0, \ {"26.10", false, true, "Enable async inserts for `INSERT ... SELECT` queries by default."}) \ DECLARE(Bool, wait_for_async_insert, true, R"( If true wait for processing of asynchronous insertion. )", 0) \ DECLARE(Seconds, wait_for_async_insert_timeout, DBMS_DEFAULT_LOCK_ACQUIRE_TIMEOUT_SEC, R"( Timeout for waiting for processing asynchronous insertion. )", 0) \ DECLARE(UInt64, async_insert_max_data_size, 10485760, R"( Maximum size in bytes of unparsed data collected per query before being inserted Cloud default value: `104857600` (100 MiB). )", 0, \ {"24.2", 1000000, 10485760, "The previous value appeared to be too small."}) \ DECLARE(UInt64, async_insert_max_query_number, 450, R"( Maximum number of insert queries before being inserted. Only takes effect if setting [`async_insert_deduplicate`](#async_insert_deduplicate) is 1. )", 0) \ DECLARE(Milliseconds, async_insert_poll_timeout_ms, 10, R"( Timeout for polling data from asynchronous insert queue )", 0, \ {"24.2", 10, 10, "Timeout in milliseconds for polling data from asynchronous insert queue"}) \ DECLARE(Bool, async_insert_use_adaptive_busy_timeout, true, R"( If it is set to true, use adaptive busy timeout for asynchronous inserts )", 0, \ {"24.2", false, true, "Use adaptive asynchronous insert timeout"}) \ DECLARE(Milliseconds, async_insert_busy_timeout_min_ms, 50, R"( If auto-adjusting is enabled through async_insert_use_adaptive_busy_timeout, minimum time to wait before dumping collected data per query since the first data appeared. It also serves as the initial value for the adaptive algorithm )", 0, \ {"24.2", 50, 50, "The minimum value of the asynchronous insert timeout in milliseconds; it also serves as the initial value, which may be increased later by the adaptive algorithm"}) \ DECLARE_WITH_ALIAS(Milliseconds, async_insert_busy_timeout_max_ms, 200, R"( Maximum time to wait before dumping collected data per query since the first data appeared. Cloud default value: `1000` (1s). )", 0, async_insert_busy_timeout_ms, \ {"24.2", 200, 200, "The minimum value of the asynchronous insert timeout in milliseconds; async_insert_busy_timeout_ms is aliased to async_insert_busy_timeout_max_ms"}) \ DECLARE(Double, async_insert_busy_timeout_increase_rate, 0.2, R"( The exponential growth rate at which the adaptive asynchronous insert timeout increases )", 0, \ {"24.2", 0.2, 0.2, "The exponential growth rate at which the adaptive asynchronous insert timeout increases"}) \ DECLARE(Double, async_insert_busy_timeout_decrease_rate, 0.2, R"( The exponential growth rate at which the adaptive asynchronous insert timeout decreases )", 0, \ {"24.2", 0.2, 0.2, "The exponential growth rate at which the adaptive asynchronous insert timeout decreases"}) \ \ DECLARE(UInt64, remote_fs_read_max_backoff_ms, 10000, R"( Max wait time when trying to read data for remote disk )", 0) \ DECLARE(UInt64, remote_fs_read_backoff_max_tries, 5, R"( Max attempts to read with backoff )", 0) \ DECLARE(Bool, cluster_function_process_archive_on_multiple_nodes, true, R"( If set to `true`, increases performance of processing archives in cluster functions. Should be set to `false` for compatibility and to avoid errors during upgrade to 25.7+ if using cluster functions with archives on earlier versions. )", 0, \ {"25.7", false, true, "New setting"}) \ DECLARE(UInt64, max_streams_for_files_processing_in_cluster_functions, 0, R"( If is not zero, limit the number of threads reading data from files in *Cluster table functions. )", 0, \ {"25.12", 0, 0, "Add a new setting that allows to limit number of streams for files processing in *Cluster table functions"}) \ DECLARE(Milliseconds, cluster_function_wait_for_replica_ms, 0, R"( How long the initiator of a `*Cluster` table function or of parallel replicas over object storage waits for a replica to ask for tasks before giving the files assigned to that replica to other replicas. `0` disables the wait. )", 0, \ {"26.10", 0, 0, "New setting"}) \ DECLARE(Bool, enable_filesystem_cache, true, R"( Use cache for remote filesystem. This setting does not turn on/off cache for disks (must be done via disk config), but allows to bypass cache for some queries if intended )", 0) \ DECLARE(String, filesystem_cache_name, "", R"( Filesystem cache name to use for stateless table engines or data lakes )", 0, \ {"24.10", "", "", "Filesystem cache name to use for stateless table engines or data lakes"}) \ DECLARE(Bool, enable_filesystem_cache_on_write_operations, false, R"( Enables or disables `write-through` cache. If set to `false`, the `write-through` cache is disabled for write operations. If set to `true`, `write-through` cache is enabled as long as `cache_on_write_operations` is turned on in the server config's cache disk configuration section. See ["Using local cache"](/concepts/features/configuration/server-config/storing-data#using-local-cache) for more details. Cloud default value: `1`. )", 0) \ DECLARE(Bool, enable_filesystem_cache_log, false, R"( Allows to record the filesystem caching log for each query )", 0) \ DECLARE(Bool, filesystem_cache_verbose_logging, false, R"( Emit `TEST`-level log messages for every filesystem cache buffer refill (state of the read, remaining size to read, bytes read). Only for debugging: the messages are formatted once per read, so enabling it on a query that does many small cached reads adds a large amount of logging overhead. The messages are only visible when the log level is `test` anyway (see `send_logs_level`). )", 0, \ {"26.8", false, false, "New setting gating the per-buffer-refill TEST-level log messages of the filesystem cache read buffer, which were previously emitted unconditionally once the log level allowed them."}) \ DECLARE(Bool, read_from_filesystem_cache_if_exists_otherwise_cache_temporarily, false, R"( Use the filesystem cache as a temporary buffer for data that is not in it: a miss is read into the cache and served from it, and the cache removes it when nobody holds it anymore, unless a reader or writer outside this mode used it. Only the experimental `ReaderExecutor` supports it; other readers bypass the cache. `read_from_filesystem_cache_if_exists_otherwise_bypass_cache` takes precedence. )", EXPERIMENTAL, \ {"26.11", false, false, "New experimental setting."}) \ DECLARE(Bool, read_from_filesystem_cache_if_exists_otherwise_bypass_cache, false, R"( Allow to use the filesystem cache in passive mode - benefit from the existing cache entries, but don't put more entries into the cache. If you set this setting for heavy ad-hoc queries and leave it disabled for short real-time queries, this will allows to avoid cache threshing by too heavy queries and to improve the overall system efficiency. )", 0) \ DECLARE(Bool, throw_on_error_from_cache_on_write_operations, false, R"( Ignore error from cache when caching on write operations (INSERT, merges) )", 0) \ DECLARE(UInt64, filesystem_cache_segments_batch_size, 20, R"( Limit on size of a single batch of file segments that a read buffer can request from cache. Too low value will lead to excessive requests to cache, too large may slow down eviction from cache )", 0) \ DECLARE(UInt64, filesystem_cache_reserve_space_wait_lock_timeout_milliseconds, 1000, R"( Wait time to lock cache for space reservation in filesystem cache )", 0, \ {"24.3", 1000, 1000, "Wait time to lock cache for space reservation in filesystem cache"}) \ DECLARE(UInt64, filesystem_cache_wait_for_concurrent_download_timeout_milliseconds, 1000, R"( Maximum time to wait for a file segment which is being downloaded to the filesystem cache by a concurrent query. When the timeout is reached, the read bypasses the filesystem cache for that range and reads directly from remote storage, while the concurrent download continues to fill the cache. Value `0` means do not wait at all: bypass the cache immediately if the needed range is not downloaded yet. Lowering this value bounds the tail latency of cache-hit reads which would otherwise wait for another query's download pace at the cost of additional requests to remote storage. )", 0, \ {"26.8", 1000, 1000, "The change was backported to 26.3 and 26.5 and is recorded there."}, \ {"26.5", 60000, 1000, "The bounded wait is the default again: 26.4 does not have this setting."}, \ {"26.4", 1000, 60000, "26.4 does not have this setting, which was backported to 26.3 and 26.5 but not to 26.4."}, \ {"26.3", 60000, 1000, "New setting to bound how long a read waits for a file segment being downloaded to the filesystem cache by a concurrent query; on timeout the read bypasses the cache instead of waiting indefinitely. The previous value 60000 corresponds to the old behavior (one full 60 s wait cycle on the downloader)."}) \ DECLARE(Bool, filesystem_cache_prefer_bigger_buffer_size, true, R"( Prefer bigger buffer size if filesystem cache is enabled to avoid writing small file segments which deteriorate cache performance. On the other hand, enabling this setting might increase memory usage. )", 0, \ {"24.11", true, true, "New setting"}) \ DECLARE(UInt64, filesystem_cache_boundary_alignment, 0, R"( Filesystem cache boundary alignment. For non-disk read (e.g. for cache of remote table engines / table functions) value 0 means no alignment. For disk read (e.g. for MergeTree tables on a disk with cache) value 0 means that `boundary_alignment` from the cache configuration is used. The value is capped at `max_file_segment_size` of the cache. )", 0, \ {"24.11", 0, 0, "New setting"}) \ DECLARE(UInt64, temporary_data_in_cache_reserve_space_wait_lock_timeout_milliseconds, (10 * 60 * 1000), R"( Wait time to lock cache for space reservation for temporary data in filesystem cache )", 0, \ {"24.4", (10 * 60 * 1000), (10 * 60 * 1000), "Wait time to lock cache for space reservation in temporary data in filesystem cache"}) \ \ DECLARE(Bool, use_page_cache_for_disks_without_file_cache, false, R"( Use userspace page cache for remote disks that don't have filesystem cache enabled. )", 0, \ {"24.3", false, false, "Added userspace page cache"}) \ DECLARE(Bool, use_page_cache_with_distributed_cache, false, R"( Use userspace page cache when distributed cache is used. )", 0, \ {"25.3", false, false, "New setting"}) \ DECLARE(Bool, use_page_cache_for_local_disks, false, R"( Use userspace page cache when reading from local disks. Used for testing, unlikely to improve performance in practice. Requires local_filesystem_read_method = 'pread' or 'read'. Doesn't disable the OS page cache; min_bytes_to_use_direct_io can be used for that. Only affects regular tables, not file() table function or File() table engine. )", 0, \ {"26.2", false, false, "New setting to use userspace page cache for local disks"}) \ DECLARE(Bool, use_page_cache_for_object_storage, false, R"( Use userspace page cache when reading from object storage table functions (s3, azure, hdfs) and table engines (S3, Azure, HDFS). )", 0, \ {"26.2", false, false, "New setting to use userspace page cache for object storage table functions"}) \ DECLARE(Bool, read_from_page_cache_if_exists_otherwise_bypass_cache, false, R"( Use userspace page cache in passive mode, similar to read_from_filesystem_cache_if_exists_otherwise_bypass_cache. )", 0, \ {"24.3", false, false, "Added userspace page cache"}) \ DECLARE(Bool, page_cache_inject_eviction, false, R"( Userspace page cache will sometimes invalidate some pages at random. Intended for testing. )", 0, \ {"24.3", false, false, "Added userspace page cache"}) \ DECLARE(UInt64, page_cache_block_size, 1048576, R"( Size of file chunks to store in the userspace page cache, in bytes. All reads that go through the cache will be rounded up to a multiple of this size. This setting can be adjusted on a per-query level basis, but cache entries with different block sizes cannot be reused. Changing this setting effectively invalidates existing entries in the cache. A higher value, like 1 MiB is good for high-throughput queries, and a lower value, like 64 KiB is good for low-latency point queries. )", 0, \ {"25.5", 1048576, 1048576, "Made this setting adjustable on a per-query level."}) \ DECLARE(UInt64, page_cache_lookahead_blocks, 16, R"( On userspace page cache miss, read up to this many consecutive blocks at once from the underlying storage, if they're also not in the cache. Each block is page_cache_block_size bytes. A higher value is good for high-throughput queries, while low-latency point queries will work better without readahead. )", 0, \ {"25.5", 16, 16, "Made this setting adjustable on a per-query level."}) \ DECLARE(UInt64, page_cache_max_coalesced_bytes, 16777216, R"( When `readBigAt` populates the userspace page cache, consecutive cache misses are coalesced into a single read from the underlying storage. This setting bounds the size of one coalesced read in bytes; longer miss runs are split into multiple reads. It limits transient memory usage of the temporary buffer under parallel cold reads. A higher value reduces the number of HTTP requests for cold scans on object storage; a lower value reduces peak transient memory. )", 0, \ {"26.5", 16777216, 16777216, "New setting to bound the size of a single coalesced read used to populate the userspace page cache on cache miss."}) \ \ DECLARE(Bool, load_marks_asynchronously, true, R"( Load MergeTree marks asynchronously in a background thread pool (see the server setting `load_marks_threadpool_pool_size`), so that the marks of all streams are loaded in parallel. Otherwise, marks are loaded synchronously, one stream after another, which is slow on remote disks for columns with many substreams, such as `JSON`. )", 0, \ {"26.9", false, true, "Load marks of all streams in parallel by default. On remote disks, synchronous loading of marks of columns with many substreams (such as `JSON`) took one network round trip per stream."}) \ DECLARE(Bool, use_streaming_marks_compression, false, R"( When loading marks for MergeTree parts, compress them into the in-memory representation one block at a time (streaming) instead of materializing the full plain marks array first. This significantly reduces peak memory usage during marks loading for compact parts with many substreams (e.g. tables with JSON columns and write_marks_for_substreams_in_compact_parts enabled). )", 0, \ {"26.7", false, false, "New setting to compress marks into in-memory representation one block at a time (streaming) instead of materializing the full plain marks array, reducing peak memory during marks loading for compact parts with many substreams."}) \ DECLARE(Bool, enable_filesystem_read_prefetches_log, false, R"( Log to system.filesystem prefetch_log during query. Should be used only for testing or debugging, not recommended to be turned on by default )", 0) \ DECLARE(Bool, allow_prefetched_read_pool_for_remote_filesystem, true, R"( Prefer prefetched threadpool if all parts are on remote filesystem )", 0) \ DECLARE(Bool, allow_prefetched_read_pool_for_local_filesystem, false, R"( Prefer prefetched threadpool if all parts are on local filesystem )", 0) \ \ DECLARE(UInt64, prefetch_buffer_size, DBMS_DEFAULT_BUFFER_SIZE, R"( The maximum size of the prefetch buffer to read from the filesystem. Values above 256 MiB are clamped to 256 MiB, as a read buffer never needs to be larger. )", 0) \ DECLARE(UInt64, filesystem_prefetch_step_bytes, 0, R"( Prefetch step in bytes. Zero means `auto` - approximately the best prefetch step will be auto deduced, but might not be 100% the best. The actual value might be different because of setting filesystem_prefetch_min_bytes_for_single_read_task )", 0) \ DECLARE(UInt64, filesystem_prefetch_step_marks, 0, R"( Prefetch step in marks. Zero means `auto` - approximately the best prefetch step will be auto deduced, but might not be 100% the best. The actual value might be different because of setting filesystem_prefetch_min_bytes_for_single_read_task )", 0) \ DECLARE(NonZeroUInt64, filesystem_prefetch_max_memory_usage, "1Gi", R"( Maximum memory usage for prefetches. It also applies to merges and mutations. Cloud default value: 10% of total memory. )", 0) \ DECLARE(UInt64, filesystem_prefetches_limit, 200, R"( Maximum number of prefetches. Zero means unlimited. A setting `filesystem_prefetches_max_memory_usage` is more recommended if you want to limit the number of prefetches It also applies to merges and mutations. )", 0) \ \ DECLARE(Bool, allow_calculating_subcolumns_sizes_for_merge_tree_reading, true, R"( When enabled, ClickHouse will calculate the size of files required for each subcolumn reading for better task and block sizes calculation. )", 0, \ {"26.3", false, true, "Allow calculating subcolumns sizes for merge tree reading to improve read tasks splitting"}) \ \ DECLARE(UInt64, use_structure_from_insertion_table_in_table_functions, 2, R"( Use structure from insertion table instead of schema inference from data. Possible values: 0 - disabled, 1 - enabled, 2 - auto )", 0, \ {"22.11", 0, 2, "Improve using structure from insertion table in table functions"}) \ \ DECLARE(UInt64, http_max_tries, 10, R"( Max attempts to read via http. )", 0) \ DECLARE(UInt64, http_retry_initial_backoff_ms, 100, R"( Min milliseconds for backoff, when retrying read via http )", 0) \ DECLARE(UInt64, http_retry_max_backoff_ms, 10000, R"( Max milliseconds for backoff, when retrying read via http )", 0) \ \ DECLARE(Bool, force_remove_data_recursively_on_drop, false, R"( Recursively remove data on DROP query. Avoids 'Directory not empty' error, but may silently remove detached data )", 0) \ DECLARE(Bool, check_table_dependencies, true, R"( Check that DDL query (such as DROP TABLE or RENAME) will not break dependencies )", 0) \ DECLARE(Bool, check_referential_table_dependencies, false, R"( Check that DDL query (such as DROP TABLE or RENAME) will not break referential dependencies )", 0) \ DECLARE(Bool, check_named_collection_dependencies, true, R"( Check that DROP NAMED COLLECTION will not break tables that depend on it )", 0, \ {"26.2", true, true, "New setting to check if dropping a named collection would break dependent tables."}) \ \ DECLARE(Bool, allow_unrestricted_reads_from_keeper, false, R"( Allow unrestricted (without condition on path) reads from system.zookeeper table, can be handy, but is not safe for zookeeper )", 0) \ DECLARE(Bool, allow_deprecated_database_ordinary, false, R"( Allow to create databases with deprecated Ordinary engine )", 0) \ DECLARE(Bool, allow_deprecated_syntax_for_merge_tree, false, R"( Allow to create *MergeTree tables with deprecated engine definition syntax )", 0) \ DECLARE(Bool, allow_asynchronous_read_from_io_pool_for_merge_tree, false, R"( Use background I/O pool to read from MergeTree tables. This setting may increase performance for I/O bound queries )", 0) \ DECLARE(UInt64, max_streams_for_merge_tree_reading, 0, R"( If is not zero, limit the number of reading streams for MergeTree table. )", 0) \ \ DECLARE(Bool, force_grouping_standard_compatibility, true, R"( Make GROUPING function to return 1 when argument is not used as an aggregation key )", 0, \ {"22.9", false, true, "Make GROUPING function output the same as in SQL standard and other DBMS"}) \ \ DECLARE(Bool, allow_rank_dense_rank_arguments, false, R"( Allow passing arguments to the `RANK` and `DENSE_RANK` window functions for backward compatibility. Per SQL standard, `RANK` and `DENSE_RANK` take zero arguments — they rank rows based on the `OVER (ORDER BY ...)` window only. In ClickHouse versions before 26.5, queries such as `RANK(x) OVER (...)` silently accepted and ignored the argument, which led to user confusion (the visible argument suggested it influenced the ranking, but it did not). When this setting is `false` (the default), `RANK` and `DENSE_RANK` reject any arguments and throw `NUMBER_OF_ARGUMENTS_DOESNT_MATCH`. When set to `true`, the legacy lenient behavior is restored — arguments are silently ignored, matching the pre-26.5 behavior. )", 0, \ {"26.5", true, false, "New setting. Before 26.5, the `RANK` and `DENSE_RANK` window functions silently ignored any provided arguments (equivalent to `allow_rank_dense_rank_arguments = 1`). From 26.5, they reject arguments by default with `NUMBER_OF_ARGUMENTS_DOESNT_MATCH` because per SQL standard these functions take zero arguments. Set this to `1` to restore the legacy behavior."}) \ \ DECLARE(Bool, schema_inference_use_cache_for_file, true, R"( Use cache in schema inference while using file table function )", 0) \ DECLARE(Bool, schema_inference_use_cache_for_s3, true, R"( Use cache in schema inference while using s3 table function )", 0) \ DECLARE(Bool, schema_inference_use_cache_for_azure, true, R"( Use cache in schema inference while using azure table function )", 0) \ DECLARE(Bool, schema_inference_use_cache_for_hdfs, true, R"( Use cache in schema inference while using hdfs table function )", 0) \ DECLARE(Bool, schema_inference_use_cache_for_url, true, R"( Use cache in schema inference while using url table function )", 0) \ DECLARE(Bool, schema_inference_cache_require_modification_time_for_url, true, R"( Use schema from cache for URL with last modification time validation (for URLs with Last-Modified header) )", 0) \ \ DECLARE(String, compatibility, "", R"( The `compatibility` setting causes ClickHouse to use the default settings of a previous version of ClickHouse, with exceptions recorded in the settings changes history. If settings are set to non-default values, then those settings are honored (only settings that have not been modified are affected by the `compatibility` setting). The `compatibility` setting never applies a value that the user could not set: a setting keeps its default if the previous version's default would violate the [constraints](/concepts/features/configuration/settings/constraints-on-settings) of the user's settings profiles, or if the setting belongs to a tier that [`allow_feature_tier`](/reference/settings/server-settings/settings/allow#allow_feature_tier) disables. Changes marked `Ignore` in [`system.settings_changes`](/reference/system-tables/settings_changes) block rollback of that change and all earlier changes to the same setting. This setting takes a ClickHouse version number as a string, like `22.3`, `22.8`. An empty value means that this setting is disabled. Disabled by default. In ClickHouse Cloud, the service-level default compatibility setting must be set by ClickHouse Cloud support. Please [open a case](https://clickhouse.cloud/support) to have it set. However, the compatibility setting can be overridden at the user, role, profile, query, or session level using standard ClickHouse setting mechanisms such as `SET compatibility = '22.3'` in a session or `SETTINGS compatibility = '22.3'` in a query. )", 0) \ \ DECLARE(Map, additional_table_filters, "", R"( An additional filter expression that is applied after reading from the specified table. **Example** ```sql INSERT INTO table_1 VALUES (1, 'a'), (2, 'bb'), (3, 'ccc'), (4, 'dddd'); SELECT * FROM table_1; ``` ```response ┌─x─┬─y────┐ │ 1 │ a │ │ 2 │ bb │ │ 3 │ ccc │ │ 4 │ dddd │ └───┴──────┘ ``` ```sql SELECT * FROM table_1 SETTINGS additional_table_filters = {'table_1': 'x != 2'} ``` ```response ┌─x─┬─y────┐ │ 1 │ a │ │ 3 │ ccc │ │ 4 │ dddd │ └───┴──────┘ ``` Filters keyed on a table read through a view with `SQL SECURITY DEFINER` or `NONE` are not applied inside the view. )", 0) \ DECLARE(String, additional_result_filter, "", R"( An additional filter expression to apply to the result of `SELECT` query. This setting is not applied to any subquery. **Example** ```sql INSERT INTO table_1 VALUES (1, 'a'), (2, 'bb'), (3, 'ccc'), (4, 'dddd'); SElECT * FROM table_1; ``` ```response ┌─x─┬─y────┐ │ 1 │ a │ │ 2 │ bb │ │ 3 │ ccc │ │ 4 │ dddd │ └───┴──────┘ ``` ```sql SELECT * FROM table_1 SETTINGS additional_result_filter = 'x != 2' ``` ```response ┌─x─┬─y────┐ │ 1 │ a │ │ 3 │ ccc │ │ 4 │ dddd │ └───┴──────┘ ``` )", 0) \ \ DECLARE(String, workload, "default", R"( Name of workload to be used to access resources )", 0) \ DECLARE(Double, weight, 1.0, R"( Base scheduling weight of the query within its workload, used by the `fair` workload scheduler (see the `scheduler` workload setting). Queries with a higher weight receive a proportionally larger share of a time-shared resource (CPU, IO) when they compete inside the same workload. Ignored by the default `fifo` scheduler. A non-positive value (`<= 0`) is meaningless for the fair share and is treated as the default `1.0`. )", 0, \ {"26.10", 1.0, 1.0, "New query setting: base scheduling weight of a query within its workload, used by the `fair` workload scheduler."}) \ DECLARE(Double, weight_lowering_factor, 1.0, R"( For the `fair` workload scheduler: once the query crosses any of the `weight_lowering_*` thresholds below, its effective weight is multiplied by this factor once (values in (0, 1) lower the weight, biasing scheduling toward shorter/newer queries). The thresholds do not combine — the first one to trip applies the full lowering. `1.0` disables lowering. The value is clamped to the range `[0, 1]`, so the factor can only ever lower a query's weight, never raise it. )", 0, \ {"26.10", 1.0, 1.0, "New query setting: factor applied to a query's weight once it crosses a weight-lowering threshold in the `fair` workload scheduler."}) \ DECLARE(Double, weight_lowering_age_seconds, 0, R"( For the `fair` workload scheduler: once the query has been running (wall-clock) for this many seconds, its weight is lowered by `weight_lowering_factor`. `0` (or any negative value) disables the age threshold. )", 0, \ {"26.10", 0, 0, "New query setting: wall-clock age threshold after which a query's weight is lowered in the `fair` workload scheduler."}) \ DECLARE(Double, weight_lowering_cpu_seconds, 0, R"( For the `fair` workload scheduler: once the query has attained this many CPU-seconds, its weight is lowered by `weight_lowering_factor`. Applies to CPU resources. `0` (or any negative value) disables the CPU threshold. Attained CPU is the granted scheduler service, charged when a request is granted rather than as CPU is spent, so it leads actual consumption by at most one quantum (`cpu_slot_quantum_ns`) per active slot. This is only meaningful with CPU slot preemption (`cpu_slot_preemption = 1`, the default); without preemption CPU slots carry a fixed per-slot cost rather than real CPU time, so this threshold — like the other `fair` CPU settings — no longer reflects actual CPU consumption. )", 0, \ {"26.10", 0, 0, "New query setting: attained CPU-seconds threshold after which a query's weight is lowered in the `fair` workload scheduler."}) \ DECLARE(Double, weight_lowering_io_bytes, 0, R"( For the `fair` workload scheduler: once the query has attained this many bytes of IO, its weight is lowered by `weight_lowering_factor`. Applies to IO resources. `0` (or any negative value) disables the IO threshold. )", 0, \ {"26.10", 0, 0, "New query setting: attained IO-bytes threshold after which a query's weight is lowered in the `fair` workload scheduler."}) \ DECLARE(Int64, workload_priority, 0, R"( Scheduling priority of the query within its workload, used by the `priority` workload scheduler (see the `scheduler` workload setting). Lower value = higher priority; the default `0` is the neutral baseline, a negative value raises the query above the default and a positive value lowers it. Queries of equal priority are served first-come-first-served. Ignored by the other schedulers. )", 0, \ {"26.10", 0, 0, "New query setting: scheduling priority of a query within its workload, used by the `priority` workload scheduler."}) \ DECLARE(Milliseconds, workload_admission_timeout_ms, 0, R"( The maximum time a query waits to be admitted by workload scheduling before it fails without starting. It bounds the combined wait for a query slot (from a `CREATE RESOURCE ... (QUERY)` resource, limited by the workload's `max_concurrent_queries`) and for a memory reservation (from a `CREATE RESOURCE ... (MEMORY RESERVATION)` resource together with the `reserve_memory` setting). Both are acquired before the query starts running, so this is the only way to bound that pre-execution wait: `max_execution_time` does not apply yet because the query has not started. When the timeout expires the query fails with one of two distinct errors, depending on which resource it was waiting for: `QUERY_SLOT_ACQUISITION_TIMEOUT` for a query slot, or `MEMORY_RESERVATION_ACQUISITION_TIMEOUT` for a memory reservation. Possible values: - Positive integer — timeout in milliseconds. - 0 — Infinite timeout: the query waits indefinitely for admission (default). It can still be rejected immediately when the workload's `max_waiting_queries` limit is reached. )", 0, \ {"26.9", 0, 0, "New setting bounding how long a query waits to be admitted by workload scheduling (acquiring its query slot and memory reservation) before failing; 0 (default) preserves the previous unbounded wait."}) \ DECLARE(Milliseconds, storage_system_stack_trace_pipe_read_timeout_ms, 100, R"( Maximum time to read from a pipe for receiving information from the threads when querying the `system.stack_trace` table. This setting is used for testing purposes and not meant to be changed by users. )", 0) \ \ DECLARE(String, rename_files_after_processing, "", R"( - **Type:** String - **Default value:** Empty string This setting allows to specify renaming pattern for files processed by `file` table function. When option is set, all files read by `file` table function will be renamed according to specified pattern with placeholders, only if files processing was successful. Renaming is a write to the source, so a query that reads the files with this option set requires the `WRITE ON FILE` grant in addition to `READ ON FILE`, and is refused in readonly mode (`readonly` above 0, which every HTTP GET request implies). `DESCRIBE` does not build the data-reading pipeline that renames, so neither of these two restrictions applies to it. ### Placeholders - `%a` — Full original filename (e.g., "sample.csv"). - `%f` — Original filename without extension (e.g., "sample"). - `%e` — Original file extension with dot (e.g., ".csv"). - `%t` — Timestamp (in microseconds). - `%%` — Percentage sign ("%"). ### Example - Option: `--rename_files_after_processing="processed_%f_%t%e"` - Query: `SELECT * FROM file('sample.csv')` If reading `sample.csv` is successful, file will be renamed to `processed_sample_1683473210851438.csv` )", 0) \ \ /* CLOUD ONLY */ \ DECLARE(BoolAuto, force_read_through_distributed_cache, Field("auto"), R"( Only has an effect in ClickHouse Cloud. Overrides the server setting `enable_read_through_distributed_cache` for a single query. `auto` (the default) means to follow the server setting. )", 0, \ {"26.9", "auto", "auto", "New setting overriding the server setting `enable_read_through_distributed_cache` for a single query."}, \ {"26.8", "auto", "auto", "New setting overriding the server setting `enable_read_through_distributed_cache` for a single query."}) \ DECLARE(BoolAuto, force_write_through_distributed_cache, Field("auto"), R"( Only has an effect in ClickHouse Cloud. Overrides the server setting `enable_write_through_distributed_cache` for a single query. `auto` (the default) means to follow the server setting. )", 0, \ {"26.9", "auto", "auto", "New setting overriding the server setting `enable_write_through_distributed_cache` for a single query."}, \ {"26.8", "auto", "auto", "New setting overriding the server setting `enable_write_through_distributed_cache` for a single query."}) \ DECLARE(Bool, distributed_cache_throw_on_error, false, R"( Only has an effect in ClickHouse Cloud. Rethrow exception happened during communication with distributed cache or exception received from distributed cache. Otherwise fallback to skipping distributed cache on error )", 0, \ {"24.10", 0, 0, "A setting for ClickHouse Cloud"}) \ DECLARE(DistributedCacheLogMode, distributed_cache_log_mode, DistributedCacheLogMode::LOG_ON_ERROR, R"( Only has an effect in ClickHouse Cloud. Mode for writing to system.distributed_cache_log )", 0, \ {"24.10", "on_error", "on_error", "A setting for ClickHouse Cloud"}) \ DECLARE(Bool, distributed_cache_fetch_metrics_only_from_current_az, true, R"( Only has an effect in ClickHouse Cloud. Fetch metrics only from current availability zone in system.distributed_cache_metrics, system.distributed_cache_events )", 0, \ {"24.10", 1, 1, "A setting for ClickHouse Cloud"}) \ DECLARE(UInt64, distributed_cache_connect_max_tries, default_distributed_cache_connect_max_tries, R"( Only has an effect in ClickHouse Cloud. Number of tries to connect to distributed cache if unsuccessful )", 0, \ {"25.8", 20, 5, "Changed setting value"}, \ {"25.1", 20, 20, "Cloud only"}, \ {"24.10", 20, 20, "A setting for ClickHouse Cloud"}) \ DECLARE(UInt64, distributed_cache_read_request_max_tries, default_distributed_cache_read_request_max_tries, R"( Only has an effect in ClickHouse Cloud. Number of tries to do distributed cache read request if unsuccessful )", 0, \ {"25.8", 20, 10, "Changed setting value"}, \ {"25.4", 20, 20, "New setting"}) \ DECLARE(UInt64, distributed_cache_write_request_max_tries, default_distributed_cache_write_request_max_tries, R"( Only has an effect in ClickHouse Cloud. Number of tries to do distributed cache write request if unsuccessful )", 0, \ {"26.4", 10, 10, "New setting"}) \ DECLARE(UInt64, distributed_cache_receive_response_wait_milliseconds, 60000, R"( Only has an effect in ClickHouse Cloud. Wait time in milliseconds to receive data for request from distributed cache )", 0, \ {"24.10", 60000, 60000, "A setting for ClickHouse Cloud"}) \ DECLARE(UInt64, distributed_cache_receive_timeout_milliseconds, 10000, R"( Only has an effect in ClickHouse Cloud. Wait time in milliseconds to receive any kind of response from distributed cache Cloud default value: `20000`. )", 0, \ {"24.10", 10000, 10000, "A setting for ClickHouse Cloud"}) \ DECLARE(UInt64, distributed_cache_wait_connection_from_pool_milliseconds, 100, R"( Only has an effect in ClickHouse Cloud. Wait time in milliseconds to receive connection from connection pool if distributed_cache_pool_behaviour_on_limit is wait )", 0, \ {"24.10", 100, 100, "A setting for ClickHouse Cloud"}) \ DECLARE(Bool, distributed_cache_bypass_connection_pool, false, R"( Only has an effect in ClickHouse Cloud. Allow to bypass distributed cache connection pool )", 0, \ {"24.10", 0, 0, "A setting for ClickHouse Cloud"}) \ DECLARE(DistributedCachePoolBehaviourOnLimit, distributed_cache_pool_behaviour_on_limit, DistributedCachePoolBehaviourOnLimit::WAIT, R"( Only has an effect in ClickHouse Cloud. Identifies behaviour of distributed cache connection on pool limit reached )", 0, \ {"25.1", "allocate_bypassing_pool", "wait", "Cloud only"}, \ {"24.10", "allocate_bypassing_pool", "allocate_bypassing_pool", "A setting for ClickHouse Cloud"}) \ DECLARE(UInt64, distributed_cache_alignment, 0, R"( Only has an effect in ClickHouse Cloud. A setting for testing purposes, do not change it )", 0, \ {"25.7", 0, 0, "Rename of distributed_cache_read_alignment"}) \ DECLARE(UInt64, distributed_cache_max_unacked_inflight_packets, default_distributed_cache_max_unacked_inflight_packets, R"( Only has an effect in ClickHouse Cloud. A maximum number of unacknowledged in-flight packets in a single distributed cache read request )", 0, \ {"24.10", 10, 10, "A setting for ClickHouse Cloud"}) \ DECLARE(UInt64, distributed_cache_data_packet_ack_window, default_distributed_cache_data_packet_ack_window, R"( Only has an effect in ClickHouse Cloud. A window for sending ACK for DataPacket sequence in a single distributed cache read request )", 0, \ {"24.10", 5, 5, "A setting for ClickHouse Cloud"}) \ DECLARE(Bool, distributed_cache_discard_connection_if_unread_data, true, R"( Only has an effect in ClickHouse Cloud. Discard connection if some data is unread. )", 0, \ {"24.11", true, true, "New setting"}, \ {"24.10", true, true, "New setting"}) \ DECLARE(UInt64, distributed_cache_min_inflight_bytes_to_discard_connection_on_seek, 4 * 1024 * 1024, R"( Only has an effect in ClickHouse Cloud. On a seek away from the current position of an open distributed cache stream, if the estimated number of in-flight bytes that would have to be discarded to keep reusing the connection (via the read range id mechanism) exceeds this value, drop the connection and open a new one instead. This avoids draining a large amount of unused data when seeks are frequent. 0 disables this and always reuses the connection. )", 0, \ {"26.8", 0, 4 * 1024 * 1024, "New setting to drop and reopen a distributed cache connection on a seek when too many in-flight bytes would otherwise be discarded. Defaults to 4 MiB; 0 restores the previous behavior (always reuse the connection via the read range id)."}) \ DECLARE(UInt64, distributed_cache_min_inflight_bytes_to_discard_connection, 4 * 1024 * 1024, R"( Only has an effect in ClickHouse Cloud. When a distributed cache read request is cancelled while data may still arrive, discard the connection if the estimated number of in-flight bytes exceeds this value; otherwise return it to the pool, and the next request on the connection drains them. 0 always discards the connection. On a seek, `distributed_cache_min_inflight_bytes_to_discard_connection_on_seek` first decides whether to re-request on the same connection; if the request is cancelled instead, this setting also applies. Unlike that setting, 0 here means "always discard". It has no effect if `distributed_cache_discard_connection_if_unread_data` is disabled, because the connection is then always kept. )", 0, \ {"26.11", 0, 4 * 1024 * 1024, "New setting to keep a distributed cache connection with a small amount of in-flight data when a read request is cancelled. Defaults to 4 MiB; 0 restores the previous behavior (discard the connection whenever data may still arrive)."}) \ DECLARE(UInt64, distributed_cache_min_bytes_for_seek, 0, R"( Only has an effect in ClickHouse Cloud. Minimum number of bytes to do seek in distributed cache. )", 0, \ {"25.1", 0, 0, "New private setting."}) \ DECLARE(UInt64, distributed_cache_credentials_refresh_period_seconds, default_distributed_cache_credentials_refresh_period_seconds, R"( Only has an effect in ClickHouse Cloud. A period of credentials refresh. )", 0, \ {"25.6", 5, 5, "New private setting"}) \ DECLARE(Bool, distributed_cache_read_only_from_current_az, true, R"( Only has an effect in ClickHouse Cloud. Allow to read only from current availability zone. If disabled, will read from all cache servers in all availability zones. )", 0, \ {"25.5", true, true, "New setting"}) \ DECLARE(UInt64, write_through_distributed_cache_buffer_size, 0, R"( Only has an effect in ClickHouse Cloud. The maximum size of the buffer which is written to distributed cache servers, per write buffer. It is independent of the buffer which is written to the object storage: that one keeps growing towards the upload part size. If 0, `DBMS_DEFAULT_BUFFER_SIZE` (1 MiB) is used. The buffer starts at `adaptive_write_buffer_initial_size` and grows up to this size only as the stream is written, so that a part does not allocate it for every stream it writes. )", 0, \ {"25.7", 0, 0, "New cloud setting"}) \ DECLARE(Bool, table_engine_read_through_distributed_cache, false, R"( Only has an effect in ClickHouse Cloud. Allow reading from distributed cache via table engines / table functions (s3, azure, etc). The cache is keyed on the object's ETag, so that an object overwritten in place is not served stale. An object whose ETag is missing or is not a strong content identifier is read from the object storage directly. )", 0, \ {"25.7", false, false, "New setting"}) \ DECLARE(UInt64, distributed_cache_connect_backoff_min_ms, default_distributed_cache_connect_backoff_min_ms, R"( Only has an effect in ClickHouse Cloud. Minimum backoff milliseconds for distributed cache connection creation. )", 0, \ {"25.8", 0, 0, "New setting"}) \ DECLARE(UInt64, distributed_cache_connect_backoff_max_ms, default_distributed_cache_connect_backoff_max_ms, R"( Only has an effect in ClickHouse Cloud. Maximum backoff milliseconds for distributed cache connection creation. )", 0, \ {"25.8", 50, 50, "New setting"}) \ DECLARE(Bool, distributed_cache_prefer_bigger_buffer_size, false, R"( Only has an effect in ClickHouse Cloud. Same as filesystem_cache_prefer_bigger_buffer_size, but for distributed cache. )", 0, \ {"25.10", false, false, "New setting."}) \ DECLARE(Bool, read_from_distributed_cache_if_exists_otherwise_bypass_cache, false, R"( Only has an effect in ClickHouse Cloud. Same as read_from_filesystem_cache_if_exists_otherwise_bypass_cache, but for distributed cache. )", 0, \ {"25.10", false, false, "New setting"}) \ DECLARE(UInt64, distributed_cache_connect_timeout_ms, default_distributed_cache_connect_timeout_ms, R"( Only has an effect in ClickHouse Cloud. Connection timeout when connecting to distributed cache server. )", 0, \ {"25.10", 50, 50, "New setting"}) \ DECLARE(UInt64, distributed_cache_receive_timeout_ms, default_distributed_cache_receive_timeout_ms, R"( Only has an effect in ClickHouse Cloud. Timeout for receiving data from distributed cache server, in milliseconds. If no bytes were received in this interval, the exception is thrown. )", 0, \ {"25.10", 3000, 3000, "New setting"}) \ DECLARE(UInt64, distributed_cache_send_timeout_ms, default_distributed_cache_send_timeout_ms, R"( Only has an effect in ClickHouse Cloud. Timeout for sending data to distributed cache server, in milliseconds. If a client needs to send some data but is not able to send any bytes in this interval, the exception is thrown. )", 0, \ {"25.10", 3000, 3000, "New setting"}) \ DECLARE(UInt64, distributed_cache_tcp_keep_alive_timeout_ms, default_distributed_cache_tcp_keep_alive_timeout_ms, R"( Only has an effect in ClickHouse Cloud. The time in milliseconds the connection to distributed cache server needs to remain idle before TCP starts sending keepalive probes. )", 0, \ {"25.10", 2900, 2900, "New setting"}) \ DECLARE(Bool, distributed_cache_use_clients_cache_for_read, default_distributed_cache_use_clients_cache_for_read, R"( Only has an effect in ClickHouse Cloud. Use clients cache for read requests. )", 0, \ {"25.12", true, true, "New setting"}) \ DECLARE(String, distributed_cache_file_cache_name, "", R"( Only has an effect in ClickHouse Cloud. A setting used only for CI tests - filesystem cache name to use on distributed cache. )", 0, \ {"26.1", "", "", "New setting."}) \ DECLARE(String, distributed_cache_client_id, "", R"( Only has an effect in ClickHouse Cloud. A setting used only for CI tests - overrides the registry-configured distributed cache client id for this query's requests when non-empty. Lets tests spread data across a bounded set of client ids while keeping the same data on the same client id. It requires `ci_mode` to be enabled in the distributed cache client config: when it is not (the default, as in production), a query that routes a read or write through the distributed cache fails with `SUPPORT_IS_DISABLED` instead of silently falling back to the configured client id. Queries that never reach the distributed cache are unaffected, so the value is ignored there. )", 0, \ {"26.9", "", "", "New setting (CI tests only) to override the distributed cache client id per query."}, \ {"26.8", "", "", "New setting (CI tests only) to override the distributed cache client id per query."}) \ DECLARE(Bool, distributed_cache_registry_show_certificate_and_signature, false, R"( Only has an effect in ClickHouse Cloud. Show the `certificate` and `signature` columns in the `system.distributed_cache_registry` table. By default these columns are empty to keep the output compact; enable this setting to inspect them. )", 0, \ {"26.6", false, false, "New setting to show the `certificate` and `signature` columns in `system.distributed_cache_registry`."}) \ DECLARE(Bool, filesystem_cache_allow_background_download, true, R"( Allow filesystem cache to enqueue background downloads for data read from remote storage. Disable to keep downloads in the foreground for the current query/session. )", 0, \ {"25.11", true, true, "New setting to control background downloads in filesystem cache per query."}) \ DECLARE(Bool, filesystem_cache_enable_background_download_for_metadata_files_in_packed_storage, true, R"( Only has an effect in ClickHouse Cloud. Wait time to lock cache for space reservation in filesystem cache )", 0, \ {"24.11", true, true, "New setting"}) \ DECLARE(Bool, filesystem_cache_enable_background_download_during_fetch, true, R"( Only has an effect in ClickHouse Cloud. Wait time to lock cache for space reservation in filesystem cache )", 0, \ {"24.11", true, true, "New setting"}) \ \ DECLARE(Bool, parallelize_output_from_storages, true, R"( Parallelize output for reading step from storage. It allows parallelization of query processing right after reading from storage if possible )", 0, \ {"23.5", false, true, "Allow parallelism when executing queries that read from file/url/s3/etc. This may reorder rows."}) \ DECLARE(String, insert_deduplication_token, "", R"( The setting allows a user to provide own deduplication semantic in MergeTree/ReplicatedMergeTree For example, by providing a unique value for the setting in each INSERT statement, user can avoid the same inserted data being deduplicated. Possible values: - Any string `insert_deduplication_token` is used for deduplication _only_ when not empty. For the replicated tables by default the only 100 of the most recent inserts for each partition are deduplicated (see [replicated_deduplication_window](/reference/settings/merge-tree-settings/replicated-deduplication-window#replicated_deduplication_window), [replicated_deduplication_window_seconds](/reference/settings/merge-tree-settings/replicated-deduplication-window#replicated_deduplication_window_seconds)). For not replicated tables see [non_replicated_deduplication_window](/reference/settings/merge-tree-settings/other#non_replicated_deduplication_window). `insert_deduplication_token` is tracked per partition, so multiple partitions written by one insert can carry the same token. Without a token, the default content checksum is computed over the whole inserted block, so an insert is deduplicated only when its entire data matches a previous insert (a retry), not when a single partition's rows happen to coincide with a different insert. Example: ```sql CREATE TABLE test_table ( A Int64 ) ENGINE = MergeTree ORDER BY A SETTINGS non_replicated_deduplication_window = 100; INSERT INTO test_table SETTINGS insert_deduplication_token = 'test' VALUES (1); -- the next insert won't be deduplicated because insert_deduplication_token is different INSERT INTO test_table SETTINGS insert_deduplication_token = 'test1' VALUES (1); -- the next insert will be deduplicated because insert_deduplication_token -- is the same as one of the previous INSERT INTO test_table SETTINGS insert_deduplication_token = 'test' VALUES (2); SELECT * FROM test_table ┌─A─┐ │ 1 │ └───┘ ┌─A─┐ │ 1 │ └───┘ ``` )", 0) \ DECLARE(Bool, optimize_inverse_dictionary_lookup, true, R"( Avoid repeated inverse dictionary lookup by doing faster lookups into a precomputed set of possible key values. )", 0, \ {"25.12", false, true, "New setting"}) \ DECLARE(Bool, throw_if_no_data_to_insert, true, R"( Allows or forbids empty INSERTs, enabled by default (throws an error on an empty insert). Only applies to INSERTs using [`clickhouse-client`](/concepts/features/interfaces/client) or using the [gRPC interface](/concepts/features/interfaces/grpc). )", 0) \ DECLARE(Bool, compatibility_ignore_auto_increment_in_create_table, false, R"( Ignore AUTO_INCREMENT keyword in column declaration if true, otherwise return error. It simplifies migration from MySQL )", 0) \ DECLARE(Bool, multiple_joins_try_to_keep_original_names, false, R"( Do not add aliases to top level expression list on multiple joins rewrite )", 0) \ DECLARE(Bool, optimize_sorting_by_input_stream_properties, true, R"( Optimize sorting by sorting properties of input stream )", 0) \ DECLARE(UInt64, keeper_max_retries, 10, R"( Max retries for general keeper operations )", 0, \ {"24.3", 10, 10, "Max retries for general keeper operations"}) \ DECLARE(UInt64, keeper_retry_initial_backoff_ms, 100, R"( Initial backoff timeout for general keeper operations )", 0, \ {"24.3", 100, 100, "Initial backoff timeout for general keeper operations"}) \ DECLARE(UInt64, keeper_retry_max_backoff_ms, 5000, R"( Max backoff timeout for general keeper operations )", 0, \ {"24.3", 5000, 5000, "Max backoff timeout for general keeper operations"}) \ DECLARE(UInt64, insert_keeper_max_retries, 20, R"( The setting sets the maximum number of retries for ClickHouse Keeper (or ZooKeeper) requests during insert into replicated MergeTree. Only Keeper requests which failed due to network error, Keeper session timeout, or request timeout are considered for retries. Possible values: - Positive integer. - 0 — Retries are disabled Keeper request retries are done after some timeout. The timeout is controlled by the following settings: `insert_keeper_retry_initial_backoff_ms`, `insert_keeper_retry_max_backoff_ms`. The first retry is done after `insert_keeper_retry_initial_backoff_ms` timeout. The consequent timeouts will be calculated as follows: ``` timeout = min(insert_keeper_retry_max_backoff_ms, latest_timeout * 2) ``` For example, if `insert_keeper_retry_initial_backoff_ms=100`, `insert_keeper_retry_max_backoff_ms=10000` and `insert_keeper_max_retries=8` then timeouts will be `100, 200, 400, 800, 1600, 3200, 6400, 10000`. Apart from fault tolerance, the retries aim to provide a better user experience - they allow to avoid returning an error during INSERT execution if Keeper is restarted, for example, due to an upgrade. )", 0, \ {"23.2", 0, 20, "Enable reconnections to Keeper on INSERT, improve reliability"}) \ DECLARE(UInt64, insert_keeper_retry_initial_backoff_ms, 100, R"( Initial timeout(in milliseconds) to retry a failed Keeper request during INSERT query execution Possible values: - Positive integer. - 0 — No timeout )", 0) \ DECLARE(UInt64, insert_keeper_retry_max_backoff_ms, 10000, R"( Maximum timeout (in milliseconds) to retry a failed Keeper request during INSERT query execution Possible values: - Positive integer. - 0 — Maximum timeout is not limited )", 0) \ DECLARE(Float, insert_keeper_fault_injection_probability, 0.0f, R"( Approximate probability of failure for a keeper request during insert. Valid value is in interval [0.0f, 1.0f] )", 0) \ DECLARE(UInt64, insert_keeper_fault_injection_seed, 0, R"( 0 - random seed, otherwise the setting value )", 0) \ DECLARE(Bool, force_aggregation_in_order, false, R"( The setting is used by the server itself to support distributed queries. Do not change it manually, because it will break normal operations. (Forces use of aggregation in order on remote nodes during distributed aggregation). )", IMPORTANT) \ DECLARE(UInt64, http_max_request_param_data_size, 10_MiB, R"( Limit on size of request data used as a query parameter in predefined HTTP requests. )", 0) \ DECLARE(Bool, function_json_value_return_type_allow_nullable, false, R"( Control whether allow to return `NULL` when value is not exist for JSON_VALUE function. ```sql SELECT JSON_VALUE('{"hello":"world"}', '$.b') settings function_json_value_return_type_allow_nullable=true; ┌─JSON_VALUE('{"hello":"world"}', '$.b')─┐ │ ᴺᵁᴸᴸ │ └────────────────────────────────────────┘ 1 row in set. Elapsed: 0.001 sec. ``` Possible values: - true — Allow. - false — Disallow. )", 0) \ DECLARE(Bool, function_json_value_return_type_allow_complex, false, R"( Control whether allow to return complex type (such as: struct, array, map) for json_value function. ```sql SELECT JSON_VALUE('{"hello":{"world":"!"}}', '$.hello') settings function_json_value_return_type_allow_complex=true ┌─JSON_VALUE('{"hello":{"world":"!"}}', '$.hello')─┐ │ {"world":"!"} │ └──────────────────────────────────────────────────┘ 1 row in set. Elapsed: 0.001 sec. ``` Possible values: - true — Allow. - false — Disallow. )", 0) \ DECLARE(Bool, use_with_fill_by_sorting_prefix, true, R"( Columns preceding WITH FILL columns in ORDER BY clause form sorting prefix. Rows with different values in sorting prefix are filled independently )", 0, \ {"23.5", false, true, "Columns preceding WITH FILL columns in ORDER BY clause form sorting prefix. Rows with different values in sorting prefix are filled independently"}) \ DECLARE(Bool, optimize_uniq_to_count, true, R"( Rewrite uniq and its variants(except uniqUpTo) to count if subquery has distinct or group by clause. )", 0) \ DECLARE(Bool, use_variant_as_common_type, true, R"( Allows to use `Variant` type as a result type for [if](/reference/functions/regular-functions/conditional-functions#if)/[multiIf](/reference/functions/regular-functions/conditional-functions#multiIf)/[array](/reference/functions/regular-functions/array-functions)/[map](/reference/functions/regular-functions/tuple-map-functions) functions when there is no common type for argument types. Example: ```sql SET use_variant_as_common_type = 1; SELECT toTypeName(if(number % 2, number, range(number))) as variant_type FROM numbers(1); SELECT if(number % 2, number, range(number)) as variant FROM numbers(5); ``` ```text ┌─variant_type───────────────────┐ │ Variant(Array(UInt64), UInt64) │ └────────────────────────────────┘ ┌─variant───┐ │ [] │ │ 1 │ │ [0,1] │ │ 3 │ │ [0,1,2,3] │ └───────────┘ ``` ```sql SET use_variant_as_common_type = 1; SELECT toTypeName(multiIf((number % 4) = 0, 42, (number % 4) = 1, [1, 2, 3], (number % 4) = 2, 'Hello, World!', NULL)) AS variant_type FROM numbers(1); SELECT multiIf((number % 4) = 0, 42, (number % 4) = 1, [1, 2, 3], (number % 4) = 2, 'Hello, World!', NULL) AS variant FROM numbers(4); ``` ```text ─variant_type─────────────────────────┐ │ Variant(Array(UInt8), String, UInt8) │ └──────────────────────────────────────┘ ┌─variant───────┐ │ 42 │ │ [1,2,3] │ │ Hello, World! │ │ ᴺᵁᴸᴸ │ └───────────────┘ ``` ```sql SET use_variant_as_common_type = 1; SELECT toTypeName(array(range(number), number, 'str_' || toString(number))) as array_of_variants_type from numbers(1); SELECT array(range(number), number, 'str_' || toString(number)) as array_of_variants FROM numbers(3); ``` ```text ┌─array_of_variants_type────────────────────────┐ │ Array(Variant(Array(UInt64), String, UInt64)) │ └───────────────────────────────────────────────┘ ┌─array_of_variants─┐ │ [[],0,'str_0'] │ │ [[0],1,'str_1'] │ │ [[0,1],2,'str_2'] │ └───────────────────┘ ``` ```sql SET use_variant_as_common_type = 1; SELECT toTypeName(map('a', range(number), 'b', number, 'c', 'str_' || toString(number))) as map_of_variants_type from numbers(1); SELECT map('a', range(number), 'b', number, 'c', 'str_' || toString(number)) as map_of_variants FROM numbers(3); ``` ```text ┌─map_of_variants_type────────────────────────────────┐ │ Map(String, Variant(Array(UInt64), String, UInt64)) │ └─────────────────────────────────────────────────────┘ ┌─map_of_variants───────────────┐ │ {'a':[],'b':0,'c':'str_0'} │ │ {'a':[0],'b':1,'c':'str_1'} │ │ {'a':[0,1],'b':2,'c':'str_2'} │ └───────────────────────────────┘ ``` )", 0, \ {"26.1", false, true, "Improves usability."}, \ {"24.1", false, false, "Allow to use Variant in if/multiIf if there is no common type"}) \ DECLARE(Bool, allow_lossy_numeric_supertype, false, R"( When enabled, `if`/`multiIf`/`coalesce`/`ifNull`/`array`/`map` over a set of numeric arguments that has no lossless common type (for example a `Decimal` and a `Float64`, or an `Int64` and a `Float64`) resolve to a numeric supertype (`Float64`) instead of failing, with possible precision loss. This allows the result to be used directly with value-combining aggregate functions like `sum`, `avg`, `min` and `max`. This is independent of `use_variant_as_common_type`: the numeric supertype is produced whether or not `use_variant_as_common_type` is enabled. When disabled (the default), such argument sets have no common type, so they either become a `Variant` (if `use_variant_as_common_type` is enabled) or raise `NO_COMMON_TYPE`. )", 0, \ {"26.8", false, false, "New setting that lets if/multiIf/coalesce/ifNull/array/map resolve all-numeric branches with no lossless common type (e.g. Decimal + Float64) to a numeric supertype (Float64, with possible precision loss), so the result can be aggregated. Independent of use_variant_as_common_type: with it off such branches previously raised NO_COMMON_TYPE, with it on they became a Variant; either way they now resolve to Float64."}) \ DECLARE(Bool, enable_order_by_all, true, R"( Enables or disables sorting with `ORDER BY ALL` syntax, see [ORDER BY](/reference/statements/select/order-by). Possible values: - 0 — Disable ORDER BY ALL. - 1 — Enable ORDER BY ALL. **Example** Query: ```sql CREATE TABLE TAB(C1 Int, C2 Int, ALL Int) ENGINE=Memory(); INSERT INTO TAB VALUES (10, 20, 30), (20, 20, 10), (30, 10, 20); SELECT * FROM TAB ORDER BY ALL; -- returns an error that ALL is ambiguous SELECT * FROM TAB ORDER BY ALL SETTINGS enable_order_by_all = 0; ``` Result: ```text ┌─C1─┬─C2─┬─ALL─┐ │ 20 │ 20 │ 10 │ │ 30 │ 10 │ 20 │ │ 10 │ 20 │ 30 │ └────┴────┴─────┘ ``` )", 0) \ DECLARE(Float, ignore_drop_queries_probability, 0, R"( If enabled, server will ignore all DROP table queries with specified probability (for Memory and JOIN engines it will replace DROP to TRUNCATE). Used for testing purposes )", 0, \ {"24.4", 0, 0, "Allow to ignore drop queries in server with specified probability for testing purposes"}) \ DECLARE(Bool, traverse_shadow_remote_data_paths, false, R"( Traverse frozen data (shadow directory) in addition to actual table data when query system.remote_data_paths )", 0, \ {"24.3", false, false, "Traverse shadow directory when query system.remote_data_paths."}) \ DECLARE(Bool, geo_distance_returns_float64_on_float64_arguments, true, R"( If all four arguments to `geoDistance`, `greatCircleDistance`, `greatCircleAngle` functions are Float64, return Float64 and use double precision for internal calculations. In previous ClickHouse versions, the functions always returned Float32. )", 0, \ {"24.3", false, true, "Increase the default precision."}) \ DECLARE(Bool, allow_get_client_http_header, false, R"( Allow to use the function `getClientHTTPHeader` which lets to obtain a value of the current HTTP request's header. It is not enabled by default for security reasons, because some headers, such as `Cookie`, could contain sensitive info. Note that the `X-ClickHouse-*`, `Authentication` and `Authorization` headers are always restricted and cannot be obtained with this function. )", 0, \ {"24.3", false, false, "Introduced a new function."}) \ DECLARE(Bool, cast_string_to_dynamic_use_inference, false, R"( Use types inference during String to Dynamic conversion )", 0, \ {"24.5", false, false, "Add setting to allow converting String to Dynamic through parsing"}) \ DECLARE(Bool, allow_dynamic_type_in_join_keys, false, R"( Allows using Dynamic type in JOIN keys. Added for compatibility. It's not recommended to use Dynamic type in JOIN keys because comparison with other types may lead to unexpected results. )", 0, \ {"25.10", true, false, "Disallow using Dynamic type in JOIN keys by default"}) \ DECLARE(Bool, cast_string_to_variant_use_inference, true, R"( Use types inference during String to Variant conversion. )", 0, \ {"25.4", true, true, "New setting to enable/disable types inference during CAST from String to Variant"}) \ DECLARE(DateTimeInputFormat, cast_string_to_date_time_mode, "best_effort", R"( Allows choosing a parser of the text representation of date and time during cast from String. Possible values: - `'best_effort'` — Enables extended parsing. 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'`. - `'best_effort_us'` — Similar to `best_effort` (see the difference in [parseDateTimeBestEffortUS](/reference/functions/regular-functions/type-conversion-functions#parseDateTimeBestEffortUS) - `'basic'` — Use basic parser. ClickHouse can parse only the basic `YYYY-MM-DD HH:MM:SS` or `YYYY-MM-DD` format. For example, `2019-08-20 10:18:56` or `2019-08-20`. See also: - [DateTime data type.](/reference/data-types/datetime) - [Functions for working with dates and times.](/reference/functions/regular-functions/date-time-functions) )", 0, \ {"26.5", "basic", "best_effort", "Better usability"}, \ {"25.6", "basic", "basic", "Allow to use different DateTime parsing mode in String to DateTime cast"}) \ DECLARE(Bool, enable_blob_storage_log, true, R"( Write information about blob storage operations to system.blob_storage_log table )", 0, \ {"24.6", true, true, "Write information about blob storage operations to system.blob_storage_log table"}) \ DECLARE(Bool, enable_blob_storage_log_for_read_operations, false, R"( Write information about blob storage read operations to system.blob_storage_log table. Requires `enable_blob_storage_log` to be enabled as well. )", 0, \ {"26.5", false, false, "New setting to log blob storage read operations to system.blob_storage_log"}) \ DECLARE(UInt64, predicate_statistics_sample_rate, 0, R"( Collect predicate selectivity statistics into `system.predicate_statistics_log`. When set to N > 0, approximately 1/N of queries are sampled (by the query ID). 0 means disabled. )", 0, \ {"26.5", 0, 0, "New setting to collect predicate selectivity statistics into system.predicate_statistics_log"}) \ DECLARE(Bool, allow_create_index_without_type, false, R"( Allow CREATE INDEX query without TYPE. Query will be ignored. Made for SQL compatibility tests. )", 0) \ DECLARE(Bool, create_index_ignore_unique, false, R"( Ignore UNIQUE keyword in CREATE UNIQUE INDEX. Made for SQL compatibility tests. )", 0) \ DECLARE(Bool, print_pretty_type_names, true, R"( Allows to print deep-nested type names in a pretty way with indents in `DESCRIBE` query and in `toTypeName()` function. Example: ```sql CREATE TABLE test (a Tuple(b String, c Tuple(d Nullable(UInt64), e Array(UInt32), f Array(Tuple(g String, h Map(String, Array(Tuple(i String, j UInt64))))), k Date), l Nullable(String))) ENGINE=Memory; DESCRIBE TABLE test FORMAT TSVRaw SETTINGS print_pretty_type_names=1; ``` ``` a Tuple( b String, c Tuple( d Nullable(UInt64), e Array(UInt32), f Array(Tuple( g String, h Map( String, Array(Tuple( i String, j UInt64 )) ) )), k Date ), l Nullable(String) ) ``` )", 0, \ {"24.1", false, true, "Better user experience."}) \ DECLARE(Bool, create_table_empty_primary_key_by_default, true, R"( Allow to create *MergeTree tables with empty primary key when ORDER BY and PRIMARY KEY not specified )", 0, \ {"25.11", false, true, "Better usability"}) \ DECLARE(SQLSecurityType, default_normal_view_sql_security, SQLSecurityType::INVOKER, R"( Allows to set default `SQL SECURITY` option while creating a normal view. [More about SQL security](/reference/statements/create/view#sql_security). The default value is `INVOKER`. )", 0, \ {"24.2", "INVOKER", "INVOKER", "Allows to set default `SQL SECURITY` option while creating a normal view"}) \ DECLARE(SQLSecurityType, default_materialized_view_sql_security, SQLSecurityType::DEFINER, R"( Allows to set a default value for SQL SECURITY option when creating a materialized view. [More about SQL security](/reference/statements/create/view#sql_security). The default value is `DEFINER`. )", 0, \ {"24.2", "DEFINER", "DEFINER", "Allows to set a default value for SQL SECURITY option when creating a materialized view"}) \ DECLARE(String, default_view_definer, "CURRENT_USER", R"( Allows to set default `DEFINER` option while creating a view. [More about SQL security](/reference/statements/create/view#sql_security). The default value is `CURRENT_USER`. )", 0, \ {"24.2", "CURRENT_USER", "CURRENT_USER", "Allows to set default `DEFINER` option while creating a view"}) \ DECLARE(UInt64, cache_warmer_threads, 4, R"( Only has an effect in ClickHouse Cloud. Number of background threads for speculatively downloading new data parts into the filesystem cache, when [cache_populated_by_fetch](/reference/settings/merge-tree-settings/cache-populated-by-fetch#cache_populated_by_fetch) is enabled. Zero to disable. )", 0) \ DECLARE(Bool, use_async_executor_for_materialized_views, false, R"( Use async and potentially multithreaded execution of materialized view query, can speedup views processing during INSERT, but also consume more memory.)", 0, \ {"24.12", false, false, "New setting."}) \ DECLARE(Int64, ignore_cold_parts_seconds, 0, R"( Only has an effect in ClickHouse Cloud. Exclude new data parts from SELECT queries until they're either pre-warmed (see [cache_populated_by_fetch](/reference/settings/merge-tree-settings/cache-populated-by-fetch#cache_populated_by_fetch)) or this many seconds old. Only for Replicated-/SharedMergeTree. )", 0) \ DECLARE(Bool, short_circuit_function_evaluation_for_nulls, true, R"( Optimizes evaluation of functions that return NULL when any argument is NULL. When the percentage of NULL values in the function's arguments exceeds the short_circuit_function_evaluation_for_nulls_threshold, the system skips evaluating the function row-by-row. Instead, it immediately returns NULL for all rows, avoiding unnecessary computation. This setting controls an optimization only. Functions that cannot be executed on the default value of their arguments - such as `parseDateTime`, `IPv4StringToNum` or `intDiv` - always skip the rows containing a NULL regardless of this setting, because the value stored behind a NULL is the default value of the argument type and executing on it would throw on otherwise valid data. )", 0, \ {"25.1", false, true, "Allow to execute functions with Nullable arguments only on rows with non-NULL values in all arguments"}) \ DECLARE(Double, short_circuit_function_evaluation_for_nulls_threshold, 1.0, R"( Ratio threshold of NULL values to execute functions with Nullable arguments only on rows with non-NULL values in all arguments. Applies when setting short_circuit_function_evaluation_for_nulls is enabled. When the ratio of rows containing NULL values to the total number of rows exceeds this threshold, these rows containing NULL values will not be evaluated. )", 0, \ {"25.1", 1.0, 1.0, "Ratio threshold of NULL values to execute functions with Nullable arguments only on rows with non-NULL values in all arguments. Applies when setting short_circuit_function_evaluation_for_nulls is enabled."}) \ DECLARE(Bool, short_circuit_function_evaluation_reorder_arguments, true, R"( Allows changing the order in which the arguments of the [and](/reference/functions/regular-functions/logical-functions#and) and [or](/reference/functions/regular-functions/logical-functions#or) functions are evaluated with [short-circuit evaluation](#short_circuit_function_evaluation), when it does not change the result and does not introduce exceptions. - If the first argument is computationally heavy and another argument is cheap, the cheap argument is evaluated first, and the heavy one is evaluated only on the rows where the result is not yet decided. For example, in `WHERE JSONExtractString(json, 'a') = 'x' AND id < 100` the JSON is parsed only for the rows with `id < 100`. - The arguments that are evaluated lazily and cannot throw an exception are evaluated in the order of increasing time per row they decide, as measured on the previous blocks. The arguments that can throw an exception keep all the arguments that precede them in front of them, so that, for example, `x != 0 AND intDiv(1, x) > 0` never divides by zero. )", 0, \ {"26.10", false, true, "New setting."}) \ DECLARE(Int64, prefer_warmed_unmerged_parts_seconds, 0, R"( Only has an effect in ClickHouse Cloud. If a merged part is less than this many seconds old and is not pre-warmed (see [cache_populated_by_fetch](/reference/settings/merge-tree-settings/cache-populated-by-fetch#cache_populated_by_fetch)), but all its source parts are available and pre-warmed, SELECT queries will read from those parts instead. Only for Replicated-/SharedMergeTree. Note that this only checks whether CacheWarmer processed the part; if the part was fetched into cache by something else, it'll still be considered cold until CacheWarmer gets to it; if it was warmed, then evicted from cache, it'll still be considered warm. )", 0) \ DECLARE(Int64, iceberg_timestamp_ms, 0, R"( Query Iceberg table using the snapshot that was current at a specific timestamp. )", 0, \ {"25.4", 0, 0, "New setting."}) \ DECLARE(Int64, iceberg_snapshot_id, 0, R"( Query Iceberg table using the specific snapshot id. )", 0, \ {"25.4", 0, 0, "New setting."}) \ DECLARE_WITH_ALIAS(Bool, allow_geo_types_in_iceberg, false, R"( Allow parsing Iceberg `geometry` and `geography` field types as ClickHouse `Geometry` (Variant) type. )", 0, allow_experimental_geo_types_in_iceberg, \ {"26.9", false, false, "Added an alias for setting `allow_experimental_geo_types_in_iceberg`."}, \ {"26.5", false, false, "New setting to allow parsing Iceberg geometry/geography fields as Geometry type. At the time the setting was named `allow_experimental_geo_types_in_iceberg`, which is now an alias of it."}) \ DECLARE(Bool, show_data_lake_catalogs_in_system_tables, false, R"( Enables showing data lake catalogs in system tables. )", 0, \ {"25.10", true, false, "Disable catalogs in system tables by default"}, \ {"25.8", true, true, "New setting"}) \ DECLARE(Bool, show_remote_databases_in_system_tables, true, R"( Enables showing `MySQL` and `PostgreSQL` databases in system tables. )", 0, \ {"26.7", true, true, "New setting to control whether `MySQL` and `PostgreSQL` databases are shown in `system.tables`, `system.columns` and `system.completions`."}, \ {"26.2", true, true, "New setting to control whether `MySQL` and `PostgreSQL` databases are shown in `system.tables`, `system.columns` and `system.completions`."}) \ DECLARE(Bool, delta_lake_enable_expression_visitor_logging, false, R"( Enables Test level logs of DeltaLake expression visitor. These logs can be too verbose even for test logging. )", 0, \ {"25.8", false, false, "New setting"}) \ DECLARE(Int64, delta_lake_snapshot_version, -1, R"( Version of delta lake snapshot to read. Value -1 means to read latest version (value 0 is a valid snapshot version). )", 0, \ {"25.8", -1, -1, "New setting"}) \ DECLARE(Int64, delta_lake_snapshot_start_version, -1, R"( Start version of delta lake snapshot to read. Value -1 means to read latest version (value 0 is a valid snapshot version). )", 0, \ {"25.12", -1, -1, "New setting."}) \ DECLARE(Int64, delta_lake_snapshot_end_version, -1, R"( End version of delta lake snapshot to read. Value -1 means to read latest version (value 0 is a valid snapshot version). )", 0, \ {"25.12", -1, -1, "New setting."}) \ DECLARE(Bool, delta_lake_throw_on_engine_predicate_error, false, R"( Enables throwing an exception if there was an error when analyzing scan predicate in delta-kernel. )", 0, \ {"25.8", false, false, "New setting"}) \ DECLARE(Bool, delta_lake_enable_engine_predicate, true, R"( Enables delta-kernel internal data pruning. )", 0, \ {"25.8", true, true, "New setting"}) \ DECLARE(NonZeroUInt64, delta_lake_insert_max_rows_in_data_file, 1000000, R"( Defines a rows limit for a single inserted data file in delta lake. )", 0, \ {"25.9", 1000000, 1000000, "New setting."}) \ DECLARE(NonZeroUInt64, delta_lake_insert_max_bytes_in_data_file, 1_GiB, R"( Defines a bytes limit for a single inserted data file in delta lake. )", 0, \ {"25.9", 1_GiB, 1_GiB, "New setting."}) \ DECLARE(Bool, delta_lake_accurate_write_cast, true, R"( When writing to a DeltaLake table, cast each value to the Delta write-schema type with an accurate cast that throws when a value does not fit the target type, instead of a plain cast that silently truncates it (e.g. `300` written into a Delta `byte` column). Set to `false`, or use a `compatibility` setting below 26.9, for the plain, non-throwing cast. )", 0, \ {"26.9", false, true, "New setting: cast written values to the Delta write-schema type with an accurate cast that throws on a value that does not fit the target type instead of silently truncating; `compatibility` below 26.9 uses the plain, non-throwing cast."}) \ DECLARE_WITH_ALIAS(Bool, allow_delta_lake_writes, false, R"( Enables delta-kernel writes feature. )", BETA, allow_experimental_delta_lake_writes, \ {"26.7", false, false, "Added an alias for setting `allow_experimental_delta_lake_writes`, which was moved to Beta."}, \ {"25.9", false, false, "New setting. At the time the setting was named `allow_experimental_delta_lake_writes`, which is now an alias of it."}) \ DECLARE(Bool, allow_deprecated_error_prone_window_functions, false, R"( Allow usage of deprecated error prone window functions (neighbor, runningAccumulate, runningDifferenceStartingWithFirstValue, runningDifference) )", 0, \ {"24.5", true, false, "Allow usage of deprecated error prone window functions (neighbor, runningAccumulate, runningDifferenceStartingWithFirstValue, runningDifference)"}) \ DECLARE(FileLikeEngineDefaultPartitionStrategy, file_like_engine_default_partition_strategy, FileLikeEngineDefaultPartitionStrategy::HIVE, R"( Default partition strategy for file like engines. Applied only to `CREATE` queries with a path that has no glob or `{_partition_id}` placeholder. A path with `{_partition_id}` always uses `wildcard`. A path with another glob uses no partition strategy and ignores `PARTITION BY`. If this setting is `wildcard` but the path has no `{_partition_id}`, no partition strategy is used; table engines that can not persist this decision in their engine arguments (e.g. `HDFS`) reject such a `CREATE` instead. )", 0, \ {"26.6", "wildcard", "hive", "Change the default partition strategy for file-like table engines (S3, AzureBlobStorage, etc.) from `wildcard` to `hive` when no `partition_strategy` is provided."}) \ DECLARE(Bool, use_iceberg_partition_pruning, true, R"( Use Iceberg partition pruning for Iceberg tables )", 0, \ {"25.6", false, true, "Enable Iceberg partition pruning by default."}, \ {"25.1", false, false, "New setting for Iceberg partition pruning."}) \ DECLARE(Bool, use_iceberg_manifest_list_partition_pruning, true, R"( Skip whole Iceberg manifest files whose partition summaries in the manifest list cannot match the query filter, without reading them. Requires [use_iceberg_partition_pruning](#use_iceberg_partition_pruning) to be enabled and only helps when a manifest file holds few distinct partition values, which is what `rewriteManifests` clustered by the partition columns produces. )", 0, \ {"26.9", false, true, "New setting to skip Iceberg manifest files whose manifest-list partition summaries cannot match the query filter, without reading them."}) \ DECLARE(Bool, use_join_runtime_filters_for_iceberg_pruning, true, R"( Skip Iceberg data files, and the Parquet row groups and pages of the files that are read, that cannot contain a key of a JOIN runtime filter (see [enable_join_runtime_filters](#enable_join_runtime_filters)). Once the build side of the join finishes, the filter's keys (or their min/max range, if the set is too large) are checked against the column bounds in the manifest files, the row group statistics and the page index. Data files requested earlier are read in full. Requires [enable_join_runtime_filters_index_analysis](#enable_join_runtime_filters_index_analysis) and [use_iceberg_partition_pruning](#use_iceberg_partition_pruning). Row groups also require [input_format_parquet_filter_push_down](/reference/settings/formats/input-format#input_format_parquet_filter_push_down), and pages require it and [input_format_parquet_page_filter_push_down](/reference/settings/formats/input-format#input_format_parquet_page_filter_push_down). )", 0, \ {"26.11", false, true, "New setting to prune Iceberg data files, Parquet row groups and pages by JOIN runtime filters."}) \ DECLARE(Bool, use_datalake_metadata_statistics, false, R"( With [`use_statistics`](#use_statistics) enabled, estimate a data lake read for join reordering from the table metadata, without reading data. Only Iceberg is supported: the estimate comes from the manifest files of its data files left after partition and min-max pruning by the query filter, the rows from their `record_count`, and the number of distinct values, min/max and NULL fraction of the columns it returns from their identity partition values, value bounds and NULL counts. The filter, `PREWHERE` and row policy of the read are estimated on these statistics, as for MergeTree tables with column statistics; if no requested column has statistics, a filter that prunes no file gives no estimate, as for MergeTree tables without them. The row estimate is exact without a filter and without delete files. Pruning by the filter requires [use_iceberg_partition_pruning](#use_iceberg_partition_pruning) to be enabled. )", 0, \ {"26.11", false, false, "New setting to estimate the rows and column statistics of data lake reads (Iceberg for now) for join reordering from the table metadata."}) \ DECLARE(Bool, use_iceberg_table_statistics_ndv, false, R"( With [`use_datalake_metadata_statistics`](#use_datalake_metadata_statistics) enabled, take the number of distinct values of an Iceberg column for which the manifest files give none from the table statistics in `metadata.json`: the `ndv` property of an `apache-datasketches-theta-v1` blob over that one column, as written by Spark `compute_table_stats` or Trino `ANALYZE`. Only the blobs computed from the snapshot that is read are used. The numbers drive join reordering and condition estimates only and never change query results. )", 0, \ {"26.11", false, false, "New setting to take the numbers of distinct values of Iceberg columns from the table statistics in `metadata.json` for join reordering."}) \ DECLARE(Bool, iceberg_tolerate_conflicting_manifest_schemas, true, R"( If enabled and the schema-id of an Iceberg manifest file is already registered from metadata.json, the metadata.json schema is used and the copy in the `schema` key of the manifest file header is ignored without being compared. If disabled, the manifest header copy is compared with the metadata.json schema, and a conflict fails the query with an ICEBERG_SPECIFICATION_VIOLATION error. The manifest header schema is only a copy of the table schema at the time the manifest was written, and some writers (e.g. AWS S3 Tables maintenance jobs) have been observed storing degraded copies there. Other query engines resolve schemas from metadata.json and ignore divergent header copies, so the default follows them. A conflict between two metadata.json schema definitions still always fails the query. )", 0, \ {"26.10", true, true, "The change was backported to 26.8 and is recorded there."}, \ {"26.8", false, true, "New setting: when an Iceberg manifest file header carries a schema that conflicts with the schema registered for the same schema-id from metadata.json, prefer the metadata.json schema instead of failing the query, matching the behavior of other query engines. `compatibility` below 26.8 restores the previous strict behavior."}) \ DECLARE(Bool, optimize_distinct_in_order, true, R"( Enable DISTINCT optimization if some columns in DISTINCT form a prefix of sorting. For example, prefix of sorting key in merge tree or ORDER BY statement. It is not applied to a `FINAL` read that uses vertical `FINAL` (see `enable_vertical_final`), unless a `LIMIT` lets the `DISTINCT` stop reading early or the read is already in order for another reason, such as `ORDER BY`. )", 0) \ DECLARE(Bool, optimize_limit_by_in_order, true, R"( Optimize `SELECT ... LIMIT N BY ` queries when `` (in any order) form a prefix of the table's sorting key, or become one after `WHERE col = const` fixes leading columns. With this enabled the source reads data in primary-key order, so rows with equal values of the `BY` columns arrive adjacent to each other within each stream. When the data arrives in a single sorted stream, `LIMIT BY` filters it in streaming mode with O(1) memory, instead of building a hash table of every distinct combination of `BY` columns seen. When the sorted data arrives in multiple streams and the same `BY` values can appear in more than one of them, each stream is first prefiltered in streaming mode down to at most `LIMIT + OFFSET` rows per group, then the streams are combined and a final hash-based `LIMIT BY` deduplicates groups that span several streams. That final pass still keeps an entry for every distinct combination of `BY` columns, but it only processes the prefiltered rows. )", 0, \ {"26.6", false, true, "New setting to optimize `LIMIT BY` queries when `BY` columns are a prefix of the table's sorting key."}) \ DECLARE(Bool, keeper_map_strict_mode, false, R"( Enforce additional checks during operations on KeeperMap. E.g. throw an exception on an insert for already existing key )", 0) \ DECLARE_WITH_ALIAS(UInt64, extract_key_value_pairs_max_pairs_per_row, 1000, R"( Max number of pairs that can be produced by the `extractKeyValuePairs` function. Used as a safeguard against consuming too much memory. )", 0, extract_kvp_max_pairs_per_row, \ {"24.2", 0, 1000, "Max number of pairs that can be produced by the `extractKeyValuePairs` function. Used as a safeguard against consuming too much memory."}) \ DECLARE(Bool, restore_replace_external_engines_to_null, false, R"( For testing purposes. Replaces all external engines to Null to not initiate external connections. )", 0, \ {"24.8", false, false, "New setting."}) \ DECLARE(Bool, restore_replace_external_table_functions_to_null, false, R"( For testing purposes. Replaces all external table functions to Null to not initiate external connections. )", 0, \ {"24.8", false, false, "New setting."}) \ DECLARE(Bool, restore_replace_external_dictionary_source_to_null, false, R"( Replace external dictionary sources to Null on restore. Useful for testing purposes )", 0, \ {"24.10", false, false, "New setting."}) \ /* Parallel replicas */ \ DECLARE_WITH_ALIAS(UInt64, allow_experimental_parallel_reading_from_replicas, 0, R"( Use up to `max_parallel_replicas` the number of replicas from each shard for SELECT query execution. Reading is parallelized and coordinated dynamically. 0 - disabled, 1 - enabled, silently disable them in case of failure, 2 - enabled, throw an exception in case of failure )", 0, enable_parallel_replicas, \ {"24.10", false, false, "Parallel replicas with read tasks became the Beta tier feature. The setting is also known by its alias `enable_parallel_replicas`."}) \ DECLARE(UInt64, automatic_parallel_replicas_mode, 0, R"( Enable automatic switching to execution with parallel replicas based on collected statistics. Requires `enable_parallel_replicas = 1`, `parallel_replicas_local_plan = 1` and providing `cluster_for_parallel_replicas`. With `enable_parallel_replicas = 2` parallel replicas are forced and the automatic mode is not applied. 0 - disabled, 1 - enabled, 2 - only statistics collection is enabled (switching to execution with parallel replicas is disabled). )", 0, \ {"25.12", 0, 0, "New setting"}) \ DECLARE(Bool, automatic_parallel_replicas_remember_boundary, true, R"( Lets automatic parallel replicas remember, per query plan, where the replicas' share of the work ends, so that a repeated query whose statistics decline parallel replicas is decided without building the plan with parallel replicas. Disables remembered boundaries. To benchmark the cost of building the plan with parallel replicas, also set `automatic_parallel_replicas_undecided_retry_after_executions = 0`: the plans whose last build ended without a decision are skipped independently of this setting. )", 0, \ {"26.10", false, true, "New setting. Automatic parallel replicas now remembers the boundary of the replicas' share of the work per query plan; previously every query built the plan with parallel replicas to find it."}) \ DECLARE(UInt64, automatic_parallel_replicas_undecided_retry_after_executions, 10, R"( How many executions of a query plan skip building the plan with parallel replicas after its last build ended without a decision in automatic parallel replicas: the two plans could not be compared, the planner used no parallel replicas in the plan built with them, a step of the plan cannot collect the statistics, or the collection measured nothing. Concurrent executions take turns: one in every `automatic_parallel_replicas_undecided_retry_after_executions + 1` builds the plan again. After the first such outcome for a query plan, the next execution builds the plan again at once just in case the first execution populated other statistics caches and the planning decisions will change. 0 disables deferral after undecided outcomes. It is independent of `automatic_parallel_replicas_remember_boundary`, which spares the build for plans decided from statistics. )", 0, \ {"26.11", 0, 10, "New setting. Automatic parallel replicas now skips building the plan with parallel replicas for a number of executions of a query plan whose last build ended without a decision; previously every execution built it."}) \ DECLARE(Float, automatic_parallel_replicas_max_duplicated_read_ratio, 0.5, R"( How much of a query's read volume may be read by every replica instead of being split between them, as a fraction of the whole, before automatic parallel replicas declines the query. Only the read parallel replicas coordinate is split; every other read of the same subtree runs on each replica in full. Those reads take the same wall-clock time either way, so the cost-model comparison is blind to them, but the cluster performs `max_parallel_replicas` times as much work for them. This setting is the limit on that waste: at the default 0.5 a query whose coordinated read is less than half of what it reads keeps running on one node, however the time comparison turns out. Set to 1 to accept any amount of duplicated reading, which restores the behaviour of only comparing times. )", 0, \ {"26.10", 1.0, 0.5, "Automatic parallel replicas now declines a query that would repeat more than half of its reading on every replica. Previously there was no limit, which is what 1 still asks for."}) \ DECLARE(Float, automatic_parallel_replicas_statistics_drift_ratio, 1.5, R"( How much the rows a read selects may differ from the rows it selected when automatic parallel replicas collected its statistics, as the ratio of the larger to the smaller, before the statistics are considered stale and collected again instead of being decided on. The rows are the ones the initiator's index analysis selects, so pruning that only the replicas do while reading (for example by their own query condition caches) is not seen. A lower ratio recollects the statistics sooner as the table changes. Should be greater than 1. )", 0, \ {"26.11", 2.0, 1.5, "New setting. The ratio was 2 and could not be changed; statistics are now recollected sooner as the data changes."}) \ DECLARE(UInt64, automatic_parallel_replicas_min_bytes_per_replica, 1_MiB, R"( Threshold of bytes to read per replica to enable parallel replicas automatically (applies only when `automatic_parallel_replicas_mode`=1). 0 means no threshold. The total number of bytes to read is estimated based on the collected statistics. )", 0, \ {"26.1", 0, 1_MiB, "Better default value derived from testing results"}, \ {"25.12", 0, 0, "New setting"}) \ DECLARE(Bool, automatic_parallel_replicas_ignore_thresholds, false, R"( For testing of the automatic parallel replicas cost model - ignore the cap on how many threads a read can usefully occupy (derived from `merge_tree_min_bytes_per_task_for_remote_reading`), which otherwise clamps both sides of the comparison to the same value for a read too small to occupy `max_threads`, so that the comparison collapses to `0 > output_bytes / replicas` and the query is decided before the cost model is consulted. It deliberately does NOT touch `automatic_parallel_replicas_min_bytes_per_replica`: set that to 0 to disable that gate, which is what it is for. Nor does it change read task sizing, or suppress the recollection of statistics that have drifted - a decision made on stale statistics is not a decision made by the cost model. )", 0, \ {"26.11", false, false, "New setting: for testing, ignore the reading-thread cap of the automatic parallel replicas cost model so that small reads are decided by the comparison rather than short-circuited by the cap."}) \ DECLARE(NonZeroUInt64, max_parallel_replicas, 1000, R"( The maximum number of replicas for each shard when executing a query. Possible values: - Positive integer. **Additional Info** This options will produce different results depending on the settings used. With `parallel_replicas_mode` `sampling_key`, or a custom key mode on a cluster with more than one shard, each replica returns its own part of the result of the shard. The replicas of a shard are used together only when the initiator aggregates or fully sorts these parts itself (for example an aggregation without `GROUP BY` keys). Otherwise, for example for `GROUP BY` with `distributed_aggregation_memory_efficient` or for `ORDER BY`, the shard is read from one replica. ### Parallel processing using `SAMPLE` key A query may be processed faster if it is executed on several servers in parallel. But the query performance may degrade in the following cases: - The position of the sampling key in the partitioning key does not allow efficient range scans. - Adding a sampling key to the table makes filtering by other columns less efficient. - The sampling key is an expression that is expensive to calculate. - The cluster latency distribution has a long tail, so that querying more servers increases the query overall latency. ### Parallel processing using [parallel_replicas_custom_key](#parallel_replicas_custom_key) This setting is useful for any replicated table. )", 0, \ {"25.1", 1, 1000, "Use up to 1000 parallel replicas by default."}) \ DECLARE(ParallelReplicasMode, parallel_replicas_mode, ParallelReplicasMode::READ_TASKS, R"( Type of filter to use with custom key for parallel replicas. default - use modulo operation on the custom key, range - use range filter on custom key using all possible values for the value type of custom key. )", 0, \ {"24.10", "read_tasks", "read_tasks", "This setting was introduced as a part of making parallel replicas feature Beta"}) \ DECLARE(UInt64, parallel_replicas_count, 0, R"( This is internal setting that should not be used directly and represents an implementation detail of the 'parallel replicas' mode. This setting will be automatically set up by the initiator server for distributed queries to the number of parallel replicas participating in query processing. )", BETA) \ DECLARE(UInt64, parallel_replica_offset, 0, R"( This is internal setting that should not be used directly and represents an implementation detail of the 'parallel replicas' mode. This setting will be automatically set up by the initiator server for distributed queries to the index of the replica participating in query processing among parallel replicas. )", BETA) \ DECLARE(UInt64, distributed_group_by_top_k, 0, R"( This is internal setting that should not be used directly and represents an implementation detail of the 'parallel replicas' mode. The initiator sends it as `n` with a `GROUP BY ... LIMIT n` query without `ORDER BY` when it keeps the smallest `n` merged groups by all grouping keys. Then each replica keeps only its smallest `n` groups in its partial aggregation (see `enable_group_by_top_k_optimization`). It is not forwarded further. )", BETA, \ {"26.11", 0, 0, "New internal setting: the initiator of a query with parallel replicas lets the replicas apply the `GROUP BY` top-K heap to `GROUP BY ... LIMIT` without `ORDER BY`."}) \ DECLARE(String, parallel_replicas_custom_key, "", R"( An arbitrary integer expression that can be used to split work between replicas for a specific table. The value can be any integer expression. Simple expressions using primary keys are preferred. If the setting is used on a cluster that consists of a single shard with multiple replicas, those replicas will be converted into virtual shards. Otherwise, it will behave same as for `SAMPLE` key, it will use multiple replicas of each shard. The expression is checked against the column-level `SELECT` grants of the user. For a view with `SQL SECURITY DEFINER` or `NONE` it is applied to the columns of the view; the body of the view is read without it. )", BETA) \ DECLARE(UInt64, parallel_replicas_custom_key_range_lower, 0, R"( Allows the filter type `range` to split the work evenly between replicas based on the custom range `[parallel_replicas_custom_key_range_lower, INT_MAX]`. When used in conjunction with [parallel_replicas_custom_key_range_upper](#parallel_replicas_custom_key_range_upper), it lets the filter evenly split the work over replicas for the range `[parallel_replicas_custom_key_range_lower, parallel_replicas_custom_key_range_upper]`. Note: This setting will not cause any additional data to be filtered during query processing, rather it changes the points at which the range filter breaks up the range `[0, INT_MAX]` for parallel processing. )", BETA, \ {"24.6", 0, 0, "Add settings to control the range filter when using parallel replicas with dynamic shards"}) \ DECLARE(UInt64, parallel_replicas_custom_key_range_upper, 0, R"( Allows the filter type `range` to split the work evenly between replicas based on the custom range `[0, parallel_replicas_custom_key_range_upper]`. A value of 0 disables the upper bound, setting it the max value of the custom key expression. When used in conjunction with [parallel_replicas_custom_key_range_lower](#parallel_replicas_custom_key_range_lower), it lets the filter evenly split the work over replicas for the range `[parallel_replicas_custom_key_range_lower, parallel_replicas_custom_key_range_upper]`. Note: This setting will not cause any additional data to be filtered during query processing, rather it changes the points at which the range filter breaks up the range `[0, INT_MAX]` for parallel processing )", BETA, \ {"24.6", 0, 0, "Add settings to control the range filter when using parallel replicas with dynamic shards. A value of 0 disables the upper limit"}) \ DECLARE(String, cluster_for_parallel_replicas, "", R"( Cluster for a shard in which current server is located Cloud default value: `default`. )", 0) \ DECLARE(Bool, parallel_replicas_allow_in_with_subquery, true, R"( If true, subquery for IN will be executed on every follower replica. )", 0, \ {"24.3", false, true, "If true, subquery for IN will be executed on every follower replica"}) \ DECLARE(Bool, parallel_replicas_for_non_replicated_merge_tree, false, R"( If true, ClickHouse will use parallel replicas algorithm also for non-replicated MergeTree tables )", 0) \ DECLARE(UInt64, parallel_replicas_min_number_of_rows_per_replica, 0, R"( Limit the number of replicas used in a query to (estimated rows to read / min_number_of_rows_per_replica). The max is still limited by 'max_parallel_replicas' Ignored when `automatic_parallel_replicas_mode` is enabled: the automatic mode decides with its own cost model. )", 0) \ DECLARE(Bool, parallel_replicas_prefer_local_join, true, R"( If true, and `JOIN` can be executed with parallel replicas algorithm, and every storage of the `JOIN` part that would otherwise be materialized into a temporary table can be read by each replica on its own, local `JOIN` will be used instead of `GLOBAL JOIN`. That part is the right one, except for a `RIGHT JOIN`, where it is the left one and where every storage has to be eligible for parallel replicas rather than merely `*MergeTree`. A storage under the materialized side of a nested `GLOBAL JOIN`, or under a `GLOBAL IN`, does not count, because the initiator materializes those itself. )", 0, \ {"24.2", true, true, "If true, and JOIN can be executed with parallel replicas algorithm, and all storages of right JOIN part are *MergeTree, local JOIN will be used instead of GLOBAL JOIN."}) \ DECLARE(UInt64, parallel_replicas_mark_segment_size, 0, R"( Parts virtually divided into segments to be distributed between replicas for parallel reading. This setting controls the size of these segments. Not recommended to change until you're absolutely sure in what you're doing. Value should be in range [128; 16384] )", 0, \ {"24.9", 128, 0, "Value for this setting now determined automatically"}, \ {"24.1", 128, 128, "Add new setting to control segment size in new parallel replicas coordinator implementation"}) \ DECLARE(Bool, parallel_replicas_local_plan, true, R"( Build local plan for local replica )", 0, \ {"24.11", false, true, "Use local plan for local replica in a query with parallel replicas"}, \ {"24.10", false, true, "Use local plan for local replica in a query with parallel replicas"}, \ {"24.9", false, false, "Use local plan for local replica in a query with parallel replicas"}) \ DECLARE(Bool, parallel_replicas_plan_based, false, R"( Decide whether and where to use parallel replicas by analyzing the query plan, as opposed to the query-tree-based analysis. As a result, a plan fragment is sent to the remote replicas instead of a SQL query. Experimental. Has no effect on a distributed `INSERT SELECT` ([parallel_distributed_insert_select](#parallel_distributed_insert_select) = 2), which ships the whole `INSERT` as a query to every replica: a replica executing that query reads with the query-tree-based implementation, so the initiator, taking part as one more replica, uses it too. )", EXPERIMENTAL, \ {"26.7", false, false, "New setting"}) \ DECLARE(Bool, parallel_replicas_allow_merge_tables, false, R"( Allow reading from a `Merge` table with parallel replicas. Effective only together with [parallel_replicas_plan_based](#parallel_replicas_plan_based): the read from the `Merge` table is expanded into a union of the reads from the underlying `MergeTree` tables, which is then distributed like any other union. A `Merge` table is left to a single replica when any of its underlying tables cannot be read that way (a non-`MergeTree` table, a `FINAL` read). Set it to `false` to read every `Merge` table on a single replica, as before the support was added. Experimental. )", EXPERIMENTAL, \ {"26.9", false, false, "New setting to allow reading from a `Merge` table with plan-based parallel replicas, by expanding the `Merge` read into a union of the reads from the underlying `MergeTree` tables. It only has an effect together with `parallel_replicas_plan_based`."}) \ DECLARE(Bool, parallel_replicas_prefer_local_replica, true, R"( When enabled (default), the local replica is always included in the set of replicas used for parallel reading. When disabled, the local replica is not given any preference and replicas are selected purely by the load balancing algorithm. This allows queries with `max_parallel_replicas = 1` to be directed to another host, which can improve cache locality when many short queries are distributed across a cluster. )", 0, \ {"26.5", true, true, "New setting. When disabled, replicas for parallel reading are selected purely by the load balancing algorithm without forcing the local replica into the set."}) \ DECLARE(Bool, parallel_replicas_index_analysis_only_on_coordinator, true, R"( Index analysis done only on replica-coordinator and skipped on other replicas. Effective only with enabled parallel_replicas_local_plan This concerns the index analysis that selects the mark ranges a read announces, which is what the coordinator assigns from. It does not cover pruning that happens while the data is read, such as the granule pruning of `enable_join_runtime_filters_index_analysis`: a JOIN runtime filter only exists once the build side has been read, so every replica evaluates its own and prunes its own share, and no coordinator could do it for them. )", 0, \ {"24.12", true, true, "Index analysis done only on replica-coordinator and skipped on other replicas. Effective only with enabled parallel_replicas_local_plan"}, \ {"24.10", false, true, "Index analysis done only on replica-coordinator and skipped on other replicas. Effective only with enabled parallel_replicas_local_plan"}) \ DECLARE(Bool, parallel_replicas_support_projection, true, R"( Optimization of projections can be applied in parallel replicas. Effective only with enabled parallel_replicas_local_plan. )", 0, \ {"25.8", false, true, "New setting. Optimization of projections can be applied in parallel replicas. Effective only with enabled parallel_replicas_local_plan and aggregation_in_order is inactive."}) \ DECLARE(Milliseconds, parallel_replicas_connect_timeout_ms, 300, R"( The timeout in milliseconds for connecting to a remote replica during query execution with parallel replicas. If the timeout is expired, the corresponding replicas is not used for query execution )", 0, \ {"25.6", 1000, 300, "Separate connection timeout for parallel replicas queries"}) \ DECLARE(Bool, parallel_replicas_for_queries_with_multiple_tables, true, R"( If enabled, parallel replicas can be used for queries joining multiple tables (queries with `JOIN`). If disabled, parallel replicas are not used for such queries, and they are executed without parallel replicas. The setting affects only queries with `JOIN`, where the non-leftmost side is read in full on every replica. A `UNION` query without a `JOIN` is not affected: each `UNION` branch is an independent single-table read, so parallel replicas remain applicable to it. A `UNION` used as a table expression of a `JOIN` is a part of a query joining multiple tables and is affected. `ARRAY JOIN` does not count as a join between tables. )", BETA, \ {"26.10", true, true, "New setting to control whether parallel replicas are used for queries joining multiple tables (queries with JOIN). It does not affect a UNION query without a JOIN, nor ARRAY JOIN."}) \ DECLARE(Bool, parallel_replicas_for_cluster_engines, true, R"( Replace table function engines with their -Cluster alternatives )", 0, \ {"25.3", false, true, "New setting."}) \ DECLARE(Bool, parallel_replicas_for_object_storage_tables, true, R"( Read a table with an object storage engine that has a `-Cluster` table function (`S3`, `AzureBlobStorage`, `HDFS`, `Iceberg`, `IcebergS3`, `IcebergAzure`, `IcebergHDFS`, `IcebergLocal`, `DeltaLake`, `DeltaLakeS3`, `DeltaLakeAzure`, `Hudi`, `Paimon`, `PaimonS3`, `PaimonAzure`, `PaimonHDFS`) over the replicas of `cluster_for_parallel_replicas`, the same way `parallel_replicas_for_cluster_engines` does for the table functions. Has no effect when `parallel_replicas_for_cluster_engines` is disabled. A replica takes part in the read only if it has the table, and the table must have the same definition on every replica. )", 0, \ {"26.11", false, true, "New setting to read tables with an object storage engine with parallel replicas."}) \ DECLARE(Bool, parallel_replicas_allow_materialized_views, true, R"( Allow usage of materialized views with parallel replicas )", 0, \ {"25.12", false, true, "Allow usage of materialized views with parallel replicas"}) \ DECLARE(Bool, parallel_replicas_filter_pushdown, true, R"( Push a condition standing above the part of the query parallel replicas execute into that part, and into the query the replicas are sent, so that they filter by it as well. Turn it off to keep the condition above the read on the initiator, as versions before 26.10 did. It is the way out if the push-down misbehaves: the answer does not change either way, only how much work the replicas do and how early they do it. )", 0, \ {"26.10", false, true, "Enabled by default"}, \ {"26.2", false, false, "New setting"}) \ DECLARE(Bool, parallel_replicas_allow_view_over_mergetree, false, R"( Allow parallel replicas to execute the outer query of a simple view over `MergeTree` tables (instead of the view's inner query), improving parallelization across nodes. Also applies to `UNION ALL` views whose branches all read from different `MergeTree` tables. )", BETA, \ {"26.4", false, false, "New setting"}) \ DECLARE(Bool, distributed_index_analysis, false, R"( Index analysis will be distributed across replicas. Beneficial for shared storage and huge amount of data in cluster. Uses replicas from cluster_for_parallel_replicas. **See also** - [distributed_index_analysis_for_non_shared_merge_tree](#distributed_index_analysis_for_non_shared_merge_tree) - [distributed_index_analysis_min_parts_to_activate](/reference/settings/merge-tree-settings/distributed-index#distributed_index_analysis_min_parts_to_activate) - [distributed_index_analysis_min_indexes_bytes_to_activate](/reference/settings/merge-tree-settings/distributed-index#distributed_index_analysis_min_indexes_bytes_to_activate) )", BETA, \ {"26.10", false, false, "Distributed index analysis was moved to Beta."}, \ {"26.1", false, false, "New experimental setting"}) \ DECLARE(Bool, distributed_index_analysis_only_on_coordinator, false, R"( If enabled, distributed index analysis runs only on the coordinator. This prevents O(N^2) spawned queries when the predicate contains subqueries (e.g., `IN (SELECT ...)`), because each follower replica would otherwise independently trigger its own distributed index analysis, but makes distributed index analysis less efficient if large tables are used in the subqueries. )", 0, \ {"26.4", false, false, "New setting."}) \ DECLARE(Bool, distributed_index_analysis_for_non_shared_merge_tree, false, R"( Enable distributed index analysis even for non SharedMergeTree (cloud only engine). )", 0, \ {"26.1", false, false, "New setting"}) \ DECLARE_WITH_ALIAS(Bool, allow_database_iceberg, false, R"( Allow database engine `DataLakeCatalog` with `catalog_type = 'iceberg'` Cloud default value: `1`. )", BETA, allow_experimental_database_iceberg, \ {"25.8", false, false, "Added an alias for setting `allow_experimental_database_iceberg`"}, \ {"24.12", false, false, "New setting. At the time the setting was named `allow_experimental_database_iceberg`, which is now an alias of it."}) \ DECLARE_WITH_ALIAS(Bool, allow_database_unity_catalog, false, R"( Allow database engine `DataLakeCatalog` with `catalog_type = 'unity'` Cloud default value: `1`. )", BETA, allow_experimental_database_unity_catalog, \ {"25.8", false, false, "Added an alias for setting `allow_experimental_database_unity_catalog`"}, \ {"25.3", false, false, "Allow experimental database engine DataLakeCatalog with catalog_type = 'unity'. At the time the setting was named `allow_experimental_database_unity_catalog`, which is now an alias of it."}) \ DECLARE_WITH_ALIAS(Bool, allow_database_glue_catalog, false, R"( Allow database engine `DataLakeCatalog` with `catalog_type = 'glue'` Cloud default value: `1`. )", BETA, allow_experimental_database_glue_catalog, \ {"25.8", false, false, "Added an alias for setting `allow_experimental_database_glue_catalog`"}, \ {"25.3", false, false, "Allow experimental database engine DataLakeCatalog with catalog_type = 'glue'. At the time the setting was named `allow_experimental_database_glue_catalog`, which is now an alias of it."}) \ DECLARE_WITH_ALIAS(Bool, allow_experimental_analyzer, true, R"( Obsolete since v26.9: the analyzer cannot be disabled anymore. The analyzer is the query analysis and planning infrastructure that has been the default since v24.3. In v26.9 this setting was frozen at its only supported value, `1`, and the `compatibility` setting no longer reverts it. In v26.10 the query analysis it used to switch to was removed. For backward compatibility, setting it to `0` is accepted and replaced with `1`, so queries, session settings, settings profiles and client configurations that still set `enable_analyzer = 0` keep working, with the analyzer. To compare the behaviour or the performance of a query with the old query analysis, use a ClickHouse version older than v26.9. )", IMPORTANT | SettingsTierType::OBSOLETE, enable_analyzer, \ {"26.9", true, true, "The setting is obsolete: the analyzer is mandatory and the old query analysis is no longer supported. A change that would disable it is accepted and replaced with `1`, and `compatibility` with a version below 24.3 no longer reverts it."}, \ {"24.8", 1, 1, "Added the alias `enable_analyzer`."}, \ {"24.3", false, true, "Enable analyzer and planner by default."}) \ DECLARE(Bool, analyzer_compatibility_join_using_top_level_identifier, false, R"( Force to resolve identifier in JOIN USING from projection (for example, in `SELECT a + 1 AS b FROM t1 JOIN t2 USING (b)` join will be performed by `t1.a + 1 = t2.b`, rather then `t1.b = t2.b`). Aliases defined elsewhere in the query are also considered: in the `WITH` clause, on subexpressions inside the SELECT list, or in other clauses (for example, in `WITH a + 1 AS b SELECT count() FROM t1 JOIN t2 USING (b)` and in `SELECT uniqExact(a + 1 AS b) FROM t1 JOIN t2 USING (b)` the join is performed by `t1.a + 1 = t2.b`). In a query with several `JOIN`s only the outermost `JOIN` resolves its `USING` identifier from an alias; an inner `JOIN` resolves it from its left table, as the old analyzer did. When the matching alias is not a top-level alias of the SELECT list, parallel replicas are disabled for the query. For queries sent to remote servers (`Distributed` tables, the `remote` table function), such a query is rejected with an exception only when the identifier cannot be resolved on the remote server at all; if the alias shadows a real column of the left table, the remote server joins by that column instead, so the results may differ from local execution. )", 0, \ {"24.3", false, false, "Force to resolve identifier in JOIN USING from projection"}) \ DECLARE(Bool, analyzer_compatibility_allow_compound_identifiers_in_unflatten_nested, true, R"( Allow to add compound identifiers to nested. This is a compatibility setting because it changes the query result. When disabled, `SELECT a.b.c FROM table ARRAY JOIN a` does not work, and `SELECT a FROM table` does not include `a.b.c` column into `Nested a` result. )", 0, \ {"25.8", false, true, "New setting."}) \ DECLARE(Bool, semi_join_include_columns_from_both_sides, true, R"( When enabled (the default), `SEMI` JOIN keeps columns from both sides accessible in the joined result, and `SELECT *` returns columns from both sides. This is the legacy ClickHouse behavior. When disabled, the analyzer restricts `SEMI` JOIN column access to the preserved side in accordance with the SQL standard. For `LEFT SEMI JOIN` only left table columns are accessible, for `RIGHT SEMI JOIN` only right table columns. This applies to expressions resolved from the joined result, such as `SELECT`, `PREWHERE`, `WHERE`, `GROUP BY`, `HAVING`, `QUALIFY`, `ORDER BY`, and `LIMIT BY` clauses, including qualified wildcards like `t1.*`. An explicit reference to a non-preserved side column raises the `SEMI_ANTI_JOIN_COLUMN_ACCESS_DENIED` exception. This covers qualified references such as `t2.b`, qualified wildcards like `t2.*`, `USING` columns like `d.id`, and fully qualified references like `db.table.column`, and it is enforced even inside statically-dead branches such as `if(false, t2.b, 42)`. An unqualified identifier that does not match any accessible column still falls back to the generic `UNKNOWN_IDENTIFIER` exception. The `JOIN ON` expression of the same `JOIN` can access both sides regardless of this setting. )", 0, \ {"26.10", true, true, "New setting. Disable it to restrict `SEMI JOIN` column access to the preserved side except in `JOIN ON` expressions"}) \ DECLARE(Bool, anti_join_include_columns_from_both_sides, true, R"( When enabled (the default), `ANTI` JOIN keeps columns from both sides accessible in the joined result, and `SELECT *` returns columns from both sides. This is the legacy ClickHouse behavior. When disabled, the analyzer restricts `ANTI` JOIN column access to the preserved side in accordance with the SQL standard. For `LEFT ANTI JOIN` only left table columns are accessible, for `RIGHT ANTI JOIN` only right table columns. This applies to expressions resolved from the joined result, such as `SELECT`, `PREWHERE`, `WHERE`, `GROUP BY`, `HAVING`, `QUALIFY`, `ORDER BY`, and `LIMIT BY` clauses, including qualified wildcards like `t1.*`. An explicit reference to a non-preserved side column raises the `SEMI_ANTI_JOIN_COLUMN_ACCESS_DENIED` exception. This covers qualified references such as `t2.b`, qualified wildcards like `t2.*`, `USING` columns like `d.id`, and fully qualified references like `db.table.column`, and it is enforced even inside statically-dead branches such as `if(false, t2.b, 42)`. An unqualified identifier that does not match any accessible column still falls back to the generic `UNKNOWN_IDENTIFIER` exception. The `JOIN ON` expression of the same `JOIN` can access both sides regardless of this setting. )", 0, \ {"26.10", true, true, "New setting. Disable it to restrict `ANTI JOIN` column access to the preserved side except in `JOIN ON` expressions"}) \ DECLARE(Bool, analyzer_compatibility_allow_non_aggregate_in_having, false, R"( When enabled, the analyzer mimics the legacy behavior of moving non-aggregate AND-conjuncts from `HAVING` to `WHERE` instead of raising `NOT_AN_AGGREGATE`. The standard-compliant rejection is the default; this is a migration aid for queries that were silently accepted by the query analysis that ClickHouse used before v24.3. Conjuncts containing aggregate, `grouping`, or non-deterministic functions stay in `HAVING`. If any conjunct contains a window function or a stateful function (for example `rowNumberInBlock`), the rewrite is disabled for the whole `HAVING`, matching the behaviour of that older analysis. The setting is also ignored when `GROUP BY` uses `WITH CUBE`, `WITH ROLLUP`, `WITH TOTALS`, or `GROUPING SETS`. )", 0, \ {"26.7", false, false, "New compatibility setting. When enabled, the analyzer mimics the legacy `HAVING`-to-`WHERE` rewrite for non-aggregate AND-conjuncts instead of raising `NOT_AN_AGGREGATE`."}) \ DECLARE(Bool, analyzer_compatibility_prefer_alias_over_subcolumn, false, R"( When a multi-part identifier like `b.id` could refer to either the column `id` of a table aliased `b` or to a Tuple subcolumn `b.id` of some other column, prefer the alias-prefix interpretation (column `id` of `b`). By default the analyzer prefers the subcolumn. Enable to match the old analyzer's resolution. )", 0, \ {"26.6", false, false, "New compatibility setting"}) \ DECLARE(Bool, analyzer_compatibility_apply_final_to_all_joined_tables, false, R"( Restores the behavior of versions before 26.6, where the `FINAL` modifier specified on the left-most table of a JOIN was incorrectly applied to all other joined tables as well (for engines that support `FINAL`, e.g. `ReplacingMergeTree`). By default `FINAL` applies only to the table it is written on. Enable for compatibility with queries that rely on the old behavior; the recommended fix is to write `FINAL` explicitly on every table that needs it. Possible values: - 0 - `FINAL` applies only to the table it is specified on. - 1 - `FINAL` on the left-most table of a JOIN is applied to all joined tables. )", 0, \ {"26.8", false, false, "New setting on master (default false = the fixed behavior). The behavior flip itself is recorded under 26.6, and the introduction for backports to older release branches (with default true) under 26.4."}, \ {"26.6", true, false, "Fixed a bug in the analyzer where FINAL on the left-most table of a JOIN was incorrectly applied to the other joined tables as well. previous_value=true so `compatibility` with versions before 26.6 restores the old behavior."}, \ {"26.4", true, true, "New compatibility setting controlling whether FINAL on the left-most table of a JOIN is applied to the other joined tables. Introduced with default true (the old behavior) for backports to versions before 26.6."}) \ DECLARE(Bool, analyzer_compatibility_multiple_joins_qualify_column_names, false, R"( When enabled and the `FROM` clause of a query contains two or more `JOIN`s (comma-separated tables count; `ARRAY JOIN` does not), the analyzer names result columns the way the old analyzer's multiple-joins rewrite did: - columns produced by expanding `*`, `.*` or `COLUMNS('')` get names of the form `.` (the qualifier is the table expression's alias if it has one, otherwise the table name without the database, otherwise the CTE name; columns of a joined subquery without an alias are left unqualified). Two kinds of column keep their bare name because they belong to the join rather than to a single table expression: a column produced by `ARRAY JOIN`, and a key merged by `JOIN ... USING`. Outer references such as `SELECT ll.arr` or `SELECT ll.k` therefore do not resolve in those two shapes; - the identifier-list form `COLUMNS(col1, col2)` is not a matcher expansion: each column keeps the name exactly as its identifier was written, so `COLUMNS(x)` produces `x` and `COLUMNS(a.x)` produces `a.x`; - an unaliased column reference in the `SELECT` list keeps its name exactly as written (e.g. `SELECT a.x` produces a column named `a.x` even when `x` is unambiguous). This makes outer queries that reference such columns by their qualified names work, for example: ```sql SELECT ll.Date FROM (SELECT * FROM t AS ll LEFT JOIN t1 ON ll.k = t1.k LEFT JOIN t2 ON ll.k = t2.k); ``` )", 0, \ {"26.8", false, false, "New compatibility setting. When enabled, the analyzer mimics the old analyzer's qualified result column names for queries whose FROM clause has two or more JOINs."}) \ DECLARE(Bool, analyzer_compatibility_allow_cte_redefinition, false, R"( Allow a Common Table Expression name to be defined more than once in a single `WITH` clause. A reference to such a name binds to the latest definition that is not being resolved at that moment: a redefinition can read the previous definition of the same name, and the query body reads the last one. This matches the query analysis that ClickHouse used before v24.3, where a later definition silently shadowed the earlier ones. One shape differs from that analysis: a CTE declared between two definitions of a name also binds to the last definition, where the old analysis bound it to the definition visible at its declaration point. By default a redefinition is rejected with `MULTIPLE_EXPRESSIONS_FOR_ALIAS`. A CTE declared as `MATERIALIZED` and a CTE in a `WITH RECURSIVE` clause cannot be redefined even when the setting is enabled. Possible values: - 0 - A CTE name can be defined only once in a `WITH` clause. - 1 - A later definition of a CTE name shadows the earlier ones. )", 0, \ {"26.10", false, false, "New compatibility setting. When enabled, the analyzer accepts a CTE name defined more than once in a single `WITH` clause and lets a later definition shadow the earlier ones, as the query analysis before v24.3 did."}) \ DECLARE(Bool, enable_identifier_resolve_cache, true, R"( Enable the identifier resolution cache in the query analyzer. The cache shares resolved alias nodes to prevent AST explosion when the same alias is referenced multiple times. Set to false to disable caching if incorrect results are suspected. )", 0, \ {"26.6", false, true, "New setting to control the identifier resolution cache in the query analyzer"}) \ \ DECLARE(Timezone, session_timezone, "", R"( Sets the implicit time zone of the current session or query. The implicit time zone is the time zone applied to values of type DateTime/DateTime64 which have no explicitly specified time zone. The setting takes precedence over the globally configured (server-level) implicit time zone. A value of '' (empty string) means that the implicit time zone of the current session or query is equal to the [server time zone](/reference/settings/server-settings/settings/other#timezone). You can use functions `timeZone()` and `serverTimeZone()` to get the session time zone and server time zone. Possible values: - Any time zone name from `system.time_zones`, e.g. `Europe/Berlin`, `UTC` or `Zulu` - A fixed offset from UTC, spelled `Fixed/UTC±HH:MM:SS`, e.g. `Fixed/UTC+05:30:00`. The offset has to be a whole number of quarters of an hour and no further from UTC than 14 hours, which covers every offset a real time zone has. Only these names are accepted. A name that only the operating system's time zone database has is not, because ClickHouse ships its own copy of the time zone database so that results do not depend on the host. Examples: ```sql SELECT timeZone(), serverTimeZone() FORMAT CSV "Europe/Berlin","Europe/Berlin" ``` ```sql SELECT timeZone(), serverTimeZone() SETTINGS session_timezone = 'Asia/Novosibirsk' FORMAT CSV "Asia/Novosibirsk","Europe/Berlin" ``` Assign session time zone 'America/Denver' to the inner DateTime without explicitly specified time zone: ```sql SELECT toDateTime64(toDateTime64('1999-12-12 23:23:23.123', 3), 3, 'Europe/Zurich') SETTINGS session_timezone = 'America/Denver' FORMAT TSV 1999-12-13 07:23:23.123 ``` Not all functions that parse DateTime/DateTime64 respect `session_timezone`. This can lead to subtle errors. See the following example and explanation. ```sql CREATE TABLE test_tz (`d` DateTime('UTC')) ENGINE = Memory AS SELECT toDateTime('2000-01-01 00:00:00', 'UTC'); SELECT *, timeZone() FROM test_tz WHERE d = toDateTime('2000-01-01 00:00:00') SETTINGS session_timezone = 'Asia/Novosibirsk' 0 rows in set. SELECT *, timeZone() FROM test_tz WHERE d = '2000-01-01 00:00:00' SETTINGS session_timezone = 'Asia/Novosibirsk' ┌───────────────────d─┬─timeZone()───────┐ │ 2000-01-01 00:00:00 │ Asia/Novosibirsk │ └─────────────────────┴──────────────────┘ ``` This happens due to different parsing pipelines: - `toDateTime()` without explicitly given time zone used in the first `SELECT` query honors setting `session_timezone` and the global time zone. - In the second query, a DateTime is parsed from a String, and inherits the type and time zone of the existing column`d`. Thus, setting `session_timezone` and the global time zone are not honored. **See also** - [timezone](/reference/settings/server-settings/settings/other#timezone) )", BETA) \ DECLARE(Bool, create_if_not_exists, false, R"( Enable `IF NOT EXISTS` for `CREATE` statement by default. If either this setting or `IF NOT EXISTS` is specified and a table with the provided name already exists, no exception will be thrown. )", 0, \ {"24.9", false, false, "New setting."}) \ DECLARE(UInt64, create_token_default_ttl_seconds, 1800, R"( The lifetime, in seconds, given to a token created by [`CREATE TOKEN`](/reference/statements/create/token) which does not specify its own `VALID UNTIL` or `VALID FOR` clause. The default is 30 minutes, so a token that is not asked to live longer is short-lived. Possible values: - Positive integer — the token expires this many seconds after it is created. - 0 — a token without an explicit clause never expires. This is only a default. An explicit `VALID UNTIL` or `VALID FOR` clause of the query always wins, including `VALID UNTIL 'infinity'`, which creates a token that never expires regardless of this setting. )", 0, \ {"26.9", 1800, 1800, "New setting giving a lifetime to a token created by `CREATE TOKEN` without an explicit `VALID UNTIL` or `VALID FOR` clause. The statement is new, so there is no earlier behavior to restore and the previous value is the default itself: a `compatibility` with an older version must not turn tokens into never-expiring ones."}) \ DECLARE(Bool, enforce_strict_identifier_format, false, R"( If enabled, only allow identifiers containing alphanumeric characters and underscores. )", 0, \ {"24.10", false, false, "New setting."}) \ DECLARE(UInt64, max_limit_for_vector_search_queries, 1'000, R"( SELECT queries with LIMIT bigger than this setting cannot use vector similarity indices. Helps to prevent memory overflows in vector similarity indices. )", 0, \ {"25.5", 1'000, 1'000, "New setting"}) \ DECLARE(UInt64, hnsw_candidate_list_size_for_search, 256, R"( The size of the dynamic candidate list when searching the vector similarity index, also known as 'ef_search'. )", 0, \ {"24.10", 64, 256, "New setting. Previously, the value was optionally specified in CREATE INDEX and 64 by default."}) \ DECLARE(Bool, vector_search_with_rescoring, false, R"( If ClickHouse performs rescoring for queries that use the vector similarity index. Without rescoring, the vector similarity index returns the rows containing the best matches directly. With rescoring, the vector similarity index fetches candidate rows and ClickHouse computes the exact distance for these rows from the original full-precision vectors in the regular SQL pipeline. When possible, ClickHouse filters the scan to candidate rows before the final distance computation. Increase `vector_search_index_fetch_multiplier` if more candidate rows are needed for better recall, especially with additional filters or quantized vector indexes. Note: A query run without rescoring and with parallel replicas enabled may fall back to rescoring. )", 0, \ {"25.8", true, false, "New setting."}) \ DECLARE(VectorSearchFilterStrategy, vector_search_filter_strategy, VectorSearchFilterStrategy::AUTO, R"( If a vector search query has a WHERE clause, this setting determines if it is evaluated first (pre-filtering) OR if the vector similarity index is checked first (post-filtering). Possible values: - 'auto' - Postfiltering (the exact semantics may change in future). - 'postfilter' - Use vector similarity index to identify the nearest neighbours, then apply other filters - 'prefilter' - Evaluate other filters first, then perform brute-force search to identify neighbours. )", 0, \ {"25.5", "auto", "auto", "New setting"}) \ DECLARE_WITH_ALIAS(Float, vector_search_index_fetch_multiplier, 1.0, R"( Multiply the number of fetched nearest neighbors from the vector similarity index by this number. Only applied for post-filtering with other predicates or if setting 'vector_search_with_rescoring = 1'. Valid range: [1.0, 1000.0]. Values outside this range are rejected. )", 0, vector_search_postfilter_multiplier, \ {"25.8", 1.0, 1.0, "Alias for setting 'vector_search_postfilter_multiplier'"}, \ {"25.5", 1.0, 1.0, "New setting. At the time the setting was named `vector_search_postfilter_multiplier`, which is now an alias of it."}) \ DECLARE(Bool, vector_search_use_quantized_codes, false, R"( Enables a two-stage approximate vector search without index (brute force scan) over a `Quantized`-compressed column. When enabled, `ORDER BY L2Distance|cosineDistance(vec, reference) LIMIT k` against a column encoded with a `Quantized(...)` codec will 1. scan and filter the quantized vectors (this step produces `k * vector_search_index_fetch_multiplier` results), and 2. rescore the found vectors against original, full-precision vectors. )", 0, \ {"26.7", false, false, "New setting to opt into the two-stage approximate vector-search optimization over a Quantize(...) column codec; queries stay exact by default."}) \ DECLARE(Bool, mongodb_throw_on_unsupported_query, true, R"( If enabled, MongoDB tables will return an error when a MongoDB query cannot be built. Otherwise, ClickHouse reads the full table and processes it locally. )", 0, \ {"24.10", false, true, "New setting."}, \ {"24.9", false, true, "New setting."}) \ DECLARE(Bool, implicit_select, false, R"( Allow writing simple SELECT queries without the leading SELECT keyword, which makes it simple for calculator-style usage, e.g. `1 + 2` becomes a valid query. In `clickhouse-local` it is enabled by default and can be explicitly disabled. )", 0, \ {"24.10", false, false, "A new setting."}) \ DECLARE(Bool, optimize_extract_common_expressions, true, R"( Allow extracting common expressions from disjunctions in WHERE, PREWHERE, ON, HAVING and QUALIFY expressions. A logical expression like `(A AND B) OR (A AND C)` can be rewritten to `A AND (B OR C)`, which might help to utilize: - indices in simple filtering expressions - cross to inner join optimization )", 0, \ {"25.1", false, true, "Optimize WHERE, PREWHERE, ON, HAVING and QUALIFY expressions by extracting common expressions out from disjunction of conjunctions."}, \ {"24.12", false, false, "Introduce setting to optimize WHERE, PREWHERE, ON, HAVING and QUALIFY expressions by extracting common expressions out from disjunction of conjunctions."}) \ DECLARE(Bool, optimize_and_compare_chain, true, R"( Populate constant comparison in AND chains to enhance filtering ability. Support operators `<`, `<=`, `>`, `>=`, `=` and mix of them. For example, `(a < b) AND (b < c) AND (c < 5)` would be `(a < b) AND (b < c) AND (c < 5) AND indexHint(b < 5) AND indexHint(a < 5)`. The derived comparisons are wrapped in `indexHint`: they participate in index analysis (primary key, partition key, skipping indexes) and prune the read set, but cost nothing per row and do not affect PREWHERE. A comparison derived through expressions of different tables stays executable (`(t1.a < t2.b) AND (t2.b < 5)` derives plain `t1.a < 5`): it is the only condition that can be pushed below the join, where it filters a join input the original chain cannot reach. Derived comparisons that contradict an existing condition are also added as plain conditions, so the `AND` folds to `false`. )", 0, \ {"25.2", false, true, "A new setting"}) \ DECLARE(Bool, optimize_redundant_comparisons, true, R"( Detect conflicting and redundant comparison conditions on the same expression within AND chains. For example, `a < 1 AND a > 5` would be rewritten to `false`. A contradiction between two `equals` on the same expression (for example, `a = 1 AND a = 2`) is detected independently of this setting. )", 0, \ {"26.7", false, true, "New setting to detect conflicting and redundant comparison conditions on the same expression within AND chains."}) \ DECLARE(UInt64, optimize_and_compare_chain_max_hash_work, 5'000'000, R"( Work budget for the `optimize_and_compare_chain` optimization during query analysis, measured in the number of query-tree nodes hashed by `getTreeHash` (the dominant cost of this optimization). If applying the optimization to a query hashes more than this many nodes, the optimization is not applied to that query. This bounds analysis time for queries with very many or very large `AND`-chains of comparisons, where the optimization can otherwise dominate analysis while folding nothing. Stopping early is always safe: it only forgoes an optimization and never changes results. Set to `0` to disable the budget (unlimited). )", 0, \ {"26.7", 0, 5'000'000, "New setting that bounds the work of the `optimize_and_compare_chain` optimization (measured in query-tree nodes hashed) so it cannot dominate analysis of queries with very many or very large `AND`-chains of comparisons. The previous value `0` (unlimited) reproduces the pre-26.7 behavior where the optimization was uncapped, so `compatibility` set to an earlier version keeps deriving transitive predicates without a budget. Set to `0` to disable the budget."}) \ DECLARE(Bool, push_external_roles_in_interserver_queries, true, R"( Enable pushing user roles from originator to other nodes while performing a query. )", 0, \ {"24.11", false, true, "New setting."}) \ DECLARE(Bool, use_join_disjunctions_push_down, true, R"( Enable pushing OR-connected parts of JOIN conditions down to the corresponding input sides ("partial pushdown"). This allows storage engines to filter earlier, which can reduce data read. The optimization is semantics-preserving and is applied only when each top-level OR branch contributes at least one deterministic predicate for the target side. )", 0, \ {"26.1", false, true, "Enabled this optimization."}, \ {"25.10", false, false, "New setting."}) \ DECLARE(Bool, shared_merge_tree_sync_parts_on_partition_operations, true, R"( Automatically synchronize set of data parts after MOVE|REPLACE|ATTACH partition operations in SMT tables. Cloud only )", 0, \ {"24.12", 1, 1, "New setting. By default parts are always synchronized"}) \ DECLARE(String, implicit_table_at_top_level, "", R"( If not empty, queries without FROM at the top level will read from this table instead of system.one. This is used in clickhouse-local for input data processing. The setting could be set explicitly by a user but is not intended for this type of usage. Subqueries are not affected by this setting (neither scalar, FROM, or IN subqueries). SELECTs at the top level of UNION, INTERSECT, EXCEPT chains are treated uniformly and affected by this setting, regardless of their grouping in parentheses. It is unspecified how this setting affects views and distributed queries. The setting accepts a table name (then the table is resolved from the current database) or a qualified name in the form of 'database.table'. Both database and table names have to be unquoted - only simple identifiers are allowed. )", 0, \ {"25.5", "", "", "A new setting, used in clickhouse-local"}) \ DECLARE(Bool, allow_general_join_planning, true, R"( Allows a more general join planning algorithm that can handle more complex conditions, but only works with hash join. If hash join is not enabled, then the usual join planning algorithm is used regardless of the value of this setting. )", 0, \ {"25.1", false, true, "Allow more general join planning algorithm when hash join algorithm is enabled."}) \ DECLARE(ObjectStorageGranularityLevel, cluster_table_function_split_granularity, ObjectStorageGranularityLevel::FILE, R"( Controls how data is split into tasks when executing a CLUSTER TABLE FUNCTION. This setting defines the granularity of work distribution across the cluster: - `file` — each task processes an entire file. - `bucket` — tasks are created per internal data block within a file (for example, Parquet row groups). Choosing finer granularity (like `bucket`) can improve parallelism when working with a small number of large files. For instance, if a Parquet file contains multiple row groups, enabling `bucket` granularity allows each group to be processed independently by different workers. )", 0, \ {"25.11", "file", "file", "New setting."}) \ DECLARE(String, cluster_table_function_pushed_down_filter, "", R"( This is an internal setting that should not be used directly. The initiator of a query with a cluster table function sets it for the replicas to the serialized filter on the table, so that the replicas drop the rows that do not pass it before sending them. )", 0, \ {"26.11", "", "", "New internal setting."}) \ DECLARE(UInt64, cluster_table_function_buckets_batch_size, 0, R"( Defines the approximate size of a batch (in bytes) used in distributed processing of tasks in cluster table functions with `bucket` split granularity. The system accumulates data until at least this amount is reached. The actual size may be slightly larger to align with data boundaries. )", 0, \ {"25.11", 0, 0, "New setting."}) \ DECLARE(Bool, cluster_table_function_split_by_split_offsets, false, R"( With `bucket` split granularity, when the table metadata records the file size and the row group offsets (`split_offsets` in Iceberg), cut files into byte ranges on these offsets without reading them; each task reads the row groups that start in its range. Otherwise, and on a hit in the query condition cache, the initiator reads the footer of every file. Requires all servers of the cluster to support it: a task with a byte range cannot be sent to a server of an older version. )", 0, \ {"26.11", false, false, "New setting."}) \ DECLARE(UInt64, merge_table_max_tables_to_look_for_schema_inference, 1000, R"( When creating a `Merge` table without an explicit schema or when using the `merge` table function, infer schema as a union of not more than the specified number of matching tables. If there is a larger number of tables, the schema will be inferred from the first specified number of tables. )", 0, \ {"25.1", 1, 1000, "A new setting"}) \ DECLARE(Bool, validate_enum_literals_in_operators, false, R"( If enabled, validate enum literals in operators like `IN`, `NOT IN`, `==`, `!=` against the enum type and throw an exception if the literal is not a valid enum value. )", 0, \ {"25.1", false, false, "A new setting"}) \ \ DECLARE(UInt64, max_autoincrement_series, 1000, R"( The limit on the number of series created by the `generateSerialID` function. As each series represents a node in Keeper, it is recommended to have no more than a couple of millions of them. )", 0, \ {"25.1", 1000, 1000, "A new setting"}) \ DECLARE(Bool, use_hive_partitioning, true, R"( When enabled, ClickHouse will detect Hive-style partitioning in path (`/name=value/`) in file-like table engines [File](/reference/functions/table-functions/file#hive-style-partitioning)/[S3](/reference/functions/table-functions/s3#hive-style-partitioning)/[URL](/reference/functions/table-functions/url#hive-style-partitioning)/[HDFS](/reference/functions/table-functions/hdfs#hive-style-partitioning)/[AzureBlobStorage](/reference/functions/table-functions/azureBlobStorage#hive-style-partitioning) and will allow to use partition columns as virtual columns in the query. These virtual columns will have the same names as in the partitioned path, but starting with `_`. )", 0, \ {"25.1", false, true, "Enabled the setting by default."}, \ {"24.8", false, false, "Allows to use hive partitioning for File, URL, S3, AzureBlobStorage and HDFS engines."}) \ DECLARE(Bool, throw_on_hive_partitioning_resolution_failure, true, R"( Throw an exception instead of logging a warning when Hive-style partitioning detection for an object storage table fails to list the storage. When disabled, the query runs without the Hive partition columns, which may change its result. )", 0, \ {"26.8", false, true, "New setting to fail the query when Hive-style partitioning detection for an object storage table cannot list the storage, instead of running without the Hive partition columns."}) \ DECLARE(UInt64, parallel_hash_join_threshold, 100'000, R"( For an `INNER`, `LEFT`, `RIGHT` or `FULL` hash join, this threshold decides how the hash table is built. If the estimated number of rows in the right table is below the threshold, the join builds the hash table as one part, on one thread. At or above the threshold, and also when there is no estimate, the join splits the hash table into parts that up to `max_threads` threads fill at the same time (one thread with `max_threads = 1`). `0` always splits the hash table. With `hash_join_layout` set to `serial` or `parallel`, this threshold is not used: the join builds one part or splits the hash table, whatever the estimate. The estimate comes from the query plan, or from the statistics of earlier runs of the same join (see `collect_hash_table_stats_during_joins`). The query plan estimates 0 rows for a right table known to be empty, such as a `MergeTree` table without data parts. `ASOF` joins never get an estimate, and with `query_plan_optimize_join_order_limit = 0` no join gets one. )", 0, \ {"25.5", 0, 100'000, "New setting"}, \ {"25.4", 0, 0, "New setting"}, \ {"25.3", 0, 0, "New setting"}) \ DECLARE(HashJoinLayout, hash_join_layout, HashJoinLayout::AUTO, R"( How an `INNER`, `LEFT`, `RIGHT` or `FULL` hash join builds its hash table. `auto`, the default, lets the planner choose the layout with `parallel_hash_join_threshold`; set `serial` or `parallel` to force one. Possible values: - `auto` — `parallel_hash_join_threshold` decides, from the estimated number of rows in the right table. See that setting for a join without an estimate. - `serial` — the hash table is one part, filled by one thread, whatever the estimate. - `parallel` — the hash table is split into parts that up to `max_threads` threads fill at the same time (one thread with `max_threads = 1`), whatever the estimate. Some joins always build one part, whatever the value: - joins of other kinds, such as `CROSS`; - a join with a `Join` table or a key-value storage on the right; - each bucket of a grace hash join; - the hash join that `join_algorithm = 'auto'` starts with when the join cannot spill to disk (for example with `max_bytes_before_external_join` and `max_bytes_ratio_before_external_join` both `0`) and can switch to a partial merge join instead; - each per-shard join of `query_plan_join_shard_by_pk_ranges`. )", 0, \ {"26.11", "auto", "auto", "New setting to force the layout of a hash join. `auto` keeps choosing it with `parallel_hash_join_threshold`."}) \ DECLARE(Bool, apply_settings_from_server, true, R"( Whether the client should accept settings from server. This only affects operations performed on the client side, in particular parsing the INSERT input data and formatting the query result. Most of query execution happens on the server and is not affected by this setting. Normally this setting should be set in user profile (users.xml or queries like `ALTER USER`), not through the client (client command line arguments, `SET` query, or `SETTINGS` section of `SELECT` query). Through the client it can be changed to false, but can't be changed to true (because the server won't send the settings if user profile has `apply_settings_from_server = false`). Note that initially (24.12) there was a server setting (`send_settings_to_client`), but latter it got replaced with this client setting, for better usability. )", 0, \ {"25.2", false, true, "Client-side code (e.g. INSERT input parsing and query output formatting) will use the same settings as the server, including settings from server config."}) \ DECLARE(Bool, allow_archive_path_syntax, true, R"( File/S3 engines/table function will parse paths with '::' as ` :: ` if the archive has correct extension. )", 0, \ {"24.8", true, true, "Added new setting to allow disabling archive path syntax."}, \ {"24.5", false, true, "Added new setting to allow disabling archive path syntax."}) \ DECLARE(S3UriStyle, s3_uri_style, S3UriStyle::AUTO, R"( Force the s3 endpoint style. Possible values: auto, virtual_hosted, path. )", 0, \ {"26.4", "auto", "auto", "New setting."}) \ DECLARE(Milliseconds, low_priority_query_wait_time_ms, 1000, R"( When the query prioritization mechanism is employed (see setting `priority`), low-priority queries wait for higher-priority queries to finish. This setting specifies the duration of waiting. )", BETA, \ {"25.4", 1000, 1000, "New setting."}) \ DECLARE(UInt64, iceberg_insert_max_rows_in_data_file, 1000000, R"( Max rows of iceberg parquet data file on insert operation. )", 0, \ {"25.9", 1000000, 1000000, "New setting."}) \ DECLARE(UInt64, iceberg_insert_max_bytes_in_data_file, 512_MiB, R"( Max bytes of iceberg parquet data file on insert operation. The default mirrors the documented default of the Iceberg table property `write.target-file-size-bytes` (512 MiB), see https://iceberg.apache.org/docs/1.5.2/configuration/. The limit is compared against the size of the file written so far, that is, the compressed size, so a file can exceed it by what the writer still buffers, such as incomplete Parquet row groups and the ones being encoded. `iceberg_insert_max_rows_in_data_file` caps the file independently of its size. )", 0, \ {"26.9", 1024 * 1024 * 1024, 512 * 1024 * 1024, "Aligned with the documented default of the Iceberg table property `write.target-file-size-bytes` (512 MiB), see https://iceberg.apache.org/docs/1.5.2/configuration/."}, \ {"25.9", 1_GiB, 1_GiB, "New setting."}) \ DECLARE(UInt64, iceberg_insert_max_data_files_in_upload, 8, R"( The maximum number of finished data files of one insert stream whose upload is not waited for while the `INSERT` writes the next file, for object storages that upload in the background (S3, Azure). Such a file holds its upload buffers until its upload completes, so higher values hide more upload latency at the cost of memory. `0` waits for the upload of each data file before writing the next one. )", 0, \ {"26.11", 0, 8, "New setting. An INSERT into Iceberg on S3 or Azure no longer waits for the upload of each finished data file."}) \ DECLARE(Bool, iceberg_insert_single_manifest_for_all_partitions, false, R"( An `INSERT` into a partitioned Iceberg table writes one manifest file for all the partitions it touches, like Spark and PyIceberg, instead of one manifest file per partition. This holds per insert stream: every stream commits its own snapshot with its own manifest, so an `INSERT` writes exactly one manifest only with `max_insert_threads = 1`. `OPTIMIZE TABLE ... MANIFEST` then also merges manifests of different partitions into one. `ALTER TABLE ... DROP PARTITION` cannot drop a partition whose manifest is shared with other partitions. )", 0, \ {"26.11", false, false, "New setting."}) \ DECLARE(UInt64, iceberg_insert_max_partitions, 100, R"( Max allowed partitions count per one insert operation for Iceberg table engine. )", 0, \ {"25.12", 100, 100, "New setting."}) \ DECLARE(Bool, database_datalake_require_metadata_access, true, R"( Either to throw error or not if we don't have rights to get table's metadata in database engine DataLakeCatalog. )", 0, \ {"26.1", true, true, "New setting."}) \ DECLARE(Float, min_os_cpu_wait_time_ratio_to_throw, 0.0, "Min ratio between OS CPU wait (OSCPUWaitMicroseconds metric) and busy (OSCPUVirtualTimeMicroseconds metric) times to consider rejecting queries. Linear interpolation between min and max ratio is used to calculate the probability, the probability is 0 at this point.", 0, \ {"25.5", 0, 0, "Setting values were changed and backported to 25.4"}, \ {"25.4", 0, 0, "New setting"}) \ DECLARE(Float, max_os_cpu_wait_time_ratio_to_throw, 0.0, "Max ratio between OS CPU wait (OSCPUWaitMicroseconds metric) and busy (OSCPUVirtualTimeMicroseconds metric) times to consider rejecting queries. Linear interpolation between min and max ratio is used to calculate the probability, the probability is 1 at this point.", 0, \ {"25.5", 0, 0, "Setting values were changed and backported to 25.4"}, \ {"25.4", 0, 0, "New setting"}) \ DECLARE(Bool, enable_producing_buckets_out_of_order_in_aggregation, true, R"( Allow memory-efficient aggregation (see `distributed_aggregation_memory_efficient`) to produce buckets out of order. It may improve performance when aggregation bucket sizes are skewed by letting a replica to send buckets with higher id-s to the initiator while it is still processing some heavy buckets with lower id-s. The downside is potentially higher memory usage. )", 0, \ {"25.9", false, true, "New setting"}) \ DECLARE(Bool, enable_packed_string_keys_in_aggregation, true, R"( Use a hash table keyed by 16-byte packed string references (`PackedStringRef`) for `GROUP BY` with a single non-nullable `String` key. Keys of up to 11 bytes are stored inline in the packed reference; longer keys are referenced in an arena. This is faster for most workloads, but can be slower than the legacy method for `GROUP BY` with very few distinct keys longer than 11 bytes (most noticeably 12..24 bytes), where the legacy hash table keeps keys inline in the cell while the packed one dereferences the arena pointer on every probe. When disabled, the legacy `StringHashTable`-based method (the default before 26.8) is used. All servers participating in a distributed query must agree on this value: with `distributed_aggregation_memory_efficient`, two-level bucket numbers depend on the key hash, which differs between the two methods, so servers disagreeing on this setting may split the same key into different buckets and produce an incorrectly merged result. To guarantee agreement, the initiator always sends its effective value with the secondary queries (even when it comes only from server/profile defaults), overriding the remote servers' own defaults. )", 0, \ {"26.8", false, true, "New setting to toggle the `PackedStringRef`-based hash table for single-`String`-key GROUP BY. previous_value=false so `compatibility` with versions before 26.8 restores the legacy `StringHashTable`-based method, including its two-level bucketing."}) \ DECLARE(Bool, enable_fixed_and_packed_string_keys_in_aggregation, true, R"( Use a dedicated hash table for `GROUP BY` with fixed-width keys of up to 16 bytes in total and one non-nullable `String` key. Any of these keys can be `LowCardinality`. A key with an empty string is stored by its fixed-width values alone, in cells as narrow as fixed-width keys; the other keys are stored as the fixed-width values and a packed reference to the string, which keeps strings of up to 11 bytes inline, or of up to 15 bytes when the fixed-width values take at most 4 bytes. A `GROUP BY` without aggregate functions stores the keys alone, with no room for aggregate states, so it uses less memory. When disabled, the serialized method is used. )", 0, \ {"26.11", false, true, "New setting to use a dedicated hash table for `GROUP BY` with fixed-width keys of up to 16 bytes in total and one non-nullable `String` key. When disabled, the serialized method is used."}) \ DECLARE(Bool, enable_parallel_blocks_marshalling, true, "Affects only distributed queries. If enabled, blocks will be (de)serialized and (de)compressed on pipeline threads (i.e. with higher parallelism that what we have by default) before/after sending to the initiator.", 0, \ {"25.6", "false", "true", "A new setting"}) \ DECLARE(Bool, enable_parallel_single_level_merge, true, R"( Parallelize the final merge of the per-thread single-level aggregation hash tables. The key space is split into disjoint partitions by key hash, and each partition is merged independently: the merging thread enumerates all per-thread tables and combines the keys that belong to its partition, so no two threads ever touch the same key. If the setting is turned off, the single-level tables are merged serially on one thread. Aggregation by 8- and 16-bit keys keeps its own range-partitioned parallel merge regardless of this setting. )", 0, \ {"26.8", false, true, "New setting to parallelize the final merge of the single-level aggregation hash tables by splitting the key space into disjoint hash partitions that the threads merge independently."}) \ DECLARE(Bool, enable_parallel_single_level_merge_by_index, true, R"( Lets the parallel merge of single-level aggregation hash tables (see `enable_parallel_single_level_merge`) read the tables of the adaptive aggregator (see `enable_adaptive_aggregator`) through an index of their cells, which every thread builds when it finishes aggregating. For each partition, the merge then reads only the cells of that partition from every table. If the setting is turned off, the merge scans every cell of every table for each partition. )", 0, \ {"26.11", false, true, "New setting to let the parallel merge read only the cells of each partition from the adaptive aggregator's single-level hash tables through the indexes of their cells, instead of scanning every cell of every table for each partition."}) \ DECLARE(UInt64, min_outstreams_per_resize_after_split, 24, R"( Specifies the minimum number of output streams of a `Resize` or `StrictResize` processor after the split is performed during pipeline generation. If the resulting number of streams is less than this value, the split operation will not occur. ### What is a Resize Node A `Resize` node is a processor in the query pipeline that adjusts the number of data streams flowing through the pipeline. It can either increase or decrease the number of streams to balance the workload across multiple threads or processors. For example, if a query requires more parallelism, the `Resize` node can split a single stream into multiple streams. Conversely, it can merge multiple streams into fewer streams to consolidate data processing. The `Resize` node ensures that data is evenly distributed across streams, maintaining the structure of the data blocks. This helps optimize resource utilization and improve query performance. ### Why the Resize Node Needs to Be Split During pipeline execution, ExecutingGraph::Node::status_mutex of the centrally-hubbed `Resize` node is heavily contended especially in high-core-count environments, and this contention leads to: 1. Increased latency for ExecutingGraph::updateNode, directly impacting query performance. 2. Excessive CPU cycles are wasted in spin-lock contention (native_queued_spin_lock_slowpath), degrading efficiency. 3. Reduced CPU utilization, limiting parallelism and throughput. ### How the Resize Node Gets Split 1. The number of output streams is checked to ensure the split could be performed: the output streams of each split processor meet or exceed the `min_outstreams_per_resize_after_split` threshold. 2. The `Resize` node is divided into smaller `Resize` nodes with equal count of ports, each handling a subset of input and output streams. 3. Each group is processed independently, reducing the lock contention. ### Splitting Resize Node with Arbitrary Inputs/Outputs In some cases, where the inputs/outputs are indivisible by the number of split `Resize` nodes, some inputs are connected to `NullSource`s and some outputs are connected to `NullSink`s. This allows the split to occur without affecting the overall data flow. ### Purpose of the Setting The `min_outstreams_per_resize_after_split` setting ensures that the splitting of `Resize` nodes is meaningful and avoids creating too few streams, which could lead to inefficient parallel processing. By enforcing a minimum number of output streams, this setting helps maintain a balance between parallelism and overhead, optimizing query execution in scenarios involving stream splitting and merging. ### Disabling the Setting To disable the split of `Resize` nodes, set this setting to 0. This will prevent the splitting of `Resize` nodes during pipeline generation, allowing them to retain their original structure without division into smaller nodes. )", 0, \ {"25.6", 0, 24, "New setting."}) \ DECLARE(Bool, enable_add_distinct_to_in_subqueries, false, R"( Enable `DISTINCT` in `IN` subqueries. This is a trade-off setting: enabling it can greatly reduce the size of temporary tables transferred for distributed IN subqueries and significantly speed up data transfer between shards, by ensuring only unique values are sent. However, enabling this setting adds extra merging effort on each node, as deduplication (DISTINCT) must be performed. Use this setting when network transfer is a bottleneck and the additional merging cost is acceptable. )", 0, \ {"25.8", false, false, "New setting to reduce the size of temporary tables transferred for distributed IN subqueries."}) \ DECLARE(UInt64, function_date_trunc_return_type_behavior, 0, R"( Allows to change the behaviour of the result type of `dateTrunc` function. Possible values: - 0 - When the second argument is `DateTime64/Date32` the return type will be `DateTime64/Date32` regardless of the time unit in the first argument. - 1 - For `Date32` the result is always `Date`. For `DateTime64` the result is `DateTime` for time units `second` and higher. )", 0, \ {"25.7", 0, 0, "Add new setting to preserve old behaviour of dateTrunc function"}, \ {"25.4", 1, 0, "Change the result type for dateTrunc function for DateTime64/Date32 arguments to DateTime64/Date32 regardless of time unit to get correct result for negative values"}) \ DECLARE(Bool, enable_function_early_short_circuit, false, R"( Enable early short-circuit constant folding for `and` and `or` during query analysis. When enabled, eligible dead scalar-subquery branches are analyzed to preserve their types and validate query semantics, but they are not executed. The optimization falls back to normal analysis when scalar cardinality or runtime values are required. )", 0, \ {"26.8", false, false, "New setting"}) \ DECLARE(Bool, query_plan_remove_unused_columns, true, R"( Toggles a query-plan-level optimization which tries to remove unused columns (both input and output columns) from query plan steps. Only takes effect if setting [query_plan_enable_optimizations](#query_plan_enable_optimizations) is 1. This is an expert-level setting which should only be used for debugging by developers. The setting may change in future in backward-incompatible ways or be removed. Possible values: - 0 - Disable - 1 - Enable )", 0, \ {"25.12", false, true, "New setting. Add optimization to remove unused columns in query plan."}) \ DECLARE(Bool, kill_throw_if_noop, true, R"( Controls whether [`KILL QUERY`](/reference/statements/kill#kill-query) and [`KILL MUTATION`](/reference/statements/kill#kill-mutation) throw an exception when their `WHERE` clauses match no rows. Enabled by default. `KILL QUERY` throws when there are no eligible rows in `system.processes` after excluding the current `KILL` statement, and `KILL MUTATION` throws when no rows match in `system.mutations`. Set to `false` to allow empty matches without an exception. `TEST` dry runs return an empty preview without throwing. `ON CLUSTER` execution does not throw for empty matches because match results are not aggregated across hosts. Possible values: - 1 — Throw an exception. - 0 — Do not throw an exception. )", 0, \ {"26.11", false, true, "Enable `kill_throw_if_noop` by default so that `KILL QUERY` and `KILL MUTATION` report empty matches."}, \ {"26.10", false, false, "New setting"}) \ DECLARE(Bool, jemalloc_enable_profiler, false, R"( Enable jemalloc profiler for the query. Jemalloc will sample allocations and all deallocations for sampled allocations. Profiles can be flushed using SYSTEM JEMALLOC FLUSH PROFILE which can be used for allocation analysis. Samples can also be stored in system.trace_log using config jemalloc_collect_global_profile_samples_in_trace_log or with query setting jemalloc_collect_profile_samples_in_trace_log. See [Allocation Profiling](/concepts/features/performance/allocation-profiling))", 0, \ {"25.9", false, false, "New setting"}) \ DECLARE(Bool, jemalloc_collect_profile_samples_in_trace_log, false, R"( Collect jemalloc allocation and deallocation samples in trace log. )", 0, \ {"25.9", false, false, "New setting"}) \ DECLARE(JemallocProfileFormat, jemalloc_profile_text_output_format, JemallocProfileFormat::Collapsed, R"( Output format for jemalloc heap profile in system.jemalloc_profile_text table. Can be: 'raw' (raw profile), 'symbolized' (jeprof format with symbols), or 'collapsed' (FlameGraph format). )", 0, \ {"26.2", "collapsed", "collapsed", "New setting to control output format for system.jemalloc_profile_text table. Possible values: 'raw', 'symbolized', 'collapsed'"}) \ DECLARE(Bool, jemalloc_profile_text_symbolize_with_inline, true, R"( Whether to include inline frames when symbolizing jemalloc heap profile. When enabled, inline frames are included which can slow down symbolization process drastically; when disabled, they are skipped. Only affects 'symbolized' and 'collapsed' output formats. )", 0, \ {"26.2", true, true, "New setting to control whether to include inline frames when symbolizing jemalloc heap profile. When enabled, inline frames are included at the cost of slower symbolization; when disabled, they are skipped for faster output"}) \ DECLARE(Bool, jemalloc_profile_text_collapsed_use_count, false, R"( When using the 'collapsed' output format for jemalloc heap profile, aggregate by allocation count instead of bytes. When false (default), each stack is weighted by live bytes; when true, by live allocation count. )", 0, \ {"26.2", false, false, "New setting to aggregate by allocation count instead of bytes in the collapsed jemalloc heap profile format"}) \ DECLARE_WITH_ALIAS(Int32, os_threads_nice_value_query, 0, R"( Linux nice value for query processing threads. Lower values mean higher CPU priority. Requires CAP_SYS_NICE capability, otherwise no-op. Possible values: -20 to 19. )", 0, os_thread_priority, \ {"25.9", 0, 0, "New setting, with `os_thread_priority` as an alias of it."}) \ DECLARE(Int32, os_threads_nice_value_materialized_view, 0, R"( Linux nice value for materialized view threads. Lower values mean higher CPU priority. Requires CAP_SYS_NICE capability, otherwise no-op. Possible values: -20 to 19. )", 0, \ {"25.9", 0, 0, "New setting."}) \ DECLARE(Bool, show_processlist_include_internal, 1, R"( Show internal auxiliary processes in the `SHOW PROCESSLIST` query output. Internal processes include dictionary reloads, refreshable materialized view reloads, auxiliary `SELECT`s executed in `SHOW ...` queries, auxiliary `CREATE DATABASE ...` queries executed internally to accommodate broken tables and more. )", 0, \ {"25.11", false, true, "New setting."}) \ DECLARE(Bool, use_roaring_bitmap_iceberg_positional_deletes, false, R"( Use roaring bitmap for iceberg positional deletes. )", 0, \ {"25.8", false, false, "New setting"}) \ DECLARE(Bool, inject_random_order_for_select_without_order_by, false, R"( If enabled, injects `SHUFFLE` into SELECT queries without ORDER BY clause. Applied only for subquery depth = 0. Subqueries and INSERT INTO ... SELECT are not affected. If the top-level construct is UNION, `SHUFFLE` is injected into all children independently. Only useful for testing and development (missing ORDER BY is a source of non-deterministic query results). )", 0, \ {"25.10", false, false, "New setting"}) \ DECLARE(Int64, optimize_const_name_size, 256, R"( Replace with scalar and use hash as a name for large constants (size is estimated by the name length). Possible values: - positive integer - max length of the name, - 0 — always, - negative integer - never. )", 0, \ {"25.11", -1, 256, "Replace with scalar and use hash as a name for large constants (size is estimated by name length)"}) \ DECLARE(Bool, serialize_string_in_memory_with_zero_byte, true, R"( Serialize String values during aggregation with zero byte at the end. Enable to keep compatibility when querying cluster of incompatible versions. )", 0, \ {"25.12", true, true, "New setting"}, \ {"25.8", true, true, "New setting"}) \ DECLARE(UInt64, s3_path_filter_limit, 1000, R"( Maximum number of `_path` values that can be extracted from query filters to use for file iteration instead of glob listing. 0 means disabled. )", 0, \ {"25.12", 0, 1000, "New setting"}) \ DECLARE(Bool, ignore_on_cluster_for_replicated_database, false, R"( Always ignore ON CLUSTER clause for DDL queries with replicated databases. )", 0, \ {"26.1", false, false, "Add a new setting to ignore ON CLUSTER clause for DDL queries with a replicated database."}) \ DECLARE_WITH_ALIAS(Bool, enable_nullable_tuple_type, true, R"( Allows creation of [Nullable](/reference/data-types/nullable) [Tuple](/reference/data-types/tuple) columns in tables. This setting does not control whether extracted tuple subcolumns can be `Nullable` (for example, from Dynamic, Variant, JSON, or Tuple columns). Use `allow_nullable_tuple_in_extracted_subcolumns` to control whether extracted tuple subcolumns can be `Nullable`. )", 0, allow_experimental_nullable_tuple_type, \ {"26.9", false, true, "`Nullable(Tuple)` is now GA. This also applies to the alias `allow_experimental_nullable_tuple_type`."}, \ {"26.6", false, false, "Nullable Tuple is now Beta. Added as an alias for 'allow_experimental_nullable_tuple_type'."}, \ {"26.1", false, false, "New experimental setting. At the time the setting was named `allow_experimental_nullable_tuple_type`, which is now an alias of it."}) \ DECLARE(Bool, enable_subcolumn_codecs, false, R"( Allows declaring compression codecs for subcolumns of a column, such as elements of a `Tuple` or the keys and values of a `Map`, with `CODEC name (...)` entries in `CREATE TABLE` and with `ALTER TABLE ... MODIFY COLUMN name CODEC(...)`. Tables that already have such declarations work regardless of this setting, and the declarations can always be removed. A table with subcolumn codecs cannot be attached by a server of an older version. )", EXPERIMENTAL, \ {"26.11", false, false, "New setting to enable codec declarations for subcolumns."}) \ DECLARE(UInt64, archive_adaptive_buffer_max_size_bytes, 8 * DBMS_DEFAULT_BUFFER_SIZE, R"( Limits the maximum size of the adaptive buffer used when writing to archive files (for example, tar archives)", 0, \ {"26.1", 8 * 1024 * 1024, 8 * 1024 * 1024, "New setting"}) \ DECLARE(UInt64, shared_merge_tree_sequential_consistency_initial_parts_update_backoff_ms, 50, R"( Initial backoff in milliseconds for parts update when using `select_sequential_consistency` with `SharedMergeTree`. Only available in ClickHouse Cloud. )", 0, \ {"26.5", 50, 50, "New setting to reduce sporadic UNFINISHED errors in queries with sequential consistency for SharedMergeTree."}) \ DECLARE(UInt64, shared_merge_tree_sequential_consistency_max_parts_update_backoff_ms, 1000, R"( Max backoff in milliseconds for parts update when using `select_sequential_consistency` with `SharedMergeTree`. Only available in ClickHouse Cloud. )", 0, \ {"26.5", 1000, 1000, "New setting to reduce sporadic UNFINISHED errors in queries with sequential consistency for SharedMergeTree."}) \ DECLARE(UInt64, shared_merge_tree_sequential_consistency_parts_update_max_retries, 10, R"( Max retries for parts update when using `select_sequential_consistency` with `SharedMergeTree`. Only available in ClickHouse Cloud. )", 0, \ {"26.5", 10, 10, "New setting to reduce sporadic UNFINISHED errors in queries with sequential consistency for SharedMergeTree."}) \ DECLARE(UInt64, max_bytes_before_external_join, 0, R"( If set to a non-zero value and `join_algorithm` is `hash`, `parallel_hash`, `default`, or `auto`, a hash join spills the right-side data to disk once it exceeds this many bytes. That happens only when `GraceHashJoin` can run the join (one equality disjunct, supported kind and strictness). Multi-disjunct `ON` conditions (`OR`) stay on `hash` and can hit the memory limit with no spill. After the spill, the join continues as a grace hash join, or as a partial merge join when the query plan needs the left stream's row order (read in order through join), so the threshold does not prevent that optimization. Read in order passes through such a join only for `INNER` and `LEFT` joins with `ALL` or `ANY` strictness, with no mixed `ON` condition, without `join_any_take_last_row` for `ANY`, and with keys that are not floating-point, `JSON` or `Dynamic`, also when nested. Together with `max_bytes_ratio_before_external_join`, this is the threshold-based spill trigger for every hash-based `join_algorithm`, including `grace_hash`, which requires one of the two to be non-zero. Once a non-zero threshold makes a join spill-capable, `enable_adaptive_memory_spill_scheduler` can force it to spill under memory pressure before the threshold is reached. When set to `0` (default), this absolute byte threshold is disabled, but automatic spilling may still occur via `max_bytes_ratio_before_external_join` (which defaults to `0.5`). With both settings at `0`, the join never spills, so the scheduler has nothing to trigger. The exception is `legacy_join_size_limits_trigger_spilling`: with it on, standalone `grace_hash` ignores both settings and spills on `max_rows_in_join` / `max_bytes_in_join` instead. The threshold also bounds the right side materialized by the [block nested loop join](/reference/statements/select/join#join-with-an-arbitrary-on-condition), whatever `join_algorithm` is set to. )", 0, \ {"26.4", 0, 0, "New setting to control automatic spilling of hash joins to disk. Non-zero value enables spilling and sets the byte threshold."}) \ DECLARE(Double, max_bytes_ratio_before_external_join, 0.5, R"( The ratio of available memory that is allowed for `JOIN`. Once reached, a hash join spills the right-side data to disk. That happens only when `GraceHashJoin` can run the join (one equality disjunct, supported kind and strictness). Multi-disjunct `ON` conditions (`OR`) stay on `hash` and can hit the memory limit with no spill. After the spill, the join continues as a grace hash join, or as a partial merge join when the query plan needs the left stream's row order (see `max_bytes_before_external_join`). For example, if set to `0.6`, `JOIN` will allow using `60%` of the available memory (to server/user/merges) for the right-side hash table at the beginning of the execution; after that, it starts spilling to disk. If both `max_bytes_before_external_join` and `max_bytes_ratio_before_external_join` are set, the smaller resulting threshold is used. If the ratio is `0`, only the absolute setting applies. Has effect for every hash-based `join_algorithm`, including `grace_hash`, provided a temporary data path is configured. )", 0, \ {"26.5", 0., 0.5, "New setting: ratio of available memory used as the spill threshold for hash joins. Enabled by default at `0.5`, mirroring `max_bytes_ratio_before_external_group_by` and `max_bytes_ratio_before_external_sort`. Combined with the absolute `max_bytes_before_external_join` (the smaller of the two applies)."}) \ DECLARE(Bool, enable_join_fixed_hash_table_conversion, true, R"( Enable converting the hash table to a flat array for joins when the key is a single integer with a small value range. )", 0, \ {"26.4", false, true, "New setting to enable converting the hash table to a flat array for joins when the key is a single integer with a small value range."}) \ DECLARE(Bool, enable_join_key_only_hash_tables, true, R"( Use hash tables that store the join keys alone, without a reference to a right row, for joins whose result can never contain a value taken from a right row: `LEFT ANTI`, and `LEFT SEMI` when no right column is selected. Such a table has a smaller cell and lets the right blocks be dropped instead of stored. )", 0, \ {"26.9", false, true, "New setting to store the join keys alone, without a reference to a right row, in the hash tables of joins whose result can never contain a value taken from a right row (`LEFT ANTI`, and `LEFT SEMI` when no right column is selected)."}) \ DECLARE(Bool, enable_robin_hood_hash_for_joins, false, R"( Allow the hash tables of a hash join that splits its hash table into parts (see `hash_join_layout`) to switch to the Robin Hood mode when they become large, as the hash tables of aggregation do. A right table with more than about 8 million keys then takes up to two times less memory for its hash table, but the lookups of the join can be slower, depending on the keys. )", 0, \ {"26.11", true, false, "New setting. In 26.10 the hash tables of the `parallel_hash` join used the Robin Hood mode when they became large, which saves memory but can make large joins slower."}) \ DECLARE(Bool, enable_packed_string_keys_in_hash_join, true, R"( Makes `hash`, `parallel_hash` and `grace_hash` joins on a single `String` or `Nullable(String)` key faster and lowers their memory use. A join with `OR` qualifies when each of its conditions has a single such key. Because the hash table is smaller, a join reaches `max_bytes_in_join` and `max_bytes_before_external_join` later. The setting does not apply to `FixedString` or `LowCardinality(Nullable(String))` keys, to tables with the `Join` engine, or to `joinGet`. A join on a `LowCardinality(String)` key may use the key's dictionary instead. A join keeps exact keys when its hash table fits in the L2 cache of the CPU, and also when it would hash every left key and the right side has fewer rows than `min_rows_for_packed_string_keys_in_hash_join`. With that setting at 0, every join is packed, also one whose hash table fits in the L2 cache. )", 0, \ {"26.11", false, true, "New setting to make hash joins on a single `String` key faster and use less memory."}) \ DECLARE(UInt64, min_rows_for_packed_string_keys_in_hash_join, 100'000, R"( A hash join whose right side has a row estimate packs its `String` keys (see `enable_packed_string_keys_in_hash_join`) only when the hash table with exact keys would be larger than about the L2 cache of the CPU, or when this setting is 0. The size of the table is the number of right-side rows times the bytes of one row: a cell of 32 bytes plus the average length of the key, which adds 0 when unknown. Smaller joins gain little from packed keys, and can be slower. A packed key of more than 15 bytes is hashed for every row of the left side. A join with a runtime filter that passes mostly the rows with a match (see `enable_join_runtime_filters`) hashes only the rows that match, so it needs no minimum. Without such a filter, this setting is the minimum number of right-side rows. It applies when the average length of the key is more than 15 bytes, and when the length is unknown, because it then counts as long. The length is known from the `basic` column statistics of the key. `MergeTree` tables collect them by default, see `auto_statistics_types`. The key has no statistics when it is a column of a `Memory` table, the result of an aggregate function of a subquery, or the result of an expression in `ON`, such as `concat(k, 'x')` or `hex(k)`. A join with `OR` does not use them. A subquery that only passes the column on, or groups by it, keeps them. A `LEFT` join other than `SEMI` and `ANTI`, and a `FULL` join, keep all rows of their left side, so they get no runtime filter. The filter of a `LEFT ANTI` join passes the rows without a match, so it does not count. The number of rows is the right-side rows of an earlier run of the same join, if `collect_hash_table_stats_during_joins` is enabled. Otherwise it is the query optimizer's estimate, which `parallel_hash_join_threshold` uses too. Without an optimizer estimate, it is the estimate of this server for its own read of the right table. A join with neither packs the keys, unless the server that planned the query estimated the right side below this minimum. Each server of a distributed query decides from its own estimate, statistics and cache size. 0 packs the keys of every join. )", 0, \ {"26.11", 0, 100'000, "New setting: the minimum number of right-side rows for a hash join that would hash every left key, that is a key of an average length of more than 15 bytes, or of unknown length, without a runtime filter. `enable_packed_string_keys_in_hash_join` also needs a hash table larger than the L2 cache. 0 packs every join."}) \ DECLARE(UInt64, query_plan_max_limit_for_join_lazy_indexing, 1000, R"(Control maximum limit value that allows to use query plan for lazy indexing optimization in JOIN. If zero, there is no limit. )", 0, \ {"26.6", 1000, 1000, "Added new setting to control maximum limit value that allows to use query plan for lazy join indexing optimization. If zero, there is no limit"}) \ DECLARE(UInt64, query_plan_min_columns_for_join_lazy_indexing, 3, R"( Control the minimum number of payload columns from the left side required for enabling lazy indexing optimization in JOIN. 0 means the optimization is disabled. )", 0, \ {"26.6", 0, 3, "Control the minimum number of payload columns from the left side required for enabling lazy indexing optimization in JOIN"}) \ DECLARE_WITH_ALIAS(Bool, enable_json_lazy_type_hints, false, R"( Enables lazy type hints for the [JSON](/reference/data-types/newjson) type. With this setting enabled, `ALTER TABLE ... MODIFY COLUMN json JSON(path TypeName)` that only adds or changes type hints is a metadata-only operation: the type hints are applied at query time for existing parts and materialized during inserts and background merges instead of rewriting the historical data. )", 0, allow_experimental_json_lazy_type_hints, \ {"26.10", false, false, "Lazy `JSON` type hints are now GA. This also applies to the alias `allow_experimental_json_lazy_type_hints`."}, \ {"26.9", false, false, "Lazy JSON type hints are now Beta. An alias for setting 'allow_experimental_json_lazy_type_hints'."}, \ {"26.3", false, false, "New experimental setting for lazy JSON type hints. At the time the setting was named `allow_experimental_json_lazy_type_hints`, which is now an alias of it."}) \ DECLARE(Bool, enable_hash_join_row_store, true, R"( Enable transforming the payload of a hash join into a row-major layout. )", 0, \ {"26.9", false, true, "New setting to enable transforming the payload of a hash join into a row-major layout."}) \ DECLARE(Double, min_rows_ratio_for_hash_join_row_store, 3.0, R"( Minimum estimated ratio of join output rows to build-side rows to enable transforming hash join payload to row-major. 0 means the transformation is always allowed. )", 0, \ {"26.10", 5.0, 3.0, "Lowered the minimum estimated ratio of join output rows to build-side rows that enables the hash join row store."}, \ {"26.9", 5.0, 5.0, "New setting to control the minimum estimated ratio of join output rows to build-side rows to enable transforming hash join payload to row-major. 0 means the transformation is always allowed."}) \ DECLARE(UInt64, min_string_column_bytes_for_hash_join_row_store, 8_MiB, R"( Minimum estimated size of a build-side `String` column, the estimated number of rows multiplied by the average value size from statistics, to store it in the hash join row store. 0 means `String` columns are not stored in the row store. )", 0, \ {"26.11", 0, 8_MiB, "New setting to control the minimum estimated size of a build-side `String` column to store it in the hash join row store."}) \ \ /* ####################################################### */ \ /* AI function settings */ \ DECLARE_WITH_ALIAS(Bool, allow_ai_functions, true, R"( Allow the use of AI functions (`aiGenerate`, `aiClassify`, `aiFilter`, `aiExtract`, `aiTranslate`, `aiRedact`, `aiEmbed`, `aiSimilarity`). If disabled, a query that uses them throws an exception. )", 0, allow_experimental_ai_functions, \ {"26.11", true, true, "Added an alias for setting `allow_experimental_ai_functions`."}, \ {"26.9", false, true, "AI functions are beta and enabled by default. At the time the setting was named `allow_experimental_ai_functions`, which is now an alias of it. Keep the default regardless of `compatibility`.", CompatibilitySetting::Ignore}, \ {"26.4", false, false, "New setting. At the time the setting was named `allow_experimental_ai_functions`, which is now an alias of it."}) \ DECLARE(UInt64, ai_function_request_timeout_sec, 60, R"( Timeout in seconds for individual HTTP requests made by AI functions (AI chat completions and embedding API calls). If a request does not complete within this time, it is considered failed and may be retried according to `ai_function_max_retries`. )", BETA, \ {"26.4", 60, 60, "New setting"}) \ DECLARE(UInt64, ai_function_max_retries, 3, R"( Maximum number of retry attempts for transient errors per individual API request. Each retry uses exponential backoff starting from `ai_function_retry_initial_delay_ms`. At most 5. )", BETA, \ {"26.11", 3, 3, "The change was backported to 26.8 and is recorded there."}, \ {"26.8", 0, 3, "Retry a transient API error up to three times by default, so a 429 or 5xx from the provider does not fail the query and an overloaded rate-limited provider is retried under concurrent requests."}, \ {"26.4", 0, 0, "New setting"}) \ DECLARE(UInt64, ai_function_retry_initial_delay_ms, 1000, R"( Initial delay in milliseconds before the first retry of a failed AI function API request. The delay doubles on each subsequent attempt (exponential backoff). For example, with default settings: 1000ms, 2000ms, 4000ms. At most 10000. )", BETA, \ {"26.4", 1000, 1000, "New setting"}) \ DECLARE(Bool, ai_function_throw_on_error, true, R"( If true (default), an AI function call that fails permanently after exhausting all retries aborts the query with an exception. If false, the failed row receives the default value for the column type (empty string for String) and processing continues. )", BETA, \ {"26.4", true, true, "New setting"}) \ DECLARE(UInt64, ai_function_max_input_tokens_per_query, 0, R"( Maximum total input (prompt) tokens across all AI function API calls in a single query including cache reads and writes. 0 (default) disables the limit. Tracked cumulatively from provider responses. Note that this limit may be exceeded by up to one call's worth of input tokens per in-flight request, since a call's input tokens are not known until its response arrives. Like the other AI quotas, it is enforced per server / query fragment, not summed across a distributed query, and must be set in the top-level query - a sub-query `SETTINGS` override is ignored. This limit is only enforced for providers that report a `usage` object in their response (OpenAI, Anthropic, vLLM). Providers that omit token usage (notably HuggingFace TEI) cause the counter to stay at 0 — use `ai_function_max_api_calls_per_query` instead to bound such calls. )", BETA, \ {"26.10", 0, 0, "The change was backported to 26.7 and is recorded there."}, \ {"26.7", 1000000, 0, "The AI function per-query quotas are disabled by default: 0 means no limit."}, \ {"26.4", 1000000, 1000000, "New setting"}) \ DECLARE(UInt64, ai_function_max_output_tokens_per_query, 0, R"( Maximum total output (completion) tokens across all AI function API calls in a single query. 0 (default) disables the limit. Tracked cumulatively from provider responses. Note that this limit may be exceeded by up to one call's worth of output tokens per in-flight request, since a call's output tokens are not known until its response arrives. Like the other AI quotas, it is enforced per server / query fragment, not summed across a distributed query, and must be set in the top-level query - a sub-query `SETTINGS` override is ignored. This limit is only enforced for providers that report a `usage` object in their response (OpenAI, Anthropic, vLLM). It does not apply to the embedding functions (`aiEmbed`, `aiSimilarity`), which never produce output tokens. )", BETA, \ {"26.10", 0, 0, "The change was backported to 26.7 and is recorded there."}, \ {"26.7", 500000, 0, "The AI function per-query quotas are disabled by default: 0 means no limit."}, \ {"26.4", 500000, 500000, "New setting"}) \ DECLARE(UInt64, ai_function_max_api_calls_per_query, 0, R"( Maximum number of HTTP requests that AI functions may dispatch per query. 0 (default) disables the limit. Enforced independently by each server and query fragment: within one execution context it is an exact cap shared by every AI function, block, and thread there, but a distributed query (across shards or parallel-replica fragments) may dispatch up to this many requests per shard/fragment. It must be set in the top-level query - a sub-query `SETTINGS` override is ignored. )", BETA, \ {"26.10", 1000, 0, "The AI function per-query quotas are disabled by default: 0 means no limit.", CompatibilitySetting::Ignore}, \ {"26.8", 0, 1000, "Bound outbound AI function HTTP calls per query by default (previously 0 - unlimited)."}, \ {"26.4", 0, 0, "New setting"}) \ DECLARE(Bool, ai_function_throw_on_quota_exceeded, true, R"( If true (default), exceeding an AI function quota limit (`ai_function_max_input_tokens_per_query`, `ai_function_max_output_tokens_per_query`, or `ai_function_max_api_calls_per_query`) aborts the query with an exception. All three limits are disabled by default, so this has no effect until one of them is set. If false, remaining rows receive the default value for the column type (empty string for String). Like the quota limits, this must be set in the top-level query - a sub-query `SETTINGS` override is ignored. )", BETA, \ {"26.4", true, true, "New setting"}) \ DECLARE(NonZeroUInt64, ai_function_embedding_max_batch_size, 100, R"( Maximum number of texts to include in a single HTTP request made by the embedding functions (`aiEmbed`, `aiSimilarity`). Texts are grouped into batches of this size to reduce API call overhead. For example, 500 unique texts with a batch size of 100 result in 5 HTTP requests. )", BETA, \ {"26.6", 100, 100, "New setting"}) \ DECLARE(NonZeroUInt64, ai_function_max_concurrent_requests_per_thread, 8, R"( Maximum number of provider requests one query thread has in flight at the same time. `1` issues requests one at a time. A query running on several threads (at most `max_threads`) can have up to this many requests in flight per thread. Use a [settings profile constraint](/concepts/features/configuration/settings/constraints-on-settings) (`...`) to put a ceiling on it that a query cannot raise. The ceiling is still per thread. A value above `1` loosens two guarantees: - A request's token usage is only known once its response arrives, so the token quotas (`ai_function_max_input_tokens_per_query`, `ai_function_max_output_tokens_per_query`) may overshoot by one request's worth per request in flight - that is, by up to this many requests' worth rather than by one. - A whole wave of requests is dispatched before any of their errors is seen, so a query that fails on its first row may still have issued, and been billed for, up to this many requests. `ai_function_max_api_calls_per_query` is unaffected and stays an exact cap, because a slot is reserved before each request is dispatched. )", BETA, \ {"26.11", 8, 8, "The change was backported to 26.8 and is recorded there."}, \ {"26.8", 1, 8, "New setting"}) \ DECLARE(String, ai_function_text_default_credentials, "", R"( Name of the named collection used by the text AI functions (`aiGenerate`, `aiClassify`, `aiFilter`, `aiExtract`, `aiTranslate`, `aiRedact`) when the call does not pass `credentials` in its parameter map. Empty means no default: such calls must pass `credentials` explicitly. A chat-completions endpoint differs from an embeddings one, so this is separate from `ai_function_embedding_default_credentials`. )", BETA, \ {"26.8", "", "", "New setting"}) \ DECLARE(String, ai_function_embedding_default_credentials, "", R"( Name of the named collection used by the embedding functions (`aiEmbed`, `aiSimilarity`) when the call does not pass `credentials` in its parameter map. Empty means no default: such calls must pass `credentials` explicitly. These functions take `model` as a required positional argument, not from the named collection. Kept separate from `ai_function_text_default_credentials` because an embeddings endpoint differs from a chat one. )", BETA, \ {"26.8", "", "", "New setting"}) \ DECLARE(Bool, ai_function_allow_insecure_endpoint, false, R"( If false (default), AI functions refuse to use a named-collection `endpoint` that would send prompts and API keys over an unencrypted connection to a remote host: any non-HTTPS endpoint whose host is not loopback is rejected with an exception. Loopback endpoints (e.g. a local `http://localhost` model server) are always allowed. Set to true to permit plaintext `http://` endpoints on remote hosts. )", BETA, \ {"26.8", true, false, "AI functions now reject insecure (http) endpoints to remote hosts by default."}) \ \ /* ####################################################### */ \ /* ########### START OF EXPERIMENTAL FEATURES ############ */ \ /* ## ADD PRODUCTION / BETA FEATURES BEFORE THIS BLOCK ## */ \ /* ####################################################### */ \ \ DECLARE_WITH_ALIAS(Bool, enable_materialized_postgresql_table, false, R"( Allows to use the `MaterializedPostgreSQL` table engine. )", EXPERIMENTAL, allow_experimental_materialized_postgresql_table, \ {"26.9", false, false, "Added an alias for setting `allow_experimental_materialized_postgresql_table`."}) \ DECLARE_WITH_ALIAS(Bool, enable_funnel_functions, false, R"( Enable functions for funnel analysis. )", EXPERIMENTAL, allow_experimental_funnel_functions, \ {"26.9", false, false, "Added an alias for setting `allow_experimental_funnel_functions`."}) \ DECLARE(Bool, allow_experimental_nlp_functions, false, R"( Enable experimental functions for natural language processing. )", EXPERIMENTAL) \ DECLARE(Bool, allow_experimental_hash_functions, false, R"( Enable experimental hash functions )", EXPERIMENTAL) \ DECLARE(Bool, enable_ipcrypt, false, R"( Enable experimental IP address encryption functions (`ipcryptEncrypt`, `ipcryptDecrypt`, `ipcryptPrefixEncrypt`, `ipcryptPrefixDecrypt`). )", EXPERIMENTAL, \ {"26.10", false, false, "New setting to enable experimental IP address encryption functions."}) \ DECLARE(Bool, enable_xgboost, false, R"( Enable the experimental XGBoost integration: the `XGBOOST` dictionary layout and the `predictXGBoost` function. )", EXPERIMENTAL, \ {"26.10", false, false, "New setting to gate the experimental XGBoost integration (the `XGBOOST` dictionary layout and the `predictXGBoost` function)."}) \ DECLARE(Bool, enable_elasticsearch, false, R"( Enable the experimental Elasticsearch integration: the `Elasticsearch` table engine and the `elasticsearch` table function. )", EXPERIMENTAL, \ {"26.11", false, false, "New setting to gate the experimental Elasticsearch integration (the `Elasticsearch` table engine and the `elasticsearch` table function)."}) \ DECLARE_WITH_ALIAS(Bool, enable_time_series_table, false, R"( Allows creation of tables with the [TimeSeries](/reference/engines/table-engines/integrations/time-series) table engine. Possible values: - 0 — the [TimeSeries](/reference/engines/table-engines/integrations/time-series) table engine is disabled. - 1 — the [TimeSeries](/reference/engines/table-engines/integrations/time-series) table engine is enabled. )", PRIVATE_PREVIEW, allow_experimental_time_series_table, \ {"26.9", false, false, "The `TimeSeries` table engine and the `promql` dialect were moved to the private preview tier. Added an alias for setting `allow_experimental_time_series_table`."}, \ {"24.8", false, false, "Added new setting to allow the TimeSeries table engine. At the time the setting was named `allow_experimental_time_series_table`, which is now an alias of it."}) \ DECLARE(Bool, time_series_prefer_recent_samples_table, true, R"( Read from the recent samples table of a [TimeSeries](/reference/engines/table-engines/integrations/time-series) table instead of the main samples table when the whole requested time range fits in the TTL window of the recent samples table (see the `recent_samples_ttl_seconds` setting of the TimeSeries table engine). )", PRIVATE_PREVIEW, \ {"26.8", true, true, "New setting to read from the recent samples table of a TimeSeries table when the requested time range fits in its TTL window."}) \ DECLARE(UInt64, unique_key_max_encoded_size, 256, R"( Maximum size (in bytes) of the order-preserving binary encoding of a single `UNIQUE KEY` row. )", EXPERIMENTAL, \ {"26.6", 256, 256, "New setting: maximum size (bytes) of the order-preserving binary encoding of a single UNIQUE KEY row"}) \ DECLARE(UniqueKeyProbeImplementation, unique_key_probe_implementation, UniqueKeyProbeImplementation::Auto, R"( Selects the UNIQUE KEY write-path probe implementation. Currently only a single-threaded baseline exists, so `auto` and `simple` both resolve to it. Reserved: this setting has no effect yet — the value is not read until the UNIQUE KEY INSERT write path that constructs the probe is wired up. Declared now so the lever ships with the implementation. )", EXPERIMENTAL, \ {"26.8", "auto", "auto", "New setting: selects the UNIQUE KEY probe implementation (currently only the simple baseline exists)"}) \ DECLARE_WITH_ALIAS(Bool, enable_unique_key, false, R"( Allows creation of tables with the `UNIQUE KEY` clause on MergeTree-family engines. )", EXPERIMENTAL, allow_experimental_unique_key, \ {"26.9", false, false, "Added an alias for setting `allow_experimental_unique_key`."}, \ {"26.5", false, false, "New setting to gate the experimental UNIQUE KEY clause on MergeTree-family tables. At the time the setting was named `allow_experimental_unique_key`, which is now an alias of it."}) \ DECLARE(Bool, enable_pco_codec, false, R"( Enables the `PCO` compression codec. )", BETA, \ {"26.10", false, false, "New setting to enable the beta `PCO` compression codec."}) \ DECLARE(Bool, enable_quantized_codec, false, R"( Enables the `Quantized` compression codec. )", EXPERIMENTAL, \ {"26.8", false, false, "New setting to enable the experimental `Quantized` compression codec individually, without the `allow_experimental_codecs`."}) \ DECLARE(Bool, enable_sz3_codec, false, R"( Enables the `SZ3` compression codec. )", EXPERIMENTAL, \ {"26.8", false, false, "New setting to enable the experimental `SZ3` compression codec individually, without the `allow_experimental_codecs`."}) \ DECLARE(Bool, enable_gdeflate_codec, false, R"( Enables the `GDeflate` compression codec. )", EXPERIMENTAL, \ {"26.11", false, false, "New setting to enable the experimental `GDeflate` compression codec."}) \ DECLARE(Bool, enable_zxc_codec, false, R"( Enables the `ZXC` compression codec. )", BETA, \ {"26.11", false, false, "The `ZXC` compression codec was moved to Beta."}, \ {"26.8", false, false, "New setting to enable the experimental `ZXC` compression codec individually, without the `allow_experimental_codecs`."}) \ DECLARE(Bool, throw_on_unsupported_query_inside_transaction, true, R"( Throw exception if unsupported query is used inside transaction )", EXPERIMENTAL) \ DECLARE(TransactionsWaitCSNMode, wait_changes_become_visible_after_commit_mode, TransactionsWaitCSNMode::WAIT_UNKNOWN, R"( What `COMMIT` waits for: - `wait_commit`: the commit request. If its outcome is unknown (the Keeper connection was lost), `COMMIT` throws `UNKNOWN_STATUS_OF_TRANSACTION`. - `wait_unknown`: also the outcome of a commit whose status is unknown. - `wait_visible`: also until a new transaction on this replica sees the changes, at most `wait_changes_become_visible_timeout_ms`; then `COMMIT` throws `TIMEOUT_EXCEEDED`, although the transaction is committed. )", EXPERIMENTAL) \ DECLARE(UInt64, wait_changes_become_visible_timeout_ms, 10000, R"( How long `SYSTEM SYNC TRANSACTION LOG`, `BACKUP` of a table with transactions, and `COMMIT` with `wait_changes_become_visible_after_commit_mode = 'wait_visible'` wait until the commits are visible to a new transaction on this replica. On expiry they throw `TIMEOUT_EXCEEDED`. )", EXPERIMENTAL, \ {"26.11", 10000, 10000, "New setting bounding how long `SYSTEM SYNC TRANSACTION LOG`, `BACKUP` and `COMMIT` wait for commits to become visible on this replica."}) \ DECLARE(Bool, implicit_transaction, false, R"( If enabled and not already inside a transaction, wraps the query inside a full transaction (begin + commit or rollback) )", EXPERIMENTAL) \ DECLARE(UInt64, join_to_sort_minimum_perkey_rows, 40, R"( The lower limit of per-key average rows in the right table to determine whether to rerange the right table by key in left or inner join. This setting ensures that the optimization is not applied for sparse table keys )", EXPERIMENTAL, \ {"24.9", 0, 40, "The lower limit of per-key average rows in the right table to determine whether to rerange the right table by key in left or inner join. This setting ensures that the optimization is not applied for sparse table keys"}) \ DECLARE(UInt64, join_to_sort_maximum_table_rows, 10000, R"( The maximum number of rows in the right table to determine whether to rerange the right table by key in left or inner join. )", EXPERIMENTAL, \ {"24.9", 0, 10000, "The maximum number of rows in the right table to determine whether to rerange the right table by key in left or inner join"}) \ DECLARE_WITH_ALIAS(Bool, allow_join_right_table_sorting, false, R"( If it is set to true, and the conditions of `join_to_sort_minimum_perkey_rows` and `join_to_sort_maximum_table_rows` are met, rerange the right table by key to improve the performance in left or inner hash join. This setting is experimental and currently does not work together with all other join optimizations. In particular, when the right table is reranged, the per-key split controlled by `joined_block_split_single_row` is disabled, so neither `max_joined_block_size_rows` nor `max_joined_block_size_bytes` bounds the number of rows produced for a single left row. )", EXPERIMENTAL, allow_experimental_join_right_table_sorting, \ {"26.9", false, false, "Added an alias for setting `allow_experimental_join_right_table_sorting`."}, \ {"24.9", false, false, "If it is set to true, and the conditions of `join_to_sort_minimum_perkey_rows` and `join_to_sort_maximum_table_rows` are met, rerange the right table by key to improve the performance in left or inner hash join. At the time the setting was named `allow_experimental_join_right_table_sorting`, which is now an alias of it."}) \ DECLARE(Bool, allow_metadata_only_named_tuple_alter, false, R"( If true, ALTER MODIFY COLUMN on a named Tuple that only adds new subfields is metadata-only (no data mutation). Set to false to force the old full-mutation behavior. )", 0, \ {"26.8", false, false, "New setting to control metadata-only ALTER for named Tuple subfield additions."}) \ DECLARE(Bool, allow_experimental_shuffle_query, false, R"( Allow the experimental `SHUFFLE` clause in `SELECT` queries. `SHUFFLE` is used in place of `ORDER BY` and returns the rows in a uniformly random order. )", EXPERIMENTAL, \ {"26.11", false, false, "New setting to enable the experimental `SHUFFLE` clause in `SELECT` queries."}) \ DECLARE(Bool, enable_streaming_queries, false, R"( Allow `SELECT ... FROM t STREAM [CURSOR '{...}']` continuous queries. When off, any table expression using the `STREAM` modifier is rejected at plan-build time. This is the umbrella gate for the streaming-queries feature; additional capabilities may be gated by their own settings. )", EXPERIMENTAL, \ {"26.6", false, false, "New setting"}) \ \ DECLARE_WITH_ALIAS(Bool, allow_statistics_optimize, true, R"( Allows using statistics to optimize queries )", 0, allow_statistic_optimize, \ {"25.12", false, true, "Enable this optimization by default. This also applies to the alias `allow_statistic_optimize`."}, \ {"24.6", false, false, "The setting was renamed. The previous name is `allow_statistic_optimize`."}) \ DECLARE_WITH_ALIAS(Bool, use_statistics, true, R"( /// preferred over 'allow_statistics_optimize' because of consistency with 'use_primary_key' and 'use_skip_indexes' Allows using statistics to optimize queries )", 0, allow_statistic_optimize, \ {"26.1", true, true, "Enable this optimization by default."}) \ DECLARE_WITH_ALIAS(Bool, allow_statistics, true, R"( Allows defining columns with [statistics](/reference/engines/table-engines/mergetree-family/mergetree#table_engine-mergetree-creating-a-table) and [manipulate statistics](/reference/engines/table-engines/mergetree-family/mergetree#column-statistics). )", 0, allow_experimental_statistics, \ {"26.3", false, true, "Column statistics are now GA. This also applies to the alias `allow_experimental_statistics`."}, \ {"24.6", false, false, "The setting was renamed. The previous name is `allow_experimental_statistic`. At the time the setting was named `allow_experimental_statistics`, which is now an alias of it."}) \ \ DECLARE_WITH_ALIAS(Bool, enable_full_text_index, true, R"( If set to true, allow using the text index. )", 0, allow_experimental_full_text_index, \ {"26.2", true, true, "The text index is now GA. This also applies to the alias `allow_experimental_full_text_index`."}, \ {"25.12", true, false, "Text index was moved to Beta."}, \ {"24.6", true, false, "Enable experimental text index. At the time the setting was named `allow_experimental_full_text_index`, which is now an alias of it."}) \ DECLARE(Bool, query_plan_direct_read_from_text_index, true, R"( Allow to perform full text search filtering using only the inverted text index in query plan. )", 0, \ {"26.2", true, true, "The text index is now GA"}, \ {"25.9", true, true, "New setting."}) \ DECLARE(Bool, query_plan_optimize_count_from_text_index, true, R"( Allow to answer `SELECT count() ... WHERE ` directly from the text index posting-list cardinalities, without materializing the matching rows. Only takes effect when `query_plan_direct_read_from_text_index` is enabled. )", 0, \ {"26.8", false, true, "New setting"}) \ DECLARE(Bool, query_plan_text_index_add_hint, true, R"( Allow to add hint (additional predicate) for filtering built from the inverted text index in query plan. )", 0, \ {"25.12", true, true, "New setting"}) \ DECLARE(Float, text_index_hint_max_selectivity, 0.2f, R"( Maximal selectivity of the filter to use the hint built from the inverted text index. )", 0, \ {"25.12", 0.2, 0.2, "New setting"}) \ DECLARE(Bool, use_text_index_like_evaluation_by_dictionary_scan, true, R"( Enable evaluation of LIKE/ILIKE queries by scanning the inverted text index dictionary. The accelerated patterns are `%value%`, `value%` and `%value`, as well as the `startsWith` and `endsWith` calls that `optimize_rewrite_like_perfect_affix` rewrites into `value%` and `%value`. A `multiSearchAny`, `multiSearchAnyUTF8`, `multiSearchAnyCaseInsensitive` or `multiSearchAnyCaseInsensitiveUTF8` call with one needle is searched as `%value%`. )", 0, \ {"26.4", true, true, "New setting"}) \ DECLARE(UInt64, text_index_like_min_pattern_length, 4, R"( Minimum length of the alphanumeric needle in a LIKE/ILIKE pattern, or of a `startsWith`/`endsWith` needle, required to use the text index LIKE evaluation by the dictionary scan. Patterns shorter than this threshold match too many dictionary tokens and are skipped to avoid expensive scans. With the `array` tokenizer, where any pattern qualifies, the threshold is compared against the number of non-wildcard characters in the whole pattern. Requires [use_text_index_like_evaluation_by_dictionary_scan](/reference/settings/session-settings/use-text#use_text_index_like_evaluation_by_dictionary_scan) to be enabled. )", 0, \ {"26.4", 4, 4, "New setting"}) \ DECLARE(UInt64, text_index_like_max_postings_to_read, 50, R"( Maximum number of large postings to read when text index LIKE evaluation by the dictionary scan is enabled. Requires [use_text_index_like_evaluation_by_dictionary_scan](/reference/settings/session-settings/use-text#use_text_index_like_evaluation_by_dictionary_scan) to be enabled. )", 0, \ {"26.4", 50, 50, "New setting"}) \ DECLARE(Bool, use_text_index_tokens_cache, true, R"( Whether to cache deserialized text index token infos in memory. Using the text index tokens cache can significantly reduce latency and increase throughput when working with a large number of text index queries. )", 0, \ {"26.7", false, true, "Enabled the text index tokens cache globally."}, \ {"26.3", false, false, "New setting"}) \ DECLARE(Bool, use_text_index_negative_tokens_cache, true, R"( Whether to cache text index tokens that are absent from a data part. The negative tokens cache uses the text index tokens cache and avoids repeated dictionary lookups for absent tokens. )", 0, \ {"26.8", false, true, "New setting to cache absent text index tokens and avoid repeated dictionary lookups."}) \ DECLARE(Bool, use_text_index_pattern_bypass_cache, true, R"( Whether to cache text index pattern dictionary scans that exceed `text_index_like_max_postings_to_read`. The pattern bypass cache uses the text index tokens cache and avoids repeating dictionary scans that previously fell back to evaluating the original predicate. )", 0, \ {"26.10", false, true, "New setting to cache text index pattern dictionary scans that exceeded the posting-list threshold."}) \ DECLARE(Bool, use_text_index_header_cache, true, R"( Whether to cache deserialized text index headers in memory. Using the text index header cache can significantly reduce latency and increase throughput when working with a large number of text index queries. )", 0, \ {"26.7", false, true, "Enabled the text index header cache globally."}, \ {"25.11", false, false, "New setting"}) \ DECLARE(Bool, use_text_index_postings_cache, true, R"( Whether to cache deserialized text index posting lists in memory. Using the text index postings cache can significantly reduce latency and increase throughput when working with a large number of text index queries. )", 0, \ {"26.10", true, true, "The change was backported to 26.9 and is recorded there."}, \ {"26.9", false, true, "Enabled the text index posting lists cache globally. Previously each query used a small private cache, which caused posting lists and phrase search results to be recomputed within a single query on large tables."}, \ {"25.11", false, false, "New setting"}) \ DECLARE(Bool, use_page_cache_lookahead_for_text_index, false, R"( Text index files that are read out of file order (dictionary, postings, positions) are, by default, read through the userspace page cache with a lookahead of one block, so that the remote connection can be reused after each read. Enable this setting to make those files use `page_cache_lookahead_blocks` like other files instead. )", 0, \ {"26.11", false, false, "New setting"}) \ DECLARE(TextIndexPostingListApplyMode, text_index_posting_list_apply_mode, TextIndexPostingListApplyMode::Lazy, R"( Controls how posting lists are applied during text index queries. 'materialize' eagerly decodes posting lists into Roaring Bitmaps. 'lazy' (default) uses cursor-based on-demand decoding (requires an index format with a serialized codec). 'lazy' is applied only where it is supported: queries with patterns (such as `LIKE`) and parts with an index written by an older version fall back to 'materialize'. )", 0, \ {"26.8", "materialize", "lazy", "Text index queries now decode posting lists on demand with a cursor instead of materializing them into Roaring Bitmaps, which reduces memory usage and CPU time for selective queries."}, \ {"26.6", "materialize", "materialize", "New setting for lazy posting list apply mode"}) \ DECLARE(TextIndexPostingsIntersectionAlgorithm, text_index_postings_intersection_algorithm, TextIndexPostingsIntersectionAlgorithm::Auto, R"( Selects the algorithm that intersects posting lists in lazy posting list apply mode (`text_index_posting_list_apply_mode = 'lazy'`). - `auto` (default): leapfrog is used only when the sparsest posting list can skip whole packed blocks of the densest one, and brute-force bitmap intersection otherwise. - `bruteforce`: always use the brute-force bitmap intersection. - `leapfrog`: always use the leapfrog intersection. Intersections of 256 or more tokens always use leapfrog. )", 0, \ {"26.10", "auto", "auto", "New setting superseding `text_index_lazy_intersection_density_threshold`: selects the posting list intersection algorithm in lazy posting list apply mode. `auto` keeps the previous default behavior, so `compatibility` must not change it."}) \ DECLARE(Bool, stop_refreshable_materialized_views_on_startup, false, R"( On server startup, prevent scheduling of refreshable materialized views, as if with SYSTEM STOP VIEWS. You can manually start them with `SYSTEM START VIEWS` or `SYSTEM START VIEW ` afterwards. Also applies to newly created views. Has no effect on non-refreshable materialized views. )", EXPERIMENTAL) \ \ DECLARE_WITH_ALIAS(Bool, enable_database_materialized_postgresql, false, R"( Allow to create databases with `Engine = MaterializedPostgreSQL(...)`. )", EXPERIMENTAL, allow_experimental_database_materialized_postgresql, \ {"26.11", false, false, "Added an alias for setting `allow_experimental_database_materialized_postgresql`."}) \ \ DECLARE(Bool, allow_nullable_tuple_in_extracted_subcolumns, true, R"( Controls whether extracted subcolumns of type `Tuple(...)` can be typed as `Nullable(Tuple(...))`. - `false`: Return `Tuple(...)` and use default tuple values for rows where the subcolumn is missing. - `true`: Return `Nullable(Tuple(...))` and use `NULL` for rows where the subcolumn is missing. This setting controls extracted subcolumn behavior only. It does not control whether `Nullable(Tuple(...))` columns can be created in tables; that is controlled by `enable_nullable_tuple_type`. ClickHouse uses the value for this setting loaded at server startup. Changes made with `SET` or query-level `SETTINGS` do not change extracted subcolumn behavior. To change extracted subcolumn behavior, update `allow_nullable_tuple_in_extracted_subcolumns` in startup profile configuration (for example, users.xml) and restart the server. )", 0, \ {"26.9", false, true, "`Nullable(Tuple)` is now GA: a `Tuple` subcolumn extracted from a `Tuple`, `Variant`, `Dynamic` or `JSON` column is `Nullable(Tuple)` and is NULL in the rows where the subcolumn is missing. The setting is read once at server startup, so `compatibility` restores the previous behavior only from the startup profile (for example, users.xml), not from a session-level `SET`."}, \ {"26.3", false, false, "New setting controlling whether extracted Tuple subcolumns can be nullable."}) \ \ DECLARE_WITH_ALIAS(Bool, enable_database_hms_catalog, false, R"( Allow database engine `DataLakeCatalog` with `catalog_type = 'hms'` )", EXPERIMENTAL, allow_experimental_database_hms_catalog, \ {"26.11", false, false, "Added an alias for setting `allow_experimental_database_hms_catalog`."}, \ {"25.5", false, false, "Allow experimental database engine DataLakeCatalog with catalog_type = 'hive'"}) \ DECLARE_WITH_ALIAS(Bool, enable_kusto_dialect, false, R"( Enable the Kusto Query Language (KQL) dialect - an alternative to SQL. )", BETA, allow_experimental_kusto_dialect, \ {"26.11", false, false, "Added an alias for setting `allow_experimental_kusto_dialect`."}, \ {"26.10", false, false, "The Kusto Query Language (KQL) dialect was moved to Beta."}, \ {"25.1", true, false, "A new setting"}) \ DECLARE_WITH_ALIAS(Bool, enable_prql_dialect, false, R"( Enable PRQL - an alternative to SQL. )", EXPERIMENTAL, allow_experimental_prql_dialect, \ {"26.11", false, false, "Added an alias for setting `allow_experimental_prql_dialect`."}, \ {"25.1", true, false, "A new setting"}) \ DECLARE_WITH_ALIAS(Bool, enable_polyglot_dialect, false, R"( Enable polyglot SQL transpiler - transpiles SQL from 30+ dialects (MySQL, PostgreSQL, SQLite, Snowflake, DuckDB, etc.) into ClickHouse SQL. )", EXPERIMENTAL, allow_experimental_polyglot_dialect, \ {"26.11", false, false, "Added an alias for setting `allow_experimental_polyglot_dialect`."}, \ {"26.3", false, false, "New setting to enable the polyglot SQL transpiler dialect."}) \ DECLARE(Bool, enable_json_ast_dialect, false, R"( Enable the `clickhouse_json` value of the `dialect` setting. When `dialect` is set to `clickhouse_json`, queries are interpreted as JSON ASTs (the output of `parseQueryToJSON`) instead of SQL text. The `SET` query is still parsed as plain SQL so that the dialect can be switched back. Example: ```sql SET enable_json_ast_dialect = 1; SET dialect = 'clickhouse_json'; -- Subsequent queries are parsed as JSON ASTs: {"type":"SelectWithUnionQuery", ...} ``` )", EXPERIMENTAL, \ {"26.8", false, false, "New setting to enable the `clickhouse_json` value of the `dialect` setting, which interprets queries as JSON ASTs (the output of `parseQueryToJSON`) instead of SQL text."}) \ DECLARE(String, polyglot_dialect, "", R"( Source SQL dialect for the polyglot transpiler (e.g. 'sqlite', 'mysql', 'postgresql', 'snowflake', 'duckdb'). )", EXPERIMENTAL, \ {"26.3", "", "", "New setting to specify the source SQL dialect for the polyglot transpiler."}) \ DECLARE(Bool, enable_logsql_dialect, false, R"( Enable LogsQL - the log query language of VictoriaLogs. Queries in this dialect are translated into SELECT queries over the table specified by the `logsql_table` setting. Usage: ```sql SET enable_logsql_dialect = 1; SET logsql_table = 'logs'; SET dialect = 'logsql'; _time:1h error | stats by (host) count() ``` A complete standalone `SET` query is still parsed as plain SQL so that the dialect can be switched back; a LogsQL query merely starting with the word `set` keeps its meaning. The `logsql_time_column` and `logsql_message_column` settings configure the columns referred to by the `_time` field and by the default (message) field. Unlike VictoriaLogs, which stores every field as a string, the translated queries run over the existing table schema. The key contract deviations that follow from this: - Text filters (words, phrases, prefixes, regexps) expect `String`-backed columns and do not convert numeric columns to text. - Numeric comparison filters compare numeric columns natively (exactly for integer and decimal values, as long as the compared literal fits `Int128` or `Decimal256(38)`; a wider value, e.g. an integer above 1e38 in a `UInt256` field, is compared with `Float64` precision, and so are the integral bucket steps of `stats by (:)`). For `String` columns, only plain numeric text is parsed per row; values in the LogsQL number grammar (e.g. `10KiB`, `1h30m`) are not parsed per row. - The numeric stats functions (`sum`, `avg`, `median`, `quantile`, `stddev`, `rate_sum`) parse the numeric value of every field, skipping the values that are not numbers, like VictoriaLogs. The values are `Float64`, so a numeric column is aggregated with `Float64` precision and not exactly. - The `math` pipe requires numeric operand columns; `String` columns are not coerced. - Query results are returned with the types of the underlying columns, not as strings. )", EXPERIMENTAL, \ {"26.10", false, false, "New setting to enable the LogsQL dialect (the log query language of VictoriaLogs)."}) \ DECLARE(String, logsql_database, "", R"( Specifies the database with the logs table used by the 'logsql' dialect. Empty string means the current database. )", EXPERIMENTAL, \ {"26.10", "", "", "New setting to specify the database with the logs table used by the 'logsql' dialect."}) \ DECLARE(String, logsql_table, "", R"( Specifies the name of the logs table used by the 'logsql' dialect. )", EXPERIMENTAL, \ {"26.10", "", "", "New setting to specify the logs table used by the 'logsql' dialect."}) \ DECLARE(String, logsql_time_column, "_time", R"( Specifies the name of the column referred to by the `_time` field in the 'logsql' dialect. )", EXPERIMENTAL, \ {"26.10", "_time", "_time", "New setting to specify the column referred to by the `_time` field in the 'logsql' dialect."}) \ DECLARE(String, logsql_message_column, "_msg", R"( Specifies the name of the column referred to by the `_msg` field (the default field of LogsQL filters) in the 'logsql' dialect. )", EXPERIMENTAL, \ {"26.10", "_msg", "_msg", "New setting to specify the column referred to by the `_msg` field in the 'logsql' dialect."}) \ DECLARE(Bool, enable_trino_dialect, false, R"( Enable the `trino` value of the `dialect` setting. When `dialect` is set to `trino`, queries are written in Trino SQL: Trino-specific syntax (`ARRAY[...]` literals, `TRY_CAST`, `UNNEST`, `ROW` types, `OFFSET` before `LIMIT`) is translated to ClickHouse SQL, and Trino function names are mapped to their ClickHouse equivalents. The `SET` query is still parsed as plain SQL so that the dialect can be switched back. The dialect also aligns the query semantics with Trino: `join_use_nulls` is turned on, `use_variant_as_common_type` is turned off, and the query analyzer is turned on. An explicit `SETTINGS` clause in the query still takes precedence. )", BETA, \ {"26.10", false, false, "The `trino` dialect was moved to Beta."}, \ {"26.9", false, false, "New setting to enable the `trino` value of the `dialect` setting, which translates Trino SQL syntax and maps Trino function names to ClickHouse equivalents."}) \ DECLARE(Bool, enable_adaptive_memory_spill_scheduler, false, R"( Adaptively spill eligible aggregation, sorting, `DISTINCT`, and hash-join processors to external storage under query memory pressure. Supported hash joins include `grace_hash` and the adaptive `hash` / `parallel_hash` path. )", EXPERIMENTAL, \ {"25.2", false, false, "New setting. Enable spill memory data into external storage adaptively."}) \ DECLARE(Bool, allow_delta_lake_create_table, false, R"( Allow creating a new DeltaLake table using delta-kernel-rs or registering an existing one into a catalog. Creating a partitioned table (`PARTITION BY`) is not supported yet. In a `DataLakeCatalog` database the table is registered with its Delta schema, so declared ClickHouse types that map to a wider Delta type (e.g. `UInt8` -> `short`, `FixedString(N)` -> `string`) are read back as the Delta-mapped type rather than the declared one. )", EXPERIMENTAL, \ {"26.9", false, false, "New setting: allow creating a new DeltaLake table using delta-kernel-rs or registering an existing one into a catalog."}) \ DECLARE_WITH_ALIAS(Bool, allow_insert_into_iceberg, false, R"( Allow to execute `insert` queries into iceberg. )", BETA, allow_experimental_insert_into_iceberg, \ {"26.2", false, false, "Insert into iceberg was moved to Beta. This also applies to the alias `allow_experimental_insert_into_iceberg`."}, \ {"25.7", false, false, "New setting."}) \ DECLARE_WITH_ALIAS(Bool, enable_cleanup_old_data_files_compaction, false, R"( Allow to clean up old data files of Iceberg tables with background compaction. A background task of the table expires the snapshots that a newer one replaced longer than `iceberg_compaction_data_cleanup` ago, except those that branches and tags reference, the same way as `expire_snapshots`: removes them from the table metadata and deletes the files that no other snapshot references. It also drops the metadata files replaced as long ago from the metadata log and deletes them, unless a transactional catalog writes the metadata of the table. The snapshots that a query on any replica is reading stay until a later run. Does nothing for a table of the format version 1. )", EXPERIMENTAL, allow_experimental_cleanup_old_data_files_compaction, \ {"26.11", false, false, "Added an alias for setting `allow_experimental_cleanup_old_data_files_compaction`."}, \ {"26.5", false, false, "New setting"}) \ DECLARE(Bool, allow_experimental_iceberg_compaction, false, R"( Allow to explicitly use 'OPTIMIZE' for iceberg tables. )", EXPERIMENTAL, \ {"25.8", 0, 0, "New setting"}) \ DECLARE(UInt64, iceberg_manifest_min_count_to_compact, 100, R"( Minimum number of manifest files required to trigger manifest-only compaction via OPTIMIZE TABLE ... MANIFEST. If the current number of manifest files is less than or equal to this threshold, compaction is skipped. Requires allow_experimental_iceberg_compaction to be enabled. The default mirrors the documented default of the Iceberg table property `commit.manifest.min-count-to-merge` (100), see https://iceberg.apache.org/docs/1.5.2/configuration/. )", EXPERIMENTAL, \ {"26.9", 30, 100, "Aligned with the documented default of the Iceberg table property `commit.manifest.min-count-to-merge` (100), see https://iceberg.apache.org/docs/1.5.2/configuration/."}, \ {"26.7", 30, 30, "New setting to control manifest compaction for Iceberg tables."}) \ DECLARE(Bool, allow_iceberg_remove_orphan_files, false, R"( Allow to use 'ALTER TABLE ... EXECUTE remove_orphan_files()' for iceberg tables. )", EXPERIMENTAL, \ {"26.4", false, false, "New setting to gate Iceberg orphan file removal"}) \ DECLARE(UInt64, iceberg_orphan_files_older_than_seconds, 259200, R"( Default age threshold in seconds for orphan file removal in Iceberg tables. Files newer than this are not considered orphans. Used when the older_than argument is omitted from the remove_orphan_files() procedure call. Default is 259200 (3 days). )", EXPERIMENTAL, \ {"26.4", 259200, 259200, "New setting for default orphan file age threshold"}) \ DECLARE(UInt64, iceberg_orphan_files_min_retention_seconds, 86400, R"( Minimum age in seconds of the files that `ALTER TABLE ... EXECUTE remove_orphan_files` may delete from an Iceberg table. An `older_than` (given explicitly or derived from `iceberg_orphan_files_older_than_seconds`) that is closer to now than this is rejected: files of a write that has not committed yet are not referenced by the table metadata and would be deleted, which corrupts the table when the write commits. Keep it above the longest time a write to the table can take to commit. 0 disables the check. )", EXPERIMENTAL, \ {"26.10", 0, 86400, "New setting. `remove_orphan_files` rejects an `older_than` less than this many seconds before now, so it keeps the files of a write that started less than this long ago and has not committed yet. `compatibility` with versions before 26.10 restores the previous behavior (no minimum)."}) \ DECLARE_WITH_ALIAS(Bool, allow_expire_snapshots, false, R"( Allow to execute the Iceberg command `ALTER TABLE ... EXECUTE expire_snapshots`. )", EXPERIMENTAL, allow_experimental_expire_snapshots, \ {"26.11", false, false, "Added an alias for setting `allow_experimental_expire_snapshots`."}, \ {"26.3", false, false, "New setting."}) \ DECLARE(Bool, write_full_path_in_iceberg_metadata, false, R"( Write full paths (including s3://) into iceberg metadata files. Tables created in a `DataLakeCatalog` database always get full paths. )", EXPERIMENTAL, \ {"25.8", false, false, "New setting."}) \ DECLARE(String, iceberg_metadata_compression_method, "", R"( Method to compress `.metadata.json` file. An empty string lets the catalog choose the codec when it writes the first metadata file. Set `none` to request uncompressed metadata. )", EXPERIMENTAL, \ {"25.8", "", "", "New setting"}) \ DECLARE(Bool, make_distributed_plan, false, R"( Make distributed query plan. Enabling it automatically adjusts settings that control features not supported by distributed query plans yet: - `enable_parallel_replicas = 0` and `automatic_parallel_replicas_mode = 0` — the distributed plan does its own work distribution; - `correlated_subqueries_use_in_memory_buffer = 0`; - `compile_expressions = 0`; - `query_plan_direct_read_from_text_index = 0`. )", PRIVATE_PREVIEW, \ {"25.5", 0, 0, "New experimental setting."}) \ DECLARE(Bool, distributed_plan_fallback_to_local_execution, true, R"( When a query plan contains a step that does not support distributed execution, log the reason and execute the query on the initiator instead of throwing an exception. Disable to get an exception instead. Only takes effect when `make_distributed_plan` (private preview) is enabled. )", 0, \ {"26.9", false, true, "New setting to fall back to local execution when a plan cannot be distributed (only takes effect under `make_distributed_plan`)."}) \ DECLARE(Bool, distributed_plan_execute_locally, false, R"( Run all tasks of a distributed query plan locally. Useful for testing and debugging. )", EXPERIMENTAL, \ {"25.5", 0, 0, "New experimental setting."}) \ DECLARE(NonZeroUInt64, distributed_plan_default_shuffle_join_bucket_count, 8, R"( Default number of buckets for distributed shuffle-hash-join. Used by the rule-based distributed planner. The cost-based optimizer chooses the fan-out by estimated cost and does not use this setting. )", EXPERIMENTAL, \ {"25.5", 8, 8, "New experimental setting."}) \ DECLARE(UInt64, distributed_plan_default_reader_bucket_count, 0, R"( Number of tasks for parallel reading in distributed query. Tasks are spread across workers. `0` chooses the number automatically: one task per `distributed_plan_min_rows_per_reader` rows selected by the read, at least one, and at most the number of workers. Used by the rule-based distributed planner. The cost-based optimizer chooses the read fan-out by estimated cost and does not use this setting. )", EXPERIMENTAL, \ {"26.11", 8, 0, "Choose the number of read tasks from the rows to read and the number of workers by default."}, \ {"25.5", 8, 8, "New experimental setting."}) \ DECLARE(NonZeroUInt64, distributed_plan_min_rows_per_reader, 1000000, R"( Minimum number of rows for each read task when `distributed_plan_default_reader_bucket_count` is `0`. Used by the rule-based distributed planner. )", EXPERIMENTAL, \ {"26.11", 1000000, 1000000, "New experimental setting."}) \ DECLARE(Bool, distributed_plan_optimize_exchanges, true, R"( Removes unnecessary exchanges in distributed query plan. Disable it for debugging. )", 0, \ {"25.5", true, true, "New experimental setting."}) \ DECLARE(UInt64, distributed_plan_workers_num, 0, R"( How many stateless workers will be used to execute this query. Zero disables stateless-worker leasing for distributed plans. )", PRIVATE_PREVIEW, \ {"26.6", 0, 0, "New experimental setting for how many stateless workers to lease for a distributed query. Zero disables leasing."}) \ DECLARE(UInt64, distributed_plan_workers_provisioning_timeout_ms, 10000, R"( Total wall-clock time, in milliseconds, a query may spend provisioning stateless workers before execution: leasing them from the discovery service and verifying they are reachable. The query blocks up to this budget for the leased workers to become ready; when it elapses the query proceeds with the workers verified so far, or fails if none became available. Zero waits only for the initial lease-and-verify pass (no retries). )", PRIVATE_PREVIEW, \ {"26.8", 0, 10000, "New setting bounding how long a query waits for leased stateless workers to become reachable before execution; `compatibility` below 26.8 restores the previous no-wait behavior."}) \ DECLARE(String, distributed_plan_force_exchange_kind, "", R"( Force specified kind of Exchange operators between distributed query stages. Possible values: - '' - do not force any kind of Exchange operators, let the optimizer choose, - 'Persisted' - use temporary files in object storage, - 'Streaming' - stream exchange data over network. )", EXPERIMENTAL, \ {"25.5", "", "", "New experimental setting."}) \ DECLARE(String, distributed_plan_exchange_compression_method, "LZ4", R"( The codec for compressing the packets of the streaming exchange between the tasks of a distributed query plan. Exchanges through temporary files use the default codec of the server. Possible values: - `''` — use the codec of [network_compression_method](#network_compression_method). - `NONE` — no compression. - `LZ4` — use the LZ4 codec. - `LZ4HC` — use the LZ4HC codec at its default level 9. It compresses many times slower than `LZ4`. - `ZSTD` — use the ZSTD codec with the level of [distributed_plan_exchange_zstd_compression_level](#distributed_plan_exchange_zstd_compression_level). )", EXPERIMENTAL, \ {"26.11", "", "LZ4", "New setting: the streaming exchange of a distributed query plan compresses with `LZ4` instead of the codec of `network_compression_method`."}) \ DECLARE(Int64, distributed_plan_exchange_zstd_compression_level, 1, R"( The level of ZSTD compression of the streaming exchange of a distributed query plan. Used only when [distributed_plan_exchange_compression_method](#distributed_plan_exchange_compression_method) is set to `ZSTD`. Possible values: - Integer from 1 to 22. Higher levels compress better and slower. )", EXPERIMENTAL, \ {"26.11", 1, 1, "New setting for the level of ZSTD compression of the streaming exchange of a distributed query plan."}) \ DECLARE(UInt64, distributed_plan_max_rows_to_broadcast, 20000, R"( Maximum rows to use broadcast join instead of shuffle join in distributed query plan. A heuristic for the rule-based distributed planner. When the cost-based optimizer is enabled, the broadcast-vs-shuffle choice is made by estimated cost and this setting has no effect. )", EXPERIMENTAL, \ {"25.7", 20000, 20000, "New experimental setting."}) \ DECLARE(Bool, distributed_plan_read_in_order, false, R"( Allow the read-in-order optimization for `ORDER BY` in a distributed query plan, so a sorted read of the table's sorting key can skip the sort and stop early instead of scanning and sorting. Off by default: the rewrite that distributes a sort assumes the sort it wraps does not depend on its input already being ordered, and a sort that does can be fed rows through an exchange that does not preserve order. Only shapes where no exchange survives between the read and the sort are safe today. )", EXPERIMENTAL, \ {"26.9", false, false, "New setting to allow the read-in-order optimization for `ORDER BY` in a distributed query plan, so a sorted read of the table's sorting key can skip the sort and stop early. Off by default: only shapes where no exchange survives between the read and the sort are safe today."}) \ DECLARE(Bool, distributed_plan_prefer_replicas_over_workers, false, R"( Serialize the distributed query plan for execution at replicas. )", PRIVATE_PREVIEW, \ {"26.4", false, false, "New setting to serialize distributed plan for replicas"}) \ DECLARE(String, distributed_plan_worker_cluster, "", R"( Name of the stateless-worker cluster to execute this query's distributed plan on. The empty default selects the pre-configured default cluster; other clusters are configured under `stateless_worker_client.clusters`. )", PRIVATE_PREVIEW, \ {"26.11", "", "", "New setting to select the stateless worker cluster for distributed plan execution."}) \ DECLARE(Bool, distributed_plan_join_runtime_filters, false, R"( With `make_distributed_plan`, send join runtime filters built in one stage to the stages that read the probe side, so those stages filter rows before sending them. If a filter does not arrive, rows pass unfiltered. Requires `enable_join_runtime_filters`. )", EXPERIMENTAL, \ {"26.10", false, false, "New experimental setting."}) \ DECLARE(UInt64, distributed_plan_max_buffered_log_rows, 100000, R"( When `send_logs_level` forwards stateless-worker task logs to the coordinator, each worker task buffers at most this many log lines between status polls. Lines beyond the bound are dropped and their count is reported to the client. `0` means unbounded (never drops, but a stalled status poll can grow the buffer without limit). )", EXPERIMENTAL, \ {"26.10", 100000, 100000, "New setting bounding how many log lines a stateless-worker task buffers for forwarding to the coordinator between status polls; excess lines are dropped and counted. New feature, so the previous value equals the default."}) \ DECLARE_WITH_ALIAS(Bool, enable_ytsaurus_table_engine, false, R"( Enable the `YTsaurus` table engine for integration with YTsaurus. )", EXPERIMENTAL, allow_experimental_ytsaurus_table_engine, \ {"26.11", false, false, "Added an alias for setting `allow_experimental_ytsaurus_table_engine`."}, \ {"25.8", false, false, "New setting."}) \ DECLARE_WITH_ALIAS(Bool, enable_ytsaurus_table_function, false, R"( Enable the `ytsaurus` table function for integration with YTsaurus. )", EXPERIMENTAL, allow_experimental_ytsaurus_table_function, \ {"26.11", false, false, "Added an alias for setting `allow_experimental_ytsaurus_table_function`."}, \ {"25.8", false, false, "New setting."}) \ DECLARE_WITH_ALIAS(Bool, enable_ytsaurus_dictionary_source, false, R"( Enable the `ytsaurus` dictionary source for integration with YTsaurus. )", EXPERIMENTAL, allow_experimental_ytsaurus_dictionary_source, \ {"26.11", false, false, "Added an alias for setting `allow_experimental_ytsaurus_dictionary_source`."}, \ {"25.8", false, false, "New setting."}) \ DECLARE(Bool, distributed_plan_force_shuffle_aggregation, false, R"( Use Shuffle aggregation strategy instead of PartialAggregation + Merge in distributed query plan. Ignored where the Shuffle strategy cannot produce a correct result, for example for `GROUPING SETS` or when the aggregation must produce results in bucket order. )", EXPERIMENTAL, \ {"25.7", 0, 0, "New experimental setting"}) \ DECLARE(Bool, distributed_plan_partial_aggregation_before_shuffle, true, R"( Aggregate partially on the nodes that read the data before a distributed aggregation shuffles it by the `GROUP BY` keys, so the shuffle sends one aggregation state per group from each node instead of every input row, and each bucket merges the states of its own keys. The rule-based planner keeps shuffling the input rows when column statistics show that partial aggregation would not reduce the data at least twofold. With `enable_cascades_optimizer`, the setting allows the optimizer to choose such a merge per bucket by cost. Takes effect only together with `make_distributed_plan = 1`, and not with `distributed_plan_force_shuffle_aggregation`, which shuffles the input rows. )", BETA, \ {"26.11", false, true, "New experimental setting: a distributed aggregation shuffles partial aggregation states instead of input rows."}) \ DECLARE(Bool, enable_cascades_optimizer, false, R"( Enable the Cascades cost-based optimizer for distributed query plans. Takes effect only together with `make_distributed_plan = 1`: the setting alone does not change single-node query planning. )", EXPERIMENTAL, \ {"26.8", false, false, "New experimental setting."}) \ DECLARE(Bool, cascades_aggregation_pushdown, true, R"( Consider pushing partial aggregation below a join (eager aggregation) as a cost-based alternative in the Cascades optimizer. Takes effect only together with `enable_cascades_optimizer = 1` and `make_distributed_plan = 1`. )", BETA, \ {"26.9", false, true, "New setting to consider pushing partial aggregation below a join (eager aggregation) in the Cascades optimizer."}) \ DECLARE(Bool, enable_join_runtime_filters, true, R"( Filter left side by set of JOIN keys collected from the right side at runtime. )", 0, \ {"26.9", true, true, "The JOIN runtime filters became a Production tier feature."}, \ {"26.2", false, true, "Enabled this optimization"}, \ {"25.10", false, false, "New setting"}) \ DECLARE(UInt64, join_runtime_filter_exact_values_limit, 10000, R"( Maximum number of elements in runtime filter that are stored as is in a set. When this threshold is exceeded, it switches to a dense bitset for (U)Int8 and (U)Int16 keys, and to a bloom filter otherwise. )", 0, \ {"26.9", 10000, 10000, "The JOIN runtime filters became a Production tier feature."}, \ {"25.10", 10000, 10000, "New setting"}) \ DECLARE(UInt64, join_runtime_bloom_filter_bytes, 512_KiB, R"( Size in bytes of a bloom filter used as JOIN runtime filter (see enable_join_runtime_filters setting). )", 0, \ {"26.9", 512_KiB, 512_KiB, "The JOIN runtime filters became a Production tier feature."}, \ {"25.10", 512_KiB, 512_KiB, "New setting"}) \ DECLARE(UInt64, join_runtime_bloom_filter_hash_functions, 3, R"( Number of hash functions in a bloom filter used as JOIN runtime filter (see enable_join_runtime_filters setting). )", 0, \ {"26.9", 3, 3, "The JOIN runtime filters became a Production tier feature."}, \ {"25.10", 3, 3, "New setting"}) \ DECLARE(Double, join_runtime_filter_pass_ratio_threshold_for_disabling, 0.7, R"( If ratio of passed rows to checked rows is greater than this threshold the runtime filter is considered as poorly performing and is disabled for the next `join_runtime_filter_blocks_to_skip_before_reenabling` blocks to reduce the overhead. )", 0, \ {"26.9", 0.7, 0.7, "The JOIN runtime filters became a Production tier feature."}, \ {"26.1", 0.7, 0.7, "New setting"}) \ DECLARE(UInt64, join_runtime_filter_blocks_to_skip_before_reenabling, 30, R"( Number of blocks that are skipped before trying to dynamically re-enable a runtime filter that previously was disabled due to poor filtering ratio. )", 0, \ {"26.9", 30, 30, "The JOIN runtime filters became a Production tier feature."}, \ {"26.1", 30, 30, "New setting"}) \ DECLARE(Double, join_runtime_bloom_filter_max_ratio_of_set_bits, 0.7, R"( If the number of set bits in a runtime bloom filter exceeds this ratio the filter is completely disabled to reduce the overhead. )", 0, \ {"26.9", 0.7, 0.7, "The JOIN runtime filters became a Production tier feature."}, \ {"26.1", 0.7, 0.7, "New setting"}) \ DECLARE(UInt64, join_runtime_filter_min_probe_rows, 1000, R"( If, at query planning time, the probe side of a JOIN is estimated to produce no more than this number of rows, the JOIN runtime filter is not created. Building and applying a runtime filter for a tiny probe side costs more than it saves. Set to 0 to always create the runtime filter regardless of the estimated probe size. )", 0, \ {"26.9", 1000, 1000, "The JOIN runtime filters became a Production tier feature."}, \ {"26.8", 0, 1000, "New setting to control minimum probe side size for installing JOIN runtime filters. It wasn't limited before, so previous value is 0 meaning always install."}) \ DECLARE(Bool, join_runtime_filter_from_fixed_hash_table, true, R"( When the hash join build side was converted to a FixedHashMap (see `enable_join_fixed_hash_table_conversion`), use that hash map directly as the runtime filter. )", 0, \ {"26.6", false, true, "New setting."}) \ DECLARE(Bool, enable_join_runtime_filters_index_analysis, true, R"( Prune granules on the probe side of a JOIN with the runtime filter collected from the build side, see `enable_join_runtime_filters`. Only has an effect if `use_skip_indexes_on_data_read = 1`. Only a join key that is a primary key column of the probe side, or is covered by a `minmax`, `set` or `bloom_filter` skip index, or is the global row index `_part_starting_offset + _part_offset`, can be pruned. A self-join on the global row index, which fetches the rows found by a subquery, reads only the granules of those rows. The global row index identifies a row only within one query, so both sides of the join must read the table in the same query. If the runtime filter kept the exact key values, the pruning predicate is an `IN` set of them, otherwise the minimum/maximum key range is used (this has a lower pruning power). For an Iceberg table, the setting also allows skipping whole data files and the Parquet row groups and pages of the files that are read, see [use_join_runtime_filters_for_iceberg_pruning](#use_join_runtime_filters_for_iceberg_pruning); that does not depend on `use_skip_indexes_on_data_read`. Works with parallel replicas (`enable_parallel_replicas = 1`): each replica prunes the granules it reads with the filter it built itself. That filter can be partial - for a `RIGHT` join the build side is the one split among the replicas, so each replica's filter covers only its own share of it - but the result stays correct, because exactly one side of the join is split, every matching pair of rows meets on exactly one replica, and each replica emits a disjoint share of the result. The granule pruning does not happen with a distributed query plan (`make_distributed_plan = 1`). There the setting is a no-op: the query returns the same result and the JOIN runtime filter itself behaves exactly as it does with this setting disabled, only the granule pruning is lost. The granule pruning is also skipped for a probe side read with `FINAL` (the pruning is not implemented for `FINAL` reads, and `optimizeLazyFinal` rebuilds such a read without the descriptors), and for a table with pending data or `ALTER` mutations or patch parts. These cases are a no-op in the same sense. )", 0, \ {"26.10", false, true, "Enable pruning of granules on the probe (left) side of a JOIN by the runtime filter collected from the build (right) side."}, \ {"26.9", false, false, "The JOIN runtime filters became a Production tier feature."}, \ {"26.7", false, false, "New setting to enable join filtering using dynamic index analysis"}) \ DECLARE(Bool, join_runtime_filter_size_from_hash_table_stats, true, R"( Use hash table size statistics collected from previous executions to size the JOIN runtime filter. When disabled, fall back to the fixed `join_runtime_bloom_filter_bytes`. )", 0, \ {"26.7", false, true, "Use hash table size statistics collected from previous executions to size the JOIN runtime filter. When disabled, fall back to the fixed `join_runtime_bloom_filter_bytes`."}) \ DECLARE(Bool, rewrite_in_to_join, false, R"( Rewrite expressions like 'x IN subquery' to JOIN. This might be useful for optimizing the whole query with join reordering. )", EXPERIMENTAL, \ {"25.10", false, false, "New experimental setting"}) \ \ /** timeSeries* aggregate functions (private preview). */ \ DECLARE_WITH_ALIAS(Bool, enable_time_series_aggregate_functions, false, R"( Enables the `timeSeries*` aggregate functions for Prometheus-like time series resampling, rate, and delta calculation. )", PRIVATE_PREVIEW, SETTING_ALIASES(allow_experimental_time_series_aggregate_functions, allow_experimental_ts_to_grid_aggregate_function), \ {"26.9", false, false, "The `timeSeries*` aggregate functions were moved to the private preview tier. Added an alias for setting `allow_experimental_time_series_aggregate_functions`."}, \ {"25.6", false, false, "New setting to enable experimental timeSeries* aggregate functions. At the time the setting was named `allow_experimental_time_series_aggregate_functions`, which is now an alias of it."}, \ {"25.1", false, false, "Cloud only. At the time the setting was named `allow_experimental_ts_to_grid_aggregate_function`, which is now an alias of it."}) \ \ DECLARE(String, promql_database, "", R"( Specifies the database name used by the 'promql' dialect. Empty string means the current database. )", PRIVATE_PREVIEW, \ {"25.8", "", "", "New experimental setting"}) \ \ DECLARE(String, promql_table, "", R"( Specifies the name of a TimeSeries table used by the 'promql' dialect. )", PRIVATE_PREVIEW, \ {"25.8", "", "", "New experimental setting"}) \ \ DECLARE_WITH_ALIAS(DoubleAuto, promql_evaluation_time, Field("auto"), R"( Sets the evaluation time to be used with promql dialect, as a Unix timestamp in seconds with an optional fraction. 'auto' means the current time. )", PRIVATE_PREVIEW, evaluation_time, \ {"25.9", Field{"auto"}, Field{"auto"}, "The setting was renamed. The previous name is `evaluation_time`."}, \ {"25.8", Field{"auto"}, Field{"auto"}, "New experimental setting. At the time the setting was named `evaluation_time`, which is now an alias of it."}) \ \ DECLARE(UInt64, promql_max_points_per_series, 11000, R"( Maximum resolution of a range query in the Prometheus HTTP API (`/api/v1/query_range`). As in Prometheus, the query is rejected if `(end - start) / step` is greater than this value. 0 means no limit. The [prometheusQueryRange](/reference/functions/table-functions/prometheusQueryRange) table function is not limited. )", PRIVATE_PREVIEW, \ {"26.11", 0, 11000, "New setting to limit the resolution of a range query in the Prometheus HTTP API, as in Prometheus."}) \ DECLARE(Bool, promql_push_down_label_matchers, true, R"( Copies the label matchers of one side of a PromQL binary operator to the selectors of the other side for the labels the operator matches series by, so `b / on(job) a{job="x"}` reads only the series of `b` with `job="x"`. A matcher is not copied where the series it filters out could make Prometheus report duplicate series: into the "one" side of the operator unless it is an aggregation by the matched labels, into an operator between two vectors other than `and` and `unless`, and through a function over a range or an operator with a scalar unless its input is one metric selected by name. A comparison without `bool` keeps the metric name, so matchers always go through it. Other functions and the unary minus stop the matchers. A copied matcher turns a selector of a whole metric into a filtered one, which can be slower on a [TimeSeries](/reference/engines/table-engines/integrations/time-series) table with an `id` clustered by metric (the default) if the matcher keeps most series of the metric. Disable the setting for such queries. )", PRIVATE_PREVIEW, \ {"26.10", false, true, "New setting to copy PromQL label matchers across binary operators."}) \ DECLARE_WITH_ALIAS(Bool, enable_paimon_storage_engine, false, R"( Allow to create tables with `Paimon*` table engines. )", EXPERIMENTAL, allow_experimental_paimon_storage_engine, \ {"26.11", false, false, "Added an alias for setting `allow_experimental_paimon_storage_engine`."}, \ {"26.5", false, false, "New setting."}) \ DECLARE(Int64, paimon_target_snapshot_id, -1, R"( Query-level targeted snapshot read for Paimon incremental mode. When >0, the reader will only fetch the delta for the specified snapshot_id without advancing the committed watermark. Default: -1 (disabled) )", EXPERIMENTAL, \ {"26.5", -1, -1, "New setting."}) \ DECLARE(UInt64, max_consume_snapshots, 0, R"( Maximum number of Paimon snapshots to consume per incremental read. 0 means no limit. )", EXPERIMENTAL, \ {"26.5", 0, 0, "New setting."}) \ DECLARE(Bool, use_paimon_partition_pruning, false, R"( Use Paimon partition pruning for Paimon table functions )", EXPERIMENTAL, \ {"25.12", false, false, "New setting."}) \ DECLARE_WITH_ALIAS(Bool, enable_object_storage_queue_hive_partitioning, false, R"( Allow to use hive partitioning with `S3Queue`/`AzureQueue` engines )", EXPERIMENTAL, allow_experimental_object_storage_queue_hive_partitioning, \ {"26.11", false, false, "Added an alias for setting `allow_experimental_object_storage_queue_hive_partitioning`."}, \ {"26.1", false, false, "New setting."}) \ DECLARE(JoinOrderAlgorithm, query_plan_optimize_join_order_algorithm, "dpsub,greedy", R"( Specifies which JOIN order algorithms to attempt during query plan optimization. The following algorithms are available: - 'greedy' - basic greedy algorithm - works fast but might not produce the best join order - 'dpsize' - implements DPsize algorithm currently only for Inner joins - considers all possible join orders and finds the most optimal one but might be slow for queries with many tables and join predicates. - 'dpsub' - implements DPsub algorithm which supports both inner and non-inner joins - considers all possible join orders and finds the most optimal one. It only applies to queries with at most 12 relations; above that it gives way to the next algorithm in the list. - 'dphyp' - implements DPhyp (Dynamic Programming via Hypergraph Partitioning) algorithm currently only for inner joins - explores the same search space as `dpsize` but enumerates only connected subgraph pairs, which generates fewer intermediate joins on sparse join graphs, at the cost of not considering cross products Multiple algorithms can be specified as a comma-separated list, e.g. `dphyp,greedy`. They are tried in order; if an algorithm cannot handle the query (e.g. due to too many relations or disconnected components), the next one is used as a fallback. )", BETA, \ {"26.11", "greedy", "dpsub,greedy", "`dpsub` is now the default join order algorithm; queries with more than 12 relations fall back to `greedy`."}, \ {"25.12", "greedy", "greedy", "New experimental setting."}) \ DECLARE(JoinOrderConflictDetector, query_plan_optimize_join_order_conflict_detector, JoinOrderConflictDetector::CD_C, R"( Only affects the `dpsub` join order algorithm. Selects the conflict detector that DPsub uses to decide which join reorderings are valid. The following values are available: - `''` - no conflict detector, DPsub uses the per-relation `ON` clause restriction - `'a'` - the CD-A conflict detector, which is correct but incomplete - `'c'` (default) - the CD-C conflict detector, which is correct and complete )", BETA, \ {"26.11", "", "c", "New setting selecting the conflict detector that decides join reordering validity in the DPsub join order algorithm: `a` for the (correct but incomplete) CD-A, `c` for the (correct and complete) CD-C, empty for none. It defaults to CD-C, together with the `dpsub` default of `query_plan_optimize_join_order_algorithm`, which also lets semi and anti joins take part in reordering."}, \ {"26.9", "", "", "New setting selecting the conflict detector that decides join reordering validity in the DPsub join order algorithm: `a` for the (correct but incomplete) CD-A, `c` for the (correct and complete) CD-C, empty for none."}) \ DECLARE(Bool, query_plan_join_order_use_interesting_orders, true, R"( Only affects the `dpsub` join order algorithm. Makes it aware of the sort order of the joined tables: for each inner equi-join it chooses between a hash join and `full_sorting_merge` by cost, and keeps partial plans whose result is sorted by a join key that a later join can use. An input counts as sorted by a join key when `optimize_read_in_order` can read it in the order of that key from a `MergeTree` table, or when it is the result of a `full_sorting_merge` join on that key. A join chosen to run as `full_sorting_merge` tries it first, with the `join_algorithm` list as its fallback. The choice is made only when `join_algorithm` has its default value: any other list is a priority list, used as it is. Requires `enable_join_transitive_predicates`. )", BETA, \ {"26.11", false, true, "New setting, enabled by default: the DPsub join order algorithm chooses between hash and sort-merge joins using the sort order of the inputs."}) \ DECLARE_WITH_ALIAS(Bool, enable_database_paimon_rest_catalog, false, R"( Allow database engine `DataLakeCatalog` with `catalog_type = 'paimon_rest'` )", EXPERIMENTAL, allow_experimental_database_paimon_rest_catalog, \ {"26.11", false, false, "Added an alias for setting `allow_experimental_database_paimon_rest_catalog`."}, \ {"26.1", false, false, "New setting"}) \ DECLARE(UInt64, webassembly_udf_max_fuel, 100'000, R"( Fuel limit per WebAssembly UDF instance execution. Each WebAssembly instruction consumes some amount of fuel. The value is scaled by 1024 before being passed to the runtime, so `webassembly_udf_max_fuel = 1` corresponds to approximately 1024 fuel units. Set to 0 for no finite limit. Applies only to functions whose per-function setting `webassembly_udf_enable_fuel` is true, which is the default. )", EXPERIMENTAL, \ {"26.3", 100'000, 100'000, "New setting to limit CPU instructions (fuel) per WebAssembly UDF instance execution."}) \ DECLARE(UInt64, webassembly_udf_max_memory, 128_MiB, R"( Memory limit in bytes per WebAssembly UDF instance. )", EXPERIMENTAL, \ {"26.3", 128_MiB, 128_MiB, "New setting to limit memory per WebAssembly UDF instance."}) \ DECLARE(UInt64, webassembly_udf_max_input_block_size, 0, R"( Maximum number of rows passed to a WebAssembly UDF in a single call. A non-zero value caps the rows per call and applies to every ABI. Set to 0 to size the calls by their serialized input instead. That applies to `ABI BUFFERED_V1` alone, the only ABI that serializes a whole input block into guest memory: its blocks are split so that a call's input stays within `webassembly_udf_input_split_memory_ratio` of the module's linear memory. `ROW_DIRECT` passes its arguments as WebAssembly values and `ASSEMBLYSCRIPT` builds one object per row, so neither has a serialized input to size a call by, and 0 leaves their pipeline block whole. )", EXPERIMENTAL, \ {"26.3", 0, 0, "New setting to limit input block size for WebAssembly UDFs."}) \ DECLARE(Float, webassembly_udf_input_split_memory_ratio, 0.5, R"( Fraction of a WebAssembly UDF instance's linear memory that one call's serialized input may occupy. Must be at least 0 and at most 1; the default leaves the other half to the guest for its own working set beside the input buffer. The margin below 1 is what makes the batching safe: the guest's own data, stack and allocator share that memory and are invisible to the host. A ratio close to 1 leaves nothing for them, so a call sized against it can still fail inside the guest's allocator. Read only for `ABI BUFFERED_V1`, and it sizes the calls only while `webassembly_udf_max_input_block_size` is 0 - a non-zero block size caps the rows per call instead. A batch is never taken below a single row, so a row whose own serialized size is past the budget is passed on its own, and one too large for the module's linear memory fails inside the guest's allocator. Set to 0 to leave the input unsplit: the whole pipeline block is passed in one call. )", EXPERIMENTAL, \ {"26.9", 0.0, 0.5, "New setting controlling the fraction of a WebAssembly UDF instance's linear memory that one call's serialized input may occupy, which also enables the dynamic splitting of that input by its serialized size; `compatibility` below 26.9 sets it to 0 and restores the previous behavior, where `webassembly_udf_max_input_block_size = 0` meant one call per pipeline block."}) \ DECLARE(UInt64, webassembly_udf_max_instances, 32, R"( Maximum number of WebAssembly UDF instances that can run in parallel per function. )", EXPERIMENTAL, \ {"26.3", 32, 32, "New setting to limit the number of parallel WebAssembly UDF instances per function."}) \ DECLARE_WITH_ALIAS(Bool, enable_eval_table_function, false, R"( Enable table function `eval`. )", EXPERIMENTAL, allow_experimental_eval_table_function, \ {"26.11", false, false, "Added an alias for setting `allow_experimental_eval_table_function`."}, \ {"26.7", false, false, "New setting to enable the experimental table function `eval`."}) \ \ /* ####################################################### */ \ /* ############ END OF EXPERIMENTAL FEATURES ############# */ \ /* ####################################################### */ \ // End of COMMON_SETTINGS // Please add settings related to formats in Core/FormatFactorySettings.h, move obsolete settings to OBSOLETE_SETTINGS and obsolete format settings to OBSOLETE_FORMAT_SETTINGS. #define OBSOLETE_SETTINGS(M, ALIAS) \ /** Obsolete settings which are kept around for compatibility reasons. They have no effect anymore. */ \ MAKE_OBSOLETE(M, UInt64, iceberg_compaction_max_rows_in_data_file, std::numeric_limits::max(), \ {"26.11", std::numeric_limits::max(), std::numeric_limits::max(), "Obsolete: a compaction merge of Iceberg data files writes one output file, without a limit on its size."}) \ MAKE_OBSOLETE(M, UInt64, iceberg_compaction_max_bytes_in_data_file, 512_MiB, \ {"26.11", 512 * 1024 * 1024, 512 * 1024 * 1024, "Obsolete: a compaction merge of Iceberg data files writes one output file, without a limit on its size."}) \ MAKE_OBSOLETE(M, UInt64, iceberg_data_file_size_upper_threshold_compaction, 512_MiB * 9 / 5, \ {"26.11", 512ULL * 1024 * 1024 * 9 / 5, 512ULL * 1024 * 1024 * 9 / 5, "Obsolete: compaction no longer splits big data files, because a compaction merge writes one output file without a limit on its size."}) \ MAKE_OBSOLETE(M, Bool, enable_optimize_predicate_expression, true, \ {"18.12.17", 0, 1, "Optimize predicates to subqueries by default"}) \ MAKE_OBSOLETE(M, Bool, parallel_replicas_only_with_analyzer, true, \ {"25.2", true, true, "Parallel replicas is supported only with analyzer enabled"}) \ MAKE_OBSOLETE(M, Bool, enable_sharding_aggregator, false, \ {"26.9", false, false, "Obsolete setting, the sharded aggregator has been removed in favor of the adaptive aggregator (`enable_adaptive_aggregator`)."}, \ {"26.6", false, false, "New setting to enable sharded `GROUP BY` optimization that distributes rows across threads by hashing the grouping key, so each thread aggregates a disjoint subset of keys without a merge phase; this is efficient for high cardinality keys with evenly distributed data."}) \ MAKE_OBSOLETE(M, Bool, use_statistics_cache, true, \ {"26.2", false, true, "Enable statistics cache"}, \ {"25.11", 0, 0, "New setting"}) \ MAKE_OBSOLETE(M, Bool, s3_disable_checksum, false, \ {"26.9", false, false, "Obsolete setting: checksum calculation no longer re-reads the source"}) \ MAKE_OBSOLETE(M, Bool, distributed_cache_use_clients_cache_for_write, false, \ {"25.12", false, false, "New setting"}) \ ALIAS(Bool, filesystem_cache_skip_download_if_exceeds_per_query_cache_write_limit, true, "Obsolete setting, does nothing.", SettingsTierType::OBSOLETE, skip_download_if_exceeds_query_cache, \ {"26.10", true, true, "Obsolete: the per-query filesystem cache write limit was removed."}, \ {"24.11", 1, 1, "Rename of setting skip_download_if_exceeds_query_cache_limit"}) \ MAKE_OBSOLETE(M, UInt64, filesystem_cache_max_download_size, (128UL * 1024 * 1024 * 1024), \ {"26.10", 137438953472, 137438953472, "Obsolete: the per-query filesystem cache write limit was removed. A query is no longer capped in how much it writes into a filesystem cache; the cache's own `max_size` and eviction policy bound it."}) \ ALIAS(Bool, allow_delta_kernel_rs, true, "Obsolete setting, does nothing.", SettingsTierType::OBSOLETE, allow_experimental_delta_kernel_rs, \ {"26.11", true, true, "Obsolete: the legacy Delta Lake reader was removed, `delta-kernel-rs` is always used."}, \ {"26.8", true, true, "New name of `allow_experimental_delta_kernel_rs`, which is no longer experimental and is kept as an alias. The default is unchanged."}, \ {"25.5", false, true, "New setting. Introduced under the name `allow_experimental_delta_kernel_rs`, which is now an alias of it; the row is carried forward under the canonical name so that it keeps the whole history."}) \ MAKE_OBSOLETE(M, String, function_implementation, "") \ MAKE_OBSOLETE(M, Bool, allow_experimental_query_deduplication, false, \ {"26.6", false, false, "The setting is obsolete, the feature has been removed."}) \ MAKE_OBSOLETE(M, Bool, query_condition_cache_store_conditions_as_plaintext, false, \ {"25.4", false, false, "New setting"}) \ MAKE_OBSOLETE(M, Bool, update_insert_deduplication_token_in_dependent_materialized_views, 0, \ {"24.1", false, false, "Allow to update insert deduplication token with table identifier during insert in dependent materialized views"}) \ MAKE_OBSOLETE(M, UInt64, max_memory_usage_for_all_queries, 0) \ MAKE_OBSOLETE(M, UInt64, multiple_joins_rewriter_version, 0) \ MAKE_OBSOLETE(M, Bool, enable_debug_queries, false) \ MAKE_OBSOLETE(M, Bool, allow_experimental_database_atomic, true) \ MAKE_OBSOLETE(M, Bool, allow_experimental_bigint_types, true) \ MAKE_OBSOLETE(M, Bool, allow_experimental_window_functions, true) \ MAKE_OBSOLETE(M, Bool, allow_experimental_geo_types, true) \ MAKE_OBSOLETE(M, Bool, allow_experimental_query_cache, true) \ MAKE_OBSOLETE(M, Bool, allow_experimental_alter_materialized_view_structure, true) \ MAKE_OBSOLETE(M, Bool, allow_experimental_shared_merge_tree, true, \ {"24.3", false, true, "The setting is obsolete"}) \ MAKE_OBSOLETE(M, Bool, allow_experimental_database_replicated, true, \ {"24.4", false, true, "Database engine Replicated is now in Beta stage"}) \ MAKE_OBSOLETE(M, Bool, allow_experimental_refreshable_materialized_view, true, \ {"24.10", false, true, "Not experimental anymore"}) \ MAKE_OBSOLETE(M, Bool, allow_experimental_bfloat16_type, true, \ {"25.1", false, true, "Add new BFloat16 type"}, \ {"24.11", false, false, "Add new experimental BFloat16 type"}) \ MAKE_OBSOLETE(M, Bool, allow_experimental_inverted_index, false) \ MAKE_OBSOLETE(M, Bool, allow_experimental_vector_similarity_index, true, \ {"25.8", false, true, "Vector similarity indexes are GA."}, \ {"24.8", false, false, "Added new setting to allow experimental vector similarity indexes"}) \ MAKE_OBSOLETE(M, Bool, allow_experimental_text_index_lazy_apply, true, \ {"26.7", false, true, "Lazy posting list apply mode for the text index is no longer experimental; the setting is now obsolete and has no effect (lazy mode is selected via `text_index_posting_list_apply_mode = 'lazy'`)."}, \ {"26.6", false, false, "New setting to gate experimental lazy posting list apply mode"}) \ MAKE_OBSOLETE(M, Bool, allow_experimental_statistic, false, \ {"24.6", false, false, "Old setting which popped up here being renamed."}) \ MAKE_OBSOLETE(M, Bool, enable_vector_similarity_index, true, \ {"25.8", false, true, "Vector similarity indexes are GA."}, \ {"25.7", false, false, "Added an alias for setting `allow_experimental_vector_similarity_index`"}) \ MAKE_OBSOLETE(M, Bool, allow_experimental_qbit_type, true, \ {"26.1", false, true, "QBit was moved to Beta"}, \ {"25.10", false, false, "New experimental setting"}) \ MAKE_OBSOLETE(M, Bool, enable_qbit_type, true, \ {"26.1", false, true, "QBit was moved to Beta. Added an alias for setting 'allow_experimental_qbit_type'."}) \ MAKE_OBSOLETE(M, Bool, allow_experimental_alias_table_engine, false) \ MAKE_OBSOLETE(M, Bool, allow_deprecated_snowflake_conversion_functions, false, \ {"24.6", true, false, "Disabled deprecated functions snowflakeToDateTime[64] and dateTime[64]ToSnowflake."}) \ MAKE_OBSOLETE(M, Bool, validate_mutation_query, true, \ {"26.10", true, true, "Obsolete setting: mutation queries are always validated before being accepted. The recorded value does not change, because validation was already enabled by default and `compatibility` must not turn it back off."}, \ {"24.11", false, true, "New setting to validate mutation queries by default."}) \ \ MAKE_OBSOLETE(M, Milliseconds, async_insert_stale_timeout_ms, 0) \ MAKE_OBSOLETE(M, StreamingHandleErrorMode, handle_kafka_error_mode, StreamingHandleErrorMode::DEFAULT) \ MAKE_OBSOLETE(M, Bool, database_replicated_ddl_output, true) \ MAKE_OBSOLETE(M, UInt64, replication_alter_columns_timeout, 60) \ MAKE_OBSOLETE(M, UInt64, odbc_max_field_size, 0) \ MAKE_OBSOLETE(M, Bool, allow_experimental_map_type, true) \ MAKE_OBSOLETE(M, UInt64, merge_tree_clear_old_temporary_directories_interval_seconds, 60) \ MAKE_OBSOLETE(M, UInt64, merge_tree_clear_old_parts_interval_seconds, 1) \ MAKE_OBSOLETE(M, UInt64, partial_merge_join_optimizations, 0) \ MAKE_OBSOLETE(M, MaxThreads, max_alter_threads, 0) \ MAKE_OBSOLETE(M, Bool, use_mysql_types_in_show_columns, false) \ MAKE_OBSOLETE(M, Bool, s3queue_allow_experimental_sharded_mode, false, \ {"24.3", false, false, "Enable experimental sharded mode of S3Queue table engine. It is experimental because it will be rewritten"}) \ MAKE_OBSOLETE(M, LightweightMutationProjectionMode, lightweight_mutation_projection_mode, LightweightMutationProjectionMode::THROW) \ MAKE_OBSOLETE(M, Bool, use_local_cache_for_remote_storage, false, \ {"25.4", true, false, "Obsolete setting."}) \ MAKE_OBSOLETE(M, Bool, allow_experimental_join_condition, false, \ {"24.5", false, false, "Support join with inequal conditions which involve columns from both left and right table. e.g. t1.y < t2.y."}) \ MAKE_OBSOLETE(M, Bool, allow_experimental_variant_type, true, \ {"25.3", false, true, "Variant data type is production-ready"}, \ {"24.1", false, false, "Add new experimental Variant type"}) \ MAKE_OBSOLETE(M, Bool, allow_experimental_dynamic_type, true, \ {"25.3", false, true, "Dynamic data type is production-ready"}, \ {"24.5", false, false, "Add new experimental Dynamic type"}) \ MAKE_OBSOLETE(M, Bool, allow_experimental_json_type, true, \ {"25.3", false, true, "JSON data type is production-ready"}, \ {"24.8", false, false, "Add new experimental JSON type"}) \ MAKE_OBSOLETE(M, Bool, enable_variant_type, true, \ {"25.3", false, true, "Variant data type is production-ready"}, \ {"24.11", false, false, "Add alias to allow_experimental_variant_type"}) \ MAKE_OBSOLETE(M, Bool, enable_dynamic_type, true, \ {"25.3", false, true, "Dynamic data type is production-ready"}, \ {"24.11", false, false, "Add alias to allow_experimental_dynamic_type"}) \ MAKE_OBSOLETE(M, Bool, enable_json_type, true, \ {"25.3", false, true, "JSON data type is production-ready"}, \ {"24.11", false, false, "Add alias to allow_experimental_json_type"}) \ MAKE_OBSOLETE(M, Bool, s3_slow_all_threads_after_retryable_error, false, \ {"25.10", false, false, "Disable the setting by default"}, \ {"25.9", false, false, "Added an alias for setting `backup_slow_all_threads_after_retryable_s3_error`"}, \ {"25.8", false, false, "Added an alias for setting `backup_slow_all_threads_after_retryable_s3_error`"}, \ {"25.6", false, false, "Added an alias for setting `backup_slow_all_threads_after_retryable_s3_error`"}) \ MAKE_OBSOLETE(M, Bool, azure_sdk_use_native_client, true, \ {"25.8", false, true, "New setting"}) \ MAKE_OBSOLETE(M, Bool, allow_not_comparable_types_in_order_by, false, \ {"25.1", true, false, "Don't allow not comparable types in order by by default"}) \ MAKE_OBSOLETE(M, Bool, allow_not_comparable_types_in_comparison_functions, false, \ {"25.1", true, false, "Don't allow not comparable types in comparison functions by default"}) \ MAKE_OBSOLETE(M, Bool, enable_zstd_qat_codec, false, \ {"24.1", false, false, "Add new ZSTD_QAT codec"}) \ MAKE_OBSOLETE(M, Bool, enable_deflate_qpl_codec, false) \ MAKE_OBSOLETE(M, Bool, throw_if_deduplication_in_dependent_materialized_views_enabled_with_async_insert, false, \ {"26.1", true, false, "It becomes obsolete."}, \ {"24.3", false, true, "Deduplication in dependent materialized view cannot work together with async inserts."}) \ MAKE_OBSOLETE(M, Bool, use_projection_index_in_read_pools, false, \ {"26.8", false, false, "Obsolete setting, renamed to `use_indexes_refiner_in_read_pools`."}) \ MAKE_OBSOLETE(M, Bool, allow_experimental_codecs, false) \ MAKE_OBSOLETE(M, Bool, enable_alp_codec, true, \ {"26.11", false, true, "Obsolete setting: the `ALP` compression codec is generally available and no longer needs to be enabled."}, \ {"26.8", false, false, "New setting to enable the experimental `ALP` compression codec individually, without the `allow_experimental_codecs`."}) \ MAKE_OBSOLETE(M, UInt64, s3_max_connections, 1024) \ \ /* moved to config.xml: see also src/Core/ServerSettings.h */ \ MAKE_DEPRECATED_BY_SERVER_CONFIG(M, UInt64, background_buffer_flush_schedule_pool_size, 16) \ MAKE_DEPRECATED_BY_SERVER_CONFIG(M, UInt64, background_pool_size, 16) \ MAKE_DEPRECATED_BY_SERVER_CONFIG(M, Float, background_merges_mutations_concurrency_ratio, 2) \ MAKE_DEPRECATED_BY_SERVER_CONFIG(M, UInt64, background_move_pool_size, 8) \ MAKE_DEPRECATED_BY_SERVER_CONFIG(M, UInt64, background_fetches_pool_size, 8) \ MAKE_DEPRECATED_BY_SERVER_CONFIG(M, UInt64, background_common_pool_size, 8) \ MAKE_DEPRECATED_BY_SERVER_CONFIG(M, UInt64, background_schedule_pool_size, 128) \ MAKE_DEPRECATED_BY_SERVER_CONFIG(M, UInt64, background_message_broker_schedule_pool_size, 16) \ MAKE_DEPRECATED_BY_SERVER_CONFIG(M, UInt64, background_distributed_schedule_pool_size, 16) \ MAKE_DEPRECATED_BY_SERVER_CONFIG(M, UInt64, max_remote_read_network_bandwidth_for_server, 0) \ MAKE_DEPRECATED_BY_SERVER_CONFIG(M, UInt64, max_remote_write_network_bandwidth_for_server, 0) \ MAKE_DEPRECATED_BY_SERVER_CONFIG(M, Bool, read_through_distributed_cache, false, \ {"26.9", false, false, "The setting moved to the server configuration and is ignored as a profile setting: reading from the distributed cache is now switched by the server setting `enable_read_through_distributed_cache`, which is applied without a restart (so that merges, mutations and `Buffer` flushes follow it too, instead of being pinned to the value the server started with). Use `force_read_through_distributed_cache` to deviate from the server setting per query."}, \ {"26.8", false, false, "The setting moved to the server configuration and is ignored as a profile setting: reading from the distributed cache is now switched by the server setting `enable_read_through_distributed_cache`, which is applied without a restart (so that merges, mutations and `Buffer` flushes follow it too, instead of being pinned to the value the server started with). Use `force_read_through_distributed_cache` to deviate from the server setting per query."}, \ {"24.10", 0, 0, "A setting for ClickHouse Cloud"}) \ MAKE_DEPRECATED_BY_SERVER_CONFIG(M, Bool, write_through_distributed_cache, false, \ {"26.9", false, false, "The setting moved to the server configuration and is ignored as a profile setting: writing to the distributed cache is now switched by the server setting `enable_write_through_distributed_cache`, which is applied without a restart (so that merges, mutations and `Buffer` flushes follow it too, instead of being pinned to the value the server started with). Use `force_write_through_distributed_cache` to deviate from the server setting per query."}, \ {"26.8", false, false, "The setting moved to the server configuration and is ignored as a profile setting: writing to the distributed cache is now switched by the server setting `enable_write_through_distributed_cache`, which is applied without a restart (so that merges, mutations and `Buffer` flushes follow it too, instead of being pinned to the value the server started with). Use `force_write_through_distributed_cache` to deviate from the server setting per query."}, \ {"24.10", 0, 0, "A setting for ClickHouse Cloud"}) \ MAKE_DEPRECATED_BY_SERVER_CONFIG(M, UInt64, async_insert_threads, 16) \ MAKE_DEPRECATED_BY_SERVER_CONFIG(M, UInt64, max_replicated_fetches_network_bandwidth_for_server, 0) \ MAKE_DEPRECATED_BY_SERVER_CONFIG(M, UInt64, max_replicated_sends_network_bandwidth_for_server, 0) \ MAKE_DEPRECATED_BY_SERVER_CONFIG(M, UInt64, max_entries_for_hash_table_stats, 10'000) \ MAKE_DEPRECATED_BY_SERVER_CONFIG(M, UInt64, s3_max_redirects, S3::DEFAULT_MAX_REDIRECTS) \ MAKE_DEPRECATED_BY_SERVER_CONFIG(M, UInt64, s3_retry_attempts, S3::DEFAULT_RETRY_ATTEMPTS, \ {"25.11", 500, 500, "Changed the value of the obsolete setting"}, \ {"25.6", 500, 500, "Changed the value of the obsolete setting"}) \ /* ---- */ \ MAKE_OBSOLETE(M, DefaultDatabaseEngine, default_database_engine, DefaultDatabaseEngine::Atomic) \ MAKE_OBSOLETE(M, UInt64, max_pipeline_depth, 0) \ MAKE_OBSOLETE(M, Seconds, temporary_live_view_timeout, 1) \ MAKE_OBSOLETE(M, Seconds, periodic_live_view_refresh, 60) \ MAKE_OBSOLETE(M, Bool, allow_experimental_live_view, false) \ MAKE_OBSOLETE(M, Seconds, live_view_heartbeat_interval, 15) \ MAKE_OBSOLETE(M, UInt64, max_live_view_insert_blocks_before_refresh, 64) \ MAKE_OBSOLETE(M, Bool, allow_experimental_window_view, false) \ MAKE_OBSOLETE(M, Seconds, window_view_clean_interval, 60) \ MAKE_OBSOLETE(M, Seconds, window_view_heartbeat_interval, 15) \ MAKE_OBSOLETE(M, Seconds, wait_for_window_view_fire_signal_timeout, 10) \ MAKE_OBSOLETE(M, Milliseconds, async_insert_cleanup_timeout_ms, 1000) \ MAKE_OBSOLETE(M, Bool, optimize_fuse_sum_count_avg, 0) \ MAKE_OBSOLETE(M, Seconds, drain_timeout, 3) \ MAKE_OBSOLETE(M, UInt64, backup_threads, 16) \ MAKE_OBSOLETE(M, UInt64, restore_threads, 16) \ MAKE_OBSOLETE(M, Bool, optimize_duplicate_order_by_and_distinct, false, \ {"23.2", true, false, "Remove duplicate ORDER BY and DISTINCT if it's possible"}) \ MAKE_OBSOLETE(M, UInt64, parallel_replicas_min_number_of_granules_to_enable, 0) \ MAKE_OBSOLETE(M, ParallelReplicasCustomKeyFilterType, parallel_replicas_custom_key_filter_type, ParallelReplicasCustomKeyFilterType::DEFAULT) \ MAKE_OBSOLETE(M, Bool, query_plan_optimize_projection, true) \ MAKE_OBSOLETE(M, Bool, query_cache_store_results_of_queries_with_nondeterministic_functions, false) \ MAKE_OBSOLETE(M, Bool, allow_experimental_annoy_index, false) \ MAKE_OBSOLETE(M, UInt64, max_threads_for_annoy_index_creation, 4) \ MAKE_OBSOLETE(M, Int64, annoy_index_search_k_nodes, -1) \ MAKE_OBSOLETE(M, Int64, max_limit_for_ann_queries, -1, \ {"25.5", 1'000, 0, "Obsolete setting"}) \ MAKE_OBSOLETE(M, Bool, allow_experimental_usearch_index, false) \ MAKE_OBSOLETE(M, Bool, optimize_move_functions_out_of_any, false) \ MAKE_OBSOLETE(M, Bool, allow_experimental_undrop_table_query, true) \ MAKE_OBSOLETE(M, Bool, allow_experimental_s3queue, true) \ MAKE_OBSOLETE(M, Bool, text_index_use_bloom_filter, true, \ {"25.9", true, true, "New setting."}) \ MAKE_OBSOLETE(M, Bool, query_plan_optimize_primary_key, true) \ MAKE_OBSOLETE(M, Bool, optimize_monotonous_functions_in_order_by, false) \ MAKE_OBSOLETE(M, UInt64, http_max_chunk_size, 100_GiB, \ {"24.5", 0, 0, "Internal limitation"}) \ MAKE_OBSOLETE(M, Bool, iceberg_engine_ignore_schema_evolution, false, \ {"24.1", false, false, "Allow to ignore schema evolution in Iceberg table engine"}) \ MAKE_OBSOLETE(M, Float, parallel_replicas_single_task_marks_count_multiplier, 2) \ MAKE_OBSOLETE(M, Bool, allow_experimental_database_materialized_mysql, false) \ MAKE_OBSOLETE(M, Bool, allow_experimental_shared_set_join, true, \ {"25.4", 0, 1, "A setting for ClickHouse Cloud to enable SharedSet and SharedJoin"}, \ {"24.10", 0, 0, "A setting for ClickHouse Cloud"}) \ MAKE_OBSOLETE(M, UInt64, min_external_sort_block_bytes, 100_MiB, \ {"25.1", 0., 100_MiB, "New setting."}) \ MAKE_OBSOLETE(M, UInt64, distributed_cache_read_alignment, 0, \ {"24.10", 0, 0, "A setting for ClickHouse Cloud"}) \ MAKE_OBSOLETE(M, Bool, use_json_alias_for_old_object_type, false, \ {"24.8", true, false, "Use JSON type alias to create new JSON type"}) \ MAKE_OBSOLETE(M, Bool, describe_extend_object_types, false) \ MAKE_OBSOLETE(M, Bool, allow_experimental_object_type, false) \ MAKE_OBSOLETE(M, BoolAuto, insert_select_deduplicate, Field{"auto"}, \ {"25.12", Field{"auto"}, Field{"auto"}, "New setting"}) \ MAKE_OBSOLETE(M, Bool, use_text_index_dictionary_cache, false, \ {"25.11", false, false, "New setting"}) \ MAKE_OBSOLETE(M, Bool, query_plan_use_logical_join_step, true, \ {"26.5", true, true, "Obsolete setting, the logical join step is now always used."}, \ {"25.10", true, true, "Added alias"}) \ MAKE_OBSOLETE(M, Bool, query_plan_use_new_logical_join_step, true, \ {"26.5", true, true, "Obsolete setting, the logical join step is now always used."}, \ {"25.2", false, true, "Enable new step"}, \ {"25.1", false, false, "New join step, internal change"}) \ MAKE_OBSOLETE(M, Bool, query_plan_read_in_order, true, \ {"26.10", true, true, "Obsolete setting: the read-in-order optimization is now always applied at the query plan level, and the legacy interpreter-level implementation (`ReadInOrderOptimizer`) was removed. Use `optimize_read_in_order` to toggle the optimization."}) \ MAKE_OBSOLETE(M, Bool, query_plan_optimize_prewhere, true, \ {"26.10", true, true, "Obsolete setting: moving conditions from `WHERE` to `PREWHERE` is now always done at the query plan level, and the legacy AST-based implementation in `InterpreterSelectQuery` was removed. Use `optimize_move_to_prewhere` to toggle the optimization."}, \ {"24.2", true, true, "Allow to push down filter to PREWHERE expression for supported storages"}) \ MAKE_OBSOLETE(M, Bool, query_plan_aggregation_in_order, true, \ {"26.10", true, true, "Obsolete setting: the aggregation-in-order optimization is now always applied at the query plan level, and the legacy interpreter-level implementation was removed. Use `optimize_aggregation_in_order` to toggle the optimization."}, \ {"22.12", 0, 1, "Enable some refactoring around query plan"}) \ MAKE_OBSOLETE(M, Bool, count_distinct_optimization, false, \ {"26.11", false, false, "Obsolete setting: a single `uniqExact` or `count(DISTINCT)` without `GROUP BY` is computed by radix partitioning (`optimize_uniq_exact_radix_partitioning`), which made the rewrite to a `GROUP BY` subquery unnecessary."}) \ MAKE_OBSOLETE(M, Bool, parallel_replicas_insert_select_local_pipeline, true, \ {"26.10", true, true, "Obsolete setting: whether the initiator runs the local pipeline of a distributed `INSERT SELECT` is decided by `parallel_replicas_local_plan` and `parallel_replicas_prefer_local_replica` alone, and it is still skipped when `max_execution_time_leaf` imposes a different timeout contract. Set `parallel_replicas_local_plan = 0` to leave all the reading to the remote replicas."}, \ {"25.5", false, true, "Use local pipeline during distributed INSERT SELECT with parallel replicas. Currently disabled due to performance issues"}, \ {"25.4", false, false, "Use local pipeline during distributed INSERT SELECT with parallel replicas. Currently disabled due to performance issues"}) \ MAKE_OBSOLETE(M, UInt64, cloud_mode_database_engine, 1, \ {"26.6", 1, 1, "Obsolete setting, the database engine in Cloud no longer depends on it."}, \ {"24.10", 1, 1, "A setting for ClickHouse Cloud"}) \ MAKE_OBSOLETE(M, Float, text_index_lazy_intersection_density_threshold, 0.2f, \ {"26.7", 0.2, 0.2, "Renamed from `text_index_density_threshold` (kept as an alias); selects the posting list intersection algorithm in lazy posting list apply mode."}) \ MAKE_OBSOLETE(M, Bool, allow_named_collection_override_by_default, true, \ {"26.10", true, true, "Obsolete. Overriding named collection keys requires `SHOW NAMED COLLECTIONS SECRETS`."}) \ MAKE_OBSOLETE(M, Float, text_index_density_threshold, 0.2f, \ {"26.6", 0.2, 0.2, "New setting for lazy posting list density threshold"}) \ MAKE_OBSOLETE(M, Bool, use_compact_format_in_distributed_parts_names, true, \ {"26.10", true, true, "Obsolete setting. The non-compact directory format for the async `INSERT` queue of a `Distributed` table has been removed. The setting was 1 by default since version 21.1. Switch to `1` and let the queue drain before upgrading."}, \ {"21.1", false, true, "Use compact format for async INSERT into Distributed tables by default"}) \ MAKE_OBSOLETE(M, NonZeroUInt64, iceberg_manifest_decode_concurrency, 16, \ {"26.11", 4, 16, "Obsolete setting: Iceberg manifest files are read on the IO thread pool and parsed by the threads reading the table."}, \ {"26.9", 2, 4, "New setting bounding how many Iceberg manifest files are decoded concurrently, for delete and data manifests alike. It replaces `iceberg_delete_manifest_decode_concurrency` (kept as an alias). `2` approximates the pre-26.9 data path, which decoded one manifest at a time with the next one's fetch already in flight; under `compatibility` at or below 26.8 the delete decode therefore also runs at 2 rather than its released default of 4, preserving the older data-path memory envelope at the cost of some delete-decode overlap."}, \ {"26.8", 2, 4, "New setting bounding how many Iceberg delete manifest files are decoded concurrently before the first row is read. Before 26.8 one manifest was decoded at a time with the next one's fetch already in flight, so `2` is the closest equivalent of the previous behavior, which put the sum of their object storage round-trips on the critical path before the first row. At the time the setting was named `iceberg_delete_manifest_decode_concurrency`, which is now an alias of it."}) \ MAKE_OBSOLETE(M, NonZeroUInt64, iceberg_delete_manifest_decode_concurrency, 16, \ {"26.11", 4, 16, "Obsolete setting, formerly an alias of `iceberg_manifest_decode_concurrency`."}) \ MAKE_OBSOLETE(M, NonZeroUInt64, iceberg_file_entries_queue_size, 100, \ {"26.11", 100, 100, "Obsolete setting: there is no queue between Iceberg manifest parsing and the query any more."}, \ {"26.9", 100, 100, "New setting for the previously hardcoded capacity of the queue between the Iceberg data manifest decode tasks and the query."}) /** The section above is for obsolete settings. Do not add anything there. */ #endif /// __CLION_IDE__ #define LIST_OF_SETTINGS(M, ALIAS) \ COMMON_SETTINGS(M, ALIAS) \ OBSOLETE_SETTINGS(M, ALIAS) \ FORMAT_FACTORY_SETTINGS(M, ALIAS) \ OBSOLETE_FORMAT_SETTINGS(M, ALIAS) \ // clang-format on DECLARE_SETTINGS_TRAITS_ALLOW_CUSTOM_SETTINGS(SettingsTraits, LIST_OF_SETTINGS, COMMON_SETTINGS_SUPPORTED_TYPES) /// A `merge_tree_`-prefixed name is a `MergeTreeSettings` setting kept here as a custom setting, and it can /// have two names. Store it under the canonical one, so that a value written under either name is the value /// read under either name, instead of the two names holding two values of one setting. template <> std::string_view resolveCustomSettingName(std::string_view name) { return canonicalSettingName(name); } /** Settings of query execution. * These settings go to users.xml. */ struct SettingsImpl : public BaseSettings, public IHints<2> { SettingsImpl() = default; /** Set multiple settings from "profile" (in server configuration file (users.xml), profiles contain groups of multiple settings). * The profile can also be set using the `set` functions, like the profile setting. */ void setProfile(const String & profile_name, const Poco::Util::AbstractConfiguration & config); /// Load settings from configuration file, at "path" prefix in configuration. void loadSettingsFromConfig(const String & path, const Poco::Util::AbstractConfiguration & config); /// Dumps profile events to column of type Map(String, String) void dumpToMapColumn(IColumn * column, bool changed_only, bool show_secrets); /// The changed settings as an owning name -> value-string map (same values as dumpToMapColumn). [[nodiscard]] FlatStringMap changedToFlatMap(bool show_secrets) const; /// Check that there is no user-level settings at the top level in config. /// This is a common source of mistake (user don't know where to write user-level setting). static void checkNoSettingNamesAtTopLevel(const Poco::Util::AbstractConfiguration & config, const String & config_path); [[nodiscard]] VectorWithMemoryTracking getAllRegisteredNames() const override; void set(std::string_view name, const Field & value) override; [[nodiscard]] bool hasSettingsChangedByCompatibility() const { return num_settings_changed_by_compatibility_setting != 0; } void resetSettingsChangedByCompatibility(); void resetSettingsChangedByCompatibility(const std::function & is_allowed); void markSettingsChangedByCompatibilityAsUnchanged(); private: void applyCompatibilitySetting(const String & compatibility); /// Which settings the compatibility setting changed, as a bitmap over setting indexes. An old /// `compatibility` value marks hundreds of them on every query that sets it, so a hash set of names /// meant a lookup per setting and an allocated node per setting, on top of copying them all whenever /// the settings are copied. The number of settings is known at compile time, so the bitmap lives in /// the settings themselves and never allocates. static constexpr size_t num_setting_bitmap_words = (static_cast(SettingsTraits::SettingID_::NUM_SETTINGS) + 63) / 64; std::array settings_changed_by_compatibility_setting = {}; size_t num_settings_changed_by_compatibility_setting = 0; [[nodiscard]] bool isChangedByCompatibility(size_t index) const { return (settings_changed_by_compatibility_setting[index / 64] & (1ULL << (index % 64))) != 0; } void markChangedByCompatibility(size_t index) { UInt64 & word = settings_changed_by_compatibility_setting[index / 64]; const UInt64 bit = 1ULL << (index % 64); if (!(word & bit)) { word |= bit; ++num_settings_changed_by_compatibility_setting; } } void unmarkChangedByCompatibility(size_t index) { UInt64 & word = settings_changed_by_compatibility_setting[index / 64]; const UInt64 bit = 1ULL << (index % 64); if (word & bit) { word &= ~bit; --num_settings_changed_by_compatibility_setting; } } }; /** Set the settings from the profile (in the server configuration, many settings can be listed in one profile). * The profile can also be set using the `set` functions, like the `profile` setting. */ void SettingsImpl::setProfile(const String & profile_name, const Poco::Util::AbstractConfiguration & config) { String elem = "profiles." + profile_name; if (!config.has(elem)) throw Exception(ErrorCodes::THERE_IS_NO_PROFILE, "There is no profile '{}' in configuration file.", profile_name); Poco::Util::AbstractConfiguration::Keys config_keys; config.keys(elem, config_keys); for (const std::string & key : config_keys) { if (key == "constraints") continue; if (key == "profile" || key.starts_with("profile[")) /// Inheritance of profiles from the current one. setProfile(config.getString(elem + "." + key), config); else set(key, config.getString(elem + "." + key)); } } void SettingsImpl::loadSettingsFromConfig(const String & path, const Poco::Util::AbstractConfiguration & config) { if (!config.has(path)) throw Exception(ErrorCodes::NO_ELEMENTS_IN_CONFIG, "There is no path '{}' in configuration file.", path); Poco::Util::AbstractConfiguration::Keys config_keys; config.keys(path, config_keys); for (const std::string & key : config_keys) { set(key, config.getString(path + "." + key)); } } void SettingsImpl::dumpToMapColumn(IColumn * column, bool changed_only, bool show_secrets) { if (!column) return; auto & column_map = typeid_cast(*column); auto & offsets = column_map.getNestedColumn().getOffsets(); auto & tuple_column = column_map.getNestedData(); auto & key_column = typeid_cast(tuple_column.getColumn(0)); auto & value_column = typeid_cast(tuple_column.getColumn(1)); size_t size = 0; /// Iterate over standard settings const auto & accessor = Traits::Accessor::instance(); for (size_t i = 0; i < accessor.size(); i++) { if (changed_only && !accessor.isValueChanged(*this, i)) continue; const auto & name = accessor.getName(i); auto value = accessor.getValueString(*this, i); if (!show_secrets) CoreSettings::maskSettingValue(String(name), value); key_column.insertData(name.data(), name.size()); value_column.insertData(value.data(), value.size()); ++size; } /// Iterate over the custom settings for (const auto & custom : custom_settings_map) { const auto & setting_field = custom.second; if (changed_only && !setting_field.changed) continue; const auto & name = custom.first; auto value = setting_field.toString(show_secrets); if (!show_secrets) CoreSettings::maskSettingValue(name, value); key_column.insertData(name.data(), name.size()); value_column.insertData(value.data(), value.size()); ++size; } offsets.push_back(offsets.back() + size); } FlatStringMap SettingsImpl::changedToFlatMap(bool show_secrets) const { FlatStringMap result; /// What makes this dump large is an old `compatibility` value, and how many settings that changed /// is already known, so the buffer can be sized up front instead of growing a dozen times. A name /// and its value take 38 bytes on average. const size_t expected_entries = num_settings_changed_by_compatibility_setting + 32; result.reserve(expected_entries, expected_entries * 48); const auto & accessor = Traits::Accessor::instance(); const size_t num_settings = accessor.size(); for (size_t i = 0; i < num_settings; ++i) { if (!accessor.isValueChanged(*this, i)) continue; const auto & name = accessor.getName(i); auto value = accessor.getValueString(*this, i); if (!show_secrets) CoreSettings::maskSettingValue(String(name), value); result.add(name, value); } for (const auto & custom : custom_settings_map) { if (!custom.second.changed) continue; auto value = custom.second.toString(show_secrets); if (!show_secrets) CoreSettings::maskSettingValue(custom.first, value); result.add(custom.first, value); } return result; } void SettingsImpl::checkNoSettingNamesAtTopLevel(const Poco::Util::AbstractConfiguration & config, const String & config_path) { if (config.getBool("skip_check_for_incorrect_settings", false)) return; SettingsImpl settings; for (const auto & setting : settings.all()) { const auto & name = setting.getName(); /// Some setting names collide with long-standing top-level config sections. /// `compression` is a top-level config block describing default codec selection rules /// (see `CompressionCodecSelector`). bool should_skip_check = name == "max_table_size_to_drop" || name == "max_partition_size_to_drop" || name == "compression"; if (config.has(name) && (setting.getTier() != SettingsTierType::OBSOLETE) && !should_skip_check) { throw Exception(ErrorCodes::UNKNOWN_ELEMENT_IN_CONFIG, "A setting '{}' appeared at top level in config {}." " But it is user-level setting that should be located in users.xml inside section for specific profile." " You can add it to if you want to change default value of this setting." " You can also disable the check - specify 1" " in the main configuration file.", name, config_path); } } } VectorWithMemoryTracking SettingsImpl::getAllRegisteredNames() const { VectorWithMemoryTracking all_settings; for (const auto & setting_field : all()) all_settings.push_back(setting_field.getName()); return all_settings; } void SettingsImpl::set(std::string_view name, const Field & value) { #if defined(MEMORY_SANITIZER) if (name == "query_profiler_real_time_period_ns" || name == "query_profiler_cpu_time_period_ns") { if (BaseSettings::castValueUtil(name, value).safeGet() != 0) { throw Exception( ErrorCodes::NOT_IMPLEMENTED, "The setting `{}` is not supported in a MemorySanitizer build", name); } } #endif if (name == "compatibility") { if (value.getType() != Field::Types::Which::String) throw Exception(ErrorCodes::BAD_ARGUMENTS, "Unexpected type of value for setting 'compatibility'. Expected String, got {}", value.getTypeName()); applyCompatibilitySetting(value.safeGet()); } /// If we change setting that was changed by compatibility setting before /// we should remove it from settings_changed_by_compatibility_setting, /// otherwise the next time we will change compatibility setting /// this setting will be changed too (and we don't want it). /// Resolve aliases so the lookup matches the canonical names stored in the set. else if (num_settings_changed_by_compatibility_setting != 0) { const auto & accessor = Traits::Accessor::instance(); if (size_t index = accessor.find(SettingsTraits::resolveName(name)); index != static_cast(-1)) unmarkChangedByCompatibility(index); } BaseSettings::set(name, value); } void SettingsImpl::resetSettingsChangedByCompatibility() { if (num_settings_changed_by_compatibility_setting == 0) return; const auto & accessor = Traits::Accessor::instance(); for (size_t word = 0; word < num_setting_bitmap_words; ++word) { UInt64 bits = std::exchange(settings_changed_by_compatibility_setting[word], 0); while (bits) { accessor.resetValueToDefault(*this, word * 64 + std::countr_zero(bits)); bits &= bits - 1; } } num_settings_changed_by_compatibility_setting = 0; } void SettingsImpl::resetSettingsChangedByCompatibility(const std::function & is_allowed) { const auto & accessor = Traits::Accessor::instance(); for (size_t word = 0; word < num_setting_bitmap_words; ++word) { UInt64 bits = settings_changed_by_compatibility_setting[word]; while (bits) { const size_t index = word * 64 + std::countr_zero(bits); bits &= bits - 1; if (is_allowed(accessor.getName(index), accessor.getValue(*this, index))) continue; accessor.resetValueToDefault(*this, index); unmarkChangedByCompatibility(index); } } } const VersionToSettingsChangesMap & getSettingsChangesHistory() { static const VersionToSettingsChangesMap history = [] { using CompatibilitySetting [[maybe_unused]] = SettingsChangesHistory::SettingChange::CompatibilitySetting; VersionToSettingsChangesMap result; /// One non-inlined lambda per setting: the records of all settings in one frame exceed the frame size /// limit on targets where the stack slots of the temporary arrays are not reused (wasm64). #define SETTING_HISTORY_(TYPE, NAME, DEFAULT, DESCRIPTION, FLAGS, ...) \ __VA_OPT__([&]() __attribute__((noinline)) { addSettingChangesHistory(result, #NAME, {__VA_ARGS__}); }();) #define SETTING_HISTORY_WITH_ALIAS_(TYPE, NAME, DEFAULT, DESCRIPTION, FLAGS, ALIAS, ...) \ __VA_OPT__([&]() __attribute__((noinline)) { addSettingChangesHistory(result, #NAME, {__VA_ARGS__}); }();) LIST_OF_SETTINGS(SETTING_HISTORY_, SETTING_HISTORY_WITH_ALIAS_) #undef SETTING_HISTORY_ #undef SETTING_HISTORY_WITH_ALIAS_ return result; }(); return history; } namespace { /// A change from the settings changes history with its name already resolved to a setting index. /// Applying a `compatibility` value walks the whole history - thousands of changes for an old value, /// on every query that sets it - so the names are resolved once and the obsolete settings, which the /// walk always skips, are left out. `previous_value` points into the history, which is immutable and /// lives until the process ends. struct ResolvedCompatibilityChange { size_t index; const Field * previous_value; /// Whether `previous_value` is what the setting holds when nothing changed it. bool previous_value_is_default; SettingsChangesHistory::SettingChange::CompatibilitySetting compatibility_mode; }; using ResolvedCompatibilityHistory = std::vector>>; const ResolvedCompatibilityHistory & getResolvedCompatibilityHistory() { static const ResolvedCompatibilityHistory resolved_history = [] { const auto & accessor = SettingsTraits::Accessor::instance(); const SettingsImpl default_settings; ResolvedCompatibilityHistory result; for (const auto & [version, changes] : getSettingsChangesHistory()) { std::vector resolved_changes; resolved_changes.reserve(changes.size()); for (const auto & change : changes) { /// In case the alias is being used (e.g. use enable_analyzer) we must change the original setting const size_t index = accessor.find(SettingsTraits::resolveName(change.name)); if (index == static_cast(-1)) BaseSettingsHelpers::throwSettingNotFound(change.name); if (accessor.getTier(index) == SettingsTierType::OBSOLETE) continue; /// `default_settings` holds every setting as it is with nothing changed, which is what /// a setting the walk has not touched yet holds too. const bool previous_value_is_default = accessor.getValue(default_settings, index) == change.previous_value; resolved_changes.push_back({index, &change.previous_value, previous_value_is_default, change.compatibility_mode}); } result.emplace_back(version, std::move(resolved_changes)); } return result; }(); return resolved_history; } } void SettingsImpl::markSettingsChangedByCompatibilityAsUnchanged() { if (num_settings_changed_by_compatibility_setting == 0) return; const auto & accessor = Traits::Accessor::instance(); for (size_t word = 0; word < num_setting_bitmap_words; ++word) { UInt64 bits = std::exchange(settings_changed_by_compatibility_setting[word], 0); while (bits) { accessor.setValueChanged(*this, word * 64 + std::countr_zero(bits), false); bits &= bits - 1; } } num_settings_changed_by_compatibility_setting = 0; } void SettingsImpl::applyCompatibilitySetting(const String & compatibility_value) { /// First, revert all changes applied by previous compatibility setting resetSettingsChangedByCompatibility(); /// If setting value is empty, we don't need to change settings if (compatibility_value.empty()) return; ClickHouseVersion version(compatibility_value); const auto & accessor = Traits::Accessor::instance(); const auto & resolved_history = getResolvedCompatibilityHistory(); /// Keep blockers across versions to skip earlier changes to the same setting. std::bitset(SettingsTraits::SettingID_::NUM_SETTINGS)> blocked_settings; /// Iterate through ClickHouse version in descending order and apply reversed /// changes for each version that is higher that version from compatibility setting for (auto it = resolved_history.rbegin(); it != resolved_history.rend(); ++it) { if (version >= it->first) break; /// Apply reversed changes from this version. for (const auto & change : it->second) { if (change.compatibility_mode == SettingsChangesHistory::SettingChange::CompatibilitySetting::Ignore) blocked_settings.set(change.index); if (blocked_settings[change.index]) continue; const bool changed_by_compatibility = isChangedByCompatibility(change.index); /// If this setting was changed manually, we don't change it if (!changed_by_compatibility && accessor.isValueChanged(*this, change.index)) continue; /// Don't mark as changed if the value isn't really changed. Only a setting a newer change /// already moved has to be read to know that; an untouched one still holds its default, and /// whether that is the previous value is known from the history alone. const bool already_has_previous_value = changed_by_compatibility ? accessor.getValue(*this, change.index) == *change.previous_value : change.previous_value_is_default; if (already_has_previous_value) continue; accessor.setValue(*this, change.index, *change.previous_value); markChangedByCompatibility(change.index); } } } IMPLEMENT_SETTINGS_TRAITS_CUSTOM_IMPL(SettingsTraits, LIST_OF_SETTINGS, Settings, Setting) Settings::Settings() : impl(std::make_unique()) {} Settings::Settings(const Settings & settings) : impl(std::make_unique(*settings.impl)) {} Settings::Settings(Settings && settings) noexcept = default; Settings::~Settings() = default; Settings & Settings::operator=(const Settings & other) { if (&other == this) return *this; *impl = *other.impl; return *this; } bool Settings::operator==(const Settings & other) const { return *impl == *other.impl; } COMMON_SETTINGS_SUPPORTED_TYPES(Settings, IMPLEMENT_SETTING_SUBSCRIPT_OPERATOR) bool Settings::has(std::string_view name) const { return impl->has(name); } bool Settings::isChanged(std::string_view name) const { return impl->isChanged(name); } SettingsTierType Settings::getTier(std::string_view name) const { return impl->getTier(name); } std::string_view Settings::getDescription(std::string_view name) const { return impl->getDescription(name); } std::string_view Settings::getTypeName(std::string_view name) const { return impl->getTypeName(name); } String Settings::getDefaultValueString(std::string_view name) const { return impl->getDefaultValueString(name); } bool Settings::tryGet(std::string_view name, Field & value) const { return impl->tryGet(name, value); } Field Settings::get(std::string_view name) const { return impl->get(name); } void Settings::set(std::string_view name, const Field & value) { impl->set(name, value); } void Settings::setCustom(std::string_view name, const Field & value) { impl->setCustom(name, value); } void Settings::setDefaultValue(std::string_view name) { impl->resetToDefault(name); } bool Settings::hasSettingsChangedByCompatibility() const { return impl->hasSettingsChangedByCompatibility(); } void Settings::resetSettingsChangedByCompatibility() { impl->resetSettingsChangedByCompatibility(); } void Settings::resetSettingsChangedByCompatibility(const std::function & is_allowed) { impl->resetSettingsChangedByCompatibility(is_allowed); } void Settings::markSettingsChangedByCompatibilityAsUnchanged() { impl->markSettingsChangedByCompatibilityAsUnchanged(); } VectorWithMemoryTracking Settings::getHints(const String & name) const { return impl->getHints(name); } String Settings::toString(bool show_secrets) const { if (show_secrets) return impl->toString(); /// Same rendering as `BaseSettings::toString`, with the secrets masked. WriteBufferFromOwnString out; bool first = true; for (const auto & setting : impl->allChanged()) { if (!first) out << ", "; auto masked = CoreSettings::renderSecretSettingValue(String(setting.getName()), setting.getValue()); out << setting.getName() << " = " << (masked ? *masked : applyVisitor(FieldVisitorToString(), setting.getValue())); first = false; } return out.str(); } SettingsChanges Settings::changes() const { return impl->changes(); } void Settings::applyChanges(const SettingsChanges & changes) { impl->applyChanges(changes); } void Settings::checkShorthandChange(const SettingChange & change) const { impl->checkShorthandChange(change); } void Settings::checkShorthandChanges(const SettingsChanges & changes) const { impl->checkShorthandChanges(changes); } VectorWithMemoryTracking Settings::getAllRegisteredNames() const { VectorWithMemoryTracking setting_names; for (const auto & setting : impl->all()) { setting_names.emplace_back(setting.getName()); } return setting_names; } VectorWithMemoryTracking Settings::getAllAliasNames() const { VectorWithMemoryTracking alias_names; const auto & settings_to_aliases = SettingsImpl::Traits::settingsToAliases(); for (const auto & [_, aliases] : settings_to_aliases) { alias_names.insert(alias_names.end(), aliases.begin(), aliases.end()); } return alias_names; } VectorWithMemoryTracking Settings::getChangedAndObsoleteNames() const { VectorWithMemoryTracking setting_names; for (const auto & setting : impl->allChanged()) { if (setting.getTier() == SettingsTierType::OBSOLETE) setting_names.emplace_back(setting.getName()); } return setting_names; } VectorWithMemoryTracking Settings::getUnchangedNames() const { VectorWithMemoryTracking setting_names; for (const auto & setting : impl->allUnchanged()) { setting_names.emplace_back(setting.getName()); } return setting_names; } void Settings::dumpToSystemSettingsColumns(MutableColumnsAndConstraints & params, bool show_secrets) const { MutableColumns & res_columns = params.res_columns; /// `setting_name` may be an alias, so the masking always keys off the canonical name. const auto mask = [&](const auto & setting, String & value) { if (!show_secrets) CoreSettings::maskSettingValue(String(setting.getName()), value); }; /// For a constraint, whose raw `Field` is at hand: the value of a custom setting can be an AST /// that no plain `Field` formatter hides. const auto mask_field = [&](const auto & setting, const Field & field, String & value) { if (!show_secrets) CoreSettings::maskSettingValue(String(setting.getName()), field, value); }; const auto fill_data_for_setting = [&](std::string_view setting_name, const auto & setting) { String value = setting.getValueString(show_secrets); mask(setting, value); res_columns[1]->insert(value); res_columns[2]->insert(setting.isValueChanged()); /// Trim starting/ending newline. std::string_view doc = setting.getDescription(); if (!doc.empty() && doc[0] == '\n') doc = doc.substr(1); if (!doc.empty() && doc[doc.length() - 1] == '\n') doc = doc.substr(0, doc.length() - 1); res_columns[3]->insert(doc); Field min; Field max; std::vector disallowed_values; SettingConstraintWritability writability = SettingConstraintWritability::WRITABLE; params.constraints.get(*this, setting_name, min, max, disallowed_values, writability); /// These two columns can accept strings only. if (!min.isNull()) { String min_string = Settings::valueToStringUtil(setting_name, min); mask_field(setting, min, min_string); min = min_string; } if (!max.isNull()) { String max_string = Settings::valueToStringUtil(setting_name, max); mask_field(setting, max, max_string); max = max_string; } Array disallowed_array; for (const auto & disallowed_value : disallowed_values) { String disallowed_string = Settings::valueToStringUtil(setting_name, disallowed_value); mask_field(setting, disallowed_value, disallowed_string); disallowed_array.emplace_back(disallowed_string); } res_columns[4]->insert(min); res_columns[5]->insert(max); res_columns[6]->insert(disallowed_array); res_columns[7]->insert(writability == SettingConstraintWritability::CONST); res_columns[8]->insert(setting.getTypeName()); String default_value = setting.getDefaultValueString(show_secrets); mask(setting, default_value); res_columns[9]->insert(default_value); res_columns[11]->insert(setting.getTier() == SettingsTierType::OBSOLETE); res_columns[12]->insert(setting.getTier()); }; const auto & settings_to_aliases = SettingsImpl::Traits::settingsToAliases(); for (const auto & setting : impl->all()) { const auto & setting_name = setting.getName(); res_columns[0]->insert(setting_name); fill_data_for_setting(setting_name, setting); res_columns[10]->insert(""); if (auto it = settings_to_aliases.find(setting_name); it != settings_to_aliases.end()) { for (const auto alias : it->second) { res_columns[0]->insert(alias); fill_data_for_setting(alias, setting); res_columns[10]->insert(setting_name); } } } } void Settings::dumpToMapColumn(IColumn * column, bool changed_only, bool show_secrets) const { impl->dumpToMapColumn(column, changed_only, show_secrets); } FlatStringMap Settings::changedToFlatMap(bool show_secrets) const { return impl->changedToFlatMap(show_secrets); } void writeQueryParameters(const NameToNameMap & parameters, WriteBuffer & out) { /// Query parameters are user-chosen names, not settings. Each is written as a custom /// (string-valued) field so a parameter whose name collides with a built-in setting /// (e.g. `format` / `database` / `filter` / `select` / `page`) is not parsed as that setting's /// type. `readQueryParameters` reads them back and SQL-unquotes each value. for (const auto & [name, value] : parameters) { BaseSettingsHelpers::writeString(name, out); BaseSettingsHelpers::writeFlags(BaseSettingsHelpers::Flags::CUSTOM, out); BaseSettingsHelpers::writeString(SettingFieldCustom(Field(value)).toString(), out); } BaseSettingsHelpers::writeString(std::string_view{}, out); } NameToNameMap readQueryParameters(ReadBuffer & in) { NameToNameMap parameters; size_t num_parameters = 0; while (true) { String name = BaseSettingsHelpers::readName(in); if (name.empty()) break; if (++num_parameters > MAX_SETTINGS_IN_A_SEQUENCE) BaseSettingsHelpers::throwTooManySettings("query parameters"); std::ignore = BaseSettingsHelpers::readFlags(in); String value; ReadBufferFromOwnString buf(BaseSettingsHelpers::readString(in)); readQuoted(value, buf); parameters.insert_or_assign(std::move(name), std::move(value)); } return parameters; } void Settings::write(WriteBuffer & out) const { impl->write(out); } void Settings::read(ReadBuffer & in, bool skip_invalid_values) { impl->read(in, skip_invalid_values); } void Settings::writeEmpty(WriteBuffer & out) { BaseSettingsHelpers::writeString("", out); } void Settings::addToProgramOptions(boost::program_options::options_description & options) { /// A few settings share a name with a client-side CLI option that's already registered (e.g. /// `--database` / `-d` declared by `clickhouse-client` so the short alias appears in /// `--help` next to the other main options). Skip the setting registration when the option /// name is already taken — the client-side declaration is canonical for boost's parser, and /// `ClientBase::addOptionsToTheClientConfiguration` copies the value into `cmd_settings` /// after parsing so the setting still takes effect per query. std::unordered_set existing; existing.reserve(options.options().size()); for (const auto & option : options.options()) existing.insert(option->long_name()); const auto & settings_to_aliases = SettingsImpl::Traits::settingsToAliases(); for (const auto & field : impl->all()) { std::string_view name = field.getName(); if (!existing.contains(std::string(name))) addProgramOption(*impl, options, name, field); if (auto it = settings_to_aliases.find(name); it != settings_to_aliases.end()) { for (const auto alias : it->second) { if (!existing.contains(std::string(alias))) addProgramOption(*impl, options, alias, field); } } } } void Settings::addToProgramOptions(std::string_view setting_name, boost::program_options::options_description & options) { const auto & accessor = SettingsImpl::Traits::Accessor::instance(); size_t index = accessor.find(setting_name); chassert(index != static_cast(-1)); auto on_program_option = boost::function1( [this, setting_name](const std::string & value) { this->set(setting_name, value); }); options.add(boost::shared_ptr(new boost::program_options::option_description( setting_name.data(), boost::program_options::value()->composing()->notifier(on_program_option), accessor.getDescription(index).data()))); // NOLINT } void Settings::addToProgramOptionsAsMultitokens(boost::program_options::options_description & options) const { /// Same duplicate-skip strategy as `Settings::addToProgramOptions` — see the comment there. std::unordered_set existing; existing.reserve(options.options().size()); for (const auto & option : options.options()) existing.insert(option->long_name()); const auto & settings_to_aliases = SettingsImpl::Traits::settingsToAliases(); for (const auto & field : impl->all()) { std::string_view name = field.getName(); if (!existing.contains(std::string(name))) addProgramOptionAsMultitoken(*impl, options, name, field); if (auto it = settings_to_aliases.find(name); it != settings_to_aliases.end()) { for (const auto alias : it->second) { if (!existing.contains(std::string(alias))) addProgramOptionAsMultitoken(*impl, options, alias, field); } } } } void Settings::addToClientOptions(Poco::Util::LayeredConfiguration &config, const boost::program_options::variables_map &options, bool repeated_settings) const { for (const auto & setting : impl->all()) { const auto & name = setting.getName(); if (!options.contains(name)) continue; try { if (repeated_settings) config.setString(name, options[name].as().back()); else config.setString(name, options[name].as()); } catch (const boost::bad_any_cast &) // NOLINT(bugprone-empty-catch) { /// Ok: the setting and a client-side command-line option share a name but use different /// `boost::program_options` value types (e.g. the client owns `--database`). The /// duplicate-skip in `addToProgramOptions[AsMultitokens]` already declined to add the /// setting variant, so reading the value here as the setting's type would also fail. } } } Field Settings::castValueUtil(std::string_view name, const Field & value) { return SettingsImpl::castValueUtil(name, value); } String Settings::valueToStringUtil(std::string_view name, const Field & value) { return SettingsImpl::valueToStringUtil(name, value); } Field Settings::stringToValueUtil(std::string_view name, const String & str) { return SettingsImpl::stringToValueUtil(name, str); } bool Settings::hasBuiltin(std::string_view name) { return SettingsImpl::hasBuiltin(name); } std::optional Settings::tryGetTierOfBuiltin(std::string_view name) { return SettingsImpl::tryGetTierOfBuiltin(name); } std::string_view Settings::resolveName(std::string_view name) { return SettingsImpl::Traits::resolveName(name); } void Settings::checkNoSettingNamesAtTopLevel(const Poco::Util::AbstractConfiguration & config, const String & config_path) { SettingsImpl::checkNoSettingNamesAtTopLevel(config, config_path); } }