> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-trino-dialect.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Other session settings

> ClickHouse session settings in the Other generated group.

export const CloudOnlyBadge = () => {
  return <div className="cloudBadge">
            <div className="cloudIcon">
            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path fillRule="evenodd" clipRule="evenodd" d="M5.33395 12.6667H12.3739C13.6593 12.6667 14.7073 11.6187 14.7073 10.3334C14.7073 9.04804 13.6593 8.00004 12.3739 8.00004H12.0839V7.33337C12.0839 5.12671 10.2906 3.33337 8.08395 3.33337C6.09928 3.33337 4.45395 4.78537 4.14195 6.68204C2.55728 6.76271 1.29395 8.06204 1.29395 9.66671C1.29395 11.3234 2.63728 12.6667 4.29395 12.6667H5.33395Z" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
            </svg>
        </div>
            {'ClickHouse Cloud only'}
        </div>;
};

export const BetaBadge = ({link, galaxyTrack, galaxyEvent}) => {
  if (link) {
    return <a href={link} target="_blank" rel="noopener noreferrer" className="betaBadge" onClick={galaxyTrack && galaxyEvent ? galaxyOnClick(galaxyEvent) : undefined}>
                <span>Beta</span>
            </a>;
  }
  return <a href="https://clickhouse.com/docs/reference/settings/beta-and-experimental-features#beta-features" className="betaBadge">
            <span>Beta feature</span>
        </a>;
};

export const ExperimentalBadge = () => {
  return <a href="https://clickhouse.com/docs/reference/settings/beta-and-experimental-features#experimental-features" className="experimentalBadge">
            <div className="experimentalIcon">
            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path strokeWidth="1.25" d="M5.5 2H10.5" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
                <path strokeWidth="1.25" d="M9.50015 2V6.19625L13.4283 12.7425C13.4738 12.8183 13.4985 12.9049 13.4996 12.9934C13.5008 13.0818 13.4785 13.169 13.435 13.246C13.3914 13.323 13.3283 13.3871 13.2519 13.4317C13.1755 13.4764 13.0886 13.4999 13.0002 13.5H3.00015C2.91164 13.5 2.8247 13.4766 2.74822 13.432C2.67174 13.3874 2.60847 13.3233 2.56487 13.2463C2.52126 13.1693 2.49889 13.082 2.50004 12.9935C2.50119 12.905 2.52582 12.8184 2.5714 12.7425L6.50015 6.19625V2" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
                <path strokeWidth="1.25" d="M4.47656 9.56754C5.30344 9.41254 6.47656 9.47942 7.99969 10.25C10.0153 11.2707 11.4216 11.0569 12.2184 10.7282" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
            </svg>
        </div>
            Experimental feature
        </a>;
};

export const VersionHistory = ({rows = []}) => {
  if (rows.length === 0) {
    return null;
  }
  const headers = ["Version", "Default value", "Comment"];
  const border = "1px solid rgba(128, 128, 128, 0.3)";
  const cell = {
    border,
    padding: "0.25rem 0.5rem",
    textAlign: "start",
    verticalAlign: "top"
  };
  return <details className="not-prose" style={{
    border,
    borderRadius: "0.5rem",
    margin: "0.5rem 0",
    padding: "0.5rem 0.75rem",
    fontSize: "0.8125rem",
    lineHeight: "1.125rem"
  }}>
      <summary style={{
    cursor: "pointer",
    fontWeight: 600,
    opacity: 0.72
  }}>
        Version history
      </summary>
      <table style={{
    borderCollapse: "collapse",
    width: "100%",
    margin: "0.5rem 0 0"
  }}>
        <thead>
          <tr>
            {headers.map(header => <th key={header} style={{
    ...cell,
    fontWeight: 600,
    opacity: 0.72
  }}>
                {header}
              </th>)}
          </tr>
        </thead>
        <tbody>
          {rows.map((row, row_index) => <tr key={row.id ?? row_index}>
              {(row.items ?? []).map((item, item_index) => <td key={item_index} style={{
    ...cell,
    overflowWrap: "anywhere"
  }}>
                  {item?.label}
                </td>)}
            </tr>)}
        </tbody>
      </table>
    </details>;
};

export const SettingsInfoBlock = ({type, default_value, changeable_without_restart}) => {
  return <div className="not-prose" style={{
    display: "flex",
    flexWrap: "wrap",
    alignItems: "baseline",
    columnGap: "0.5rem",
    rowGap: "0.125rem",
    margin: "0.375rem 0",
    fontSize: "0.8125rem",
    lineHeight: "1.125rem"
  }}>
      <div style={{
    fontWeight: 600,
    opacity: 0.72
  }}>Type</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{type}</div>
      <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>Default</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{default_value}</div>
      {changeable_without_restart && <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>
          Changeable without restart
        </div>}
      {changeable_without_restart && <div style={{
    overflowWrap: "anywhere"
  }}>
          {changeable_without_restart}
        </div>}
    </div>;
};

These settings are available in [system.settings](/reference/system-tables/settings) and are autogenerated from [source](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp).

<h2 id="adaptive_aggregator_freeze_threshold">
  adaptive\_aggregator\_freeze\_threshold
</h2>

<SettingsInfoBlock type="UInt64" default_value="16384" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": "16384"},{"label": "New setting to set the number of keys at which the adaptive aggregator (`enable_adaptive_aggregator`) freezes a thread's local hash table."}]}]} />

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 similarly to the sharded aggregator (`enable_sharding_aggregator`): 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.

<h2 id="adaptive_aggregator_freeze_threshold_bytes">
  adaptive\_aggregator\_freeze\_threshold\_bytes
</h2>

<SettingsInfoBlock type="UInt64" default_value="4194304" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.9"},{"label": "4194304"},{"label": "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."}]}]} />

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 own allocated bytes (its hash-table buffer plus its arenas), checked between blocks. The byte bound matters when the keys or the aggregation states are wide: the key-count threshold alone would let such tables outgrow the CPU caches. At the default, tables of ordinary key and state widths keep freezing by the key count. 0 disables the byte bound, so the key-count threshold alone decides.

<h2 id="add_http_cors_header">
  add\_http\_cors\_header
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

Write add http CORS header.

<h2 id="analyze_index_with_space_filling_curves">
  analyze\_index\_with\_space\_filling\_curves
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

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.

<h2 id="analyzer_inline_views">
  analyzer\_inline\_views
</h2>

<ExperimentalBadge />

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.4"},{"label": "0"},{"label": "New setting"}]}]} />

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.

<h2 id="any_join_distinct_right_table_keys">
  any\_join\_distinct\_right\_table\_keys
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "19.14"},{"label": "0"},{"label": "Disable ANY RIGHT and ANY FULL JOINs by default to avoid inconsistency"}]}]} />

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

<Note>
  Use this setting only for backward compatibility if your use cases depend on legacy `JOIN` behaviour.
</Note>

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)

<h2 id="archive_adaptive_buffer_max_size_bytes">
  archive\_adaptive\_buffer\_max\_size\_bytes
</h2>

<SettingsInfoBlock type="UInt64" default_value="8388608" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.1"},{"label": "8388608"},{"label": "New setting"}]}]} />

Limits the maximum size of the adaptive buffer used when writing to archive files (for example, tar archives

<h2 id="arrow_flight_request_descriptor_type">
  arrow\_flight\_request\_descriptor\_type
</h2>

<SettingsInfoBlock type="ArrowFlightDescriptorType" default_value="path" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.11"},{"label": "path"},{"label": "New setting. Type of descriptor to use for Arrow Flight requests: 'path' or 'command'. Dremio requires 'command'."}]}]} />

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)

<h2 id="backup_slow_all_threads_after_retryable_s3_error">
  backup\_slow\_all\_threads\_after\_retryable\_s3\_error
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.8"},{"label": "0"},{"label": "New setting"}]}, {"id": "row-2","items": [{"label": "25.6"},{"label": "0"},{"label": "New setting"}]}, {"id": "row-3","items": [{"label": "25.10"},{"label": "0"},{"label": "Disable the setting by default"}]}]} />

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.

<h2 id="cache_warmer_threads">
  cache\_warmer\_threads
</h2>

<CloudOnlyBadge />

<SettingsInfoBlock type="UInt64" default_value="4" />

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.

<h2 id="calculate_text_stack_trace">
  calculate\_text\_stack\_trace
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

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.

<h2 id="cancel_http_readonly_queries_on_client_close">
  cancel\_http\_readonly\_queries\_on\_client\_close
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

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

Cloud default value: `1`.

<h2 id="checksum_on_read">
  checksum\_on\_read
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

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.

<h2 id="compression">
  compression
</h2>

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": ""},{"label": "New setting to apply generic compression to the response body."}]}]} />

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). Specifying a compressed file extension in the URL path is equivalent.

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).

<h2 id="connection_pool_max_wait_ms">
  connection\_pool\_max\_wait\_ms
</h2>

<SettingsInfoBlock type="Milliseconds" default_value="0" />

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

Possible values:

* Positive integer.
* 0 — Infinite timeout.

<h2 id="connections_with_failover_max_tries">
  connections\_with\_failover\_max\_tries
</h2>

<SettingsInfoBlock type="UInt64" default_value="3" />

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

<h2 id="convert_query_to_cnf">
  convert\_query\_to\_cnf
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

When set to `true`, a `SELECT` query will be converted to conjuctive 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 theme={null}
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 theme={null}
┌─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 theme={null}
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 theme={null}
┌─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

<h2 id="count_matches_stop_at_empty_match">
  count\_matches\_stop\_at\_empty\_match
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.6"},{"label": "0"},{"label": "New setting."}]}]} />

Stop counting once a pattern matches zero-length in the `countMatches` function.

<h2 id="cross_to_inner_join_rewrite">
  cross\_to\_inner\_join\_rewrite
</h2>

<SettingsInfoBlock type="UInt64" default_value="1" />

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

<h2 id="data_type_default_nullable">
  data\_type\_default\_nullable
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

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).

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.

<h2 id="decimal_check_overflow">
  decimal\_check\_overflow
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

Check overflow of decimal arithmetic/comparison operations

<h2 id="deduplicate_blocks_in_dependent_materialized_views">
  deduplicate\_blocks\_in\_dependent\_materialized\_views
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.2"},{"label": "1"},{"label": "Enable deduplication for dependent materialized views by default."}]}]} />

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)

<h2 id="defer_partition_pruning_after_final">
  defer\_partition\_pruning\_after\_final
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.5"},{"label": "1"},{"label": "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."}]}, {"id": "row-2","items": [{"label": "26.3"},{"label": "1"},{"label": "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)."}]}]} />

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).

<h2 id="describe_compact_output">
  describe\_compact\_output
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

If true, include only column names and types into result of DESCRIBE query

<h2 id="dialect">
  dialect
</h2>

<SettingsInfoBlock type="Dialect" default_value="clickhouse" />

Which dialect will be used to parse query.

Supported values:

* `clickhouse` (default) — standard ClickHouse SQL.
* `kusto` — Kusto Query Language. Requires the experimental setting `allow_experimental_kusto_dialect`.
* `prql` — PRQL. Requires the experimental setting `allow_experimental_prql_dialect`.
* `polyglot` — transpiles SQL from other dialects (MySQL, PostgreSQL, etc.) into ClickHouse SQL. Requires the experimental setting `allow_experimental_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`.

<h2 id="discard_query_data">
  discard\_query\_data
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.7"},{"label": "0"},{"label": "New setting to skip sending query result rows to the client over the native TCP protocol."}]}]} />

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.

<h2 id="distinct_overflow_mode">
  distinct\_overflow\_mode
</h2>

<SettingsInfoBlock type="OverflowMode" default_value="throw" />

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.

<h2 id="do_not_merge_across_partitions_select_final">
  do\_not\_merge\_across\_partitions\_select\_final
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

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.

<h2 id="dynamic_throw_on_type_mismatch">
  dynamic\_throw\_on\_type\_mismatch
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.4"},{"label": "1"},{"label": "New setting to control type mismatch behavior in default Dynamic implementation"}]}]} />

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.

<h2 id="enforce_strict_identifier_format">
  enforce\_strict\_identifier\_format
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.10"},{"label": "0"},{"label": "New setting."}]}]} />

If enabled, only allow identifiers containing alphanumeric characters and underscores.

<h2 id="engine_url_skip_empty_files">
  engine\_url\_skip\_empty\_files
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

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.

<h2 id="exact_rows_before_limit">
  exact\_rows\_before\_limit
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

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

<h2 id="except_default_mode">
  except\_default\_mode
</h2>

<SettingsInfoBlock type="SetOperationMode" default_value="ALL" />

Set default mode in EXCEPT query. Possible values: empty string, 'ALL', 'DISTINCT'. If empty, query without mode will throw exception.

<h2 id="exclude_materialize_skip_indexes_on_insert">
  exclude\_materialize\_skip\_indexes\_on\_insert
</h2>

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.10"},{"label": ""},{"label": "New setting."}]}]} />

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](/reference/settings/session-settings/materialize#materialize_skip_indexes_on_insert) is false.

Example:

```sql theme={null}
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
```

<h2 id="execute_exists_as_scalar_subquery">
  execute\_exists\_as\_scalar\_subquery
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.8"},{"label": "1"},{"label": "New setting"}]}]} />

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`.

<h2 id="explain_query_plan_default">
  explain\_query\_plan\_default
</h2>

<SettingsInfoBlock type="ExplainQueryPlanDefault" default_value="pretty" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.7"},{"label": "pretty"},{"label": "From 26.7, `EXPLAIN PLAN` defaults to `actions=1, compact=1, pretty=1`. Set this to `legacy` to restore the pre-26.7 output."}]}]} />

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.

<h2 id="explain_syntax_single_record">
  explain\_syntax\_single\_record
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": "1"},{"label": "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."}]}]} />

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`.

<h2 id="extract_key_value_pairs_max_pairs_per_row">
  extract\_key\_value\_pairs\_max\_pairs\_per\_row
</h2>

**Aliases**: `extract_kvp_max_pairs_per_row`

<SettingsInfoBlock type="UInt64" default_value="1000" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.2"},{"label": "1000"},{"label": "Max number of pairs that can be produced by the `extractKeyValuePairs` function. Used as a safeguard against consuming too much memory."}]}]} />

Max number of pairs that can be produced by the `extractKeyValuePairs` function. Used as a safeguard against consuming too much memory.

<h2 id="extremes">
  extremes
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

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".

<h2 id="fallback_to_stale_replicas_for_distributed_queries">
  fallback\_to\_stale\_replicas\_for\_distributed\_queries
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

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).

<h2 id="file_like_engine_default_partition_strategy">
  file\_like\_engine\_default\_partition\_strategy
</h2>

<SettingsInfoBlock type="FileLikeEngineDefaultPartitionStrategy" default_value="hive" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.6"},{"label": "hive"},{"label": "Change the default partition strategy for file-like table engines (S3, AzureBlobStorage, etc.) from `wildcard` to `hive` when no `partition_strategy` is provided."}]}]} />

Default partition strategy for file like engines. Applied only when the path does not contain a `{_partition_id}` placeholder: such a path is compatible only with the `wildcard` strategy, so it always implies `wildcard`.

<h2 id="filesystem_prefetches_limit">
  filesystem\_prefetches\_limit
</h2>

<SettingsInfoBlock type="UInt64" default_value="200" />

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

<h2 id="filter">
  filter
</h2>

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": ""},{"label": "New setting to add a WHERE clause around a query."}]}]} />

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.

<Danger>
  `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.
</Danger>

<h2 id="final">
  final
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

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 theme={null}
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 │
└─────┴────────┘
```

<h2 id="finalize_projection_parts_synchronously">
  finalize\_projection\_parts\_synchronously
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.4"},{"label": "0"},{"label": "New setting to finalize projection parts synchronously during INSERT to reduce peak memory usage."}]}]} />

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.

<h2 id="flatten_nested">
  flatten\_nested
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

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 theme={null}
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 theme={null}
┌─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 theme={null}
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 theme={null}
┌─statement──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ CREATE TABLE default.t_nest
(
    `n` Nested(a UInt32, b UInt32)
)
ENGINE = MergeTree
ORDER BY tuple()
SETTINGS index_granularity = 8192 │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
```

<h2 id="format">
  format
</h2>

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": ""},{"label": "New setting to override the FORMAT of the query for both input and output."}]}]} />

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.

<h2 id="framing_output_format">
  framing\_output\_format
</h2>

<BetaBadge />

<SettingsInfoBlock type="String" default_value="None" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": "None"},{"label": "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."}]}]} />

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 theme={null}
curl "http://localhost:8123/?framing_output_format=JSONEachPacketString" -d "SELECT number FROM numbers(3) FORMAT JSONEachRow"
```

Result:

```text theme={null}
{"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"}}
```

<h2 id="fsync_metadata">
  fsync\_metadata
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

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.

<h2 id="functions_h3_default_if_invalid">
  functions\_h3\_default\_if\_invalid
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.2"},{"label": "0"},{"label": "A new setting for legacy behaviour to allow invalid inputs to h3 functions"}]}]} />

If false, h3 functions, e.g. h3CellAreaM2, throw an exception if input is invalid. If true, they return 0 or default value.

<h2 id="geo_distance_returns_float64_on_float64_arguments">
  geo\_distance\_returns\_float64\_on\_float64\_arguments
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.3"},{"label": "1"},{"label": "Increase the default precision."}]}]} />

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.

<h2 id="geotoh3_argument_order">
  geotoh3\_argument\_order
</h2>

<BetaBadge />

<SettingsInfoBlock type="GeoToH3ArgumentOrder" default_value="lat_lon" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.5"},{"label": "lat_lon"},{"label": "A new setting for legacy behaviour to set lon and lat argument order"}]}]} />

Function 'geoToH3' accepts (lon, lat) if set to 'lon\_lat' and (lat, lon) if set to 'lat\_lon'.

<h2 id="glob_expansion_max_elements">
  glob\_expansion\_max\_elements
</h2>

<SettingsInfoBlock type="UInt64" default_value="1000" />

Maximum number of allowed addresses (For external storages, table functions, etc).

<h2 id="h3togeo_lon_lat_result_order">
  h3togeo\_lon\_lat\_result\_order
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.1"},{"label": "0"},{"label": "A new setting"}]}]} />

Function 'h3ToGeo' returns (lon, lat) if true, otherwise (lat, lon).

<h2 id="handshake_timeout_ms">
  handshake\_timeout\_ms
</h2>

<SettingsInfoBlock type="Milliseconds" default_value="10000" />

Timeout in milliseconds for receiving Hello packet from replicas during handshake.

<h2 id="hedged_connection_timeout_ms">
  hedged\_connection\_timeout\_ms
</h2>

<SettingsInfoBlock type="Milliseconds" default_value="50" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "23.4"},{"label": "50"},{"label": "Start new connection in hedged requests after 50 ms instead of 100 to correspond with previous connect timeout"}]}]} />

Connection timeout for establishing connection with replica for Hedged requests

<h2 id="highlight_max_matches_per_row">
  highlight\_max\_matches\_per\_row
</h2>

<SettingsInfoBlock type="UInt64" default_value="10000" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.4"},{"label": "10000"},{"label": "New setting to limit the number of highlight matches per row to protect against excessive memory usage."}]}]} />

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.

<h2 id="hnsw_candidate_list_size_for_search">
  hnsw\_candidate\_list\_size\_for\_search
</h2>

<SettingsInfoBlock type="UInt64" default_value="256" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.10"},{"label": "256"},{"label": "New setting. Previously, the value was optionally specified in CREATE INDEX and 64 by default."}]}]} />

The size of the dynamic candidate list when searching the vector similarity index, also known as 'ef\_search'.

<h2 id="hsts_max_age">
  hsts\_max\_age
</h2>

<SettingsInfoBlock type="UInt64" default_value="0" />

Expired time for HSTS. 0 means disable HSTS.

<h2 id="idle_connection_timeout">
  idle\_connection\_timeout
</h2>

<SettingsInfoBlock type="UInt64" default_value="3600" />

Timeout to close idle TCP connections after specified number of seconds.

Possible values:

* Positive integer (0 - close immediately, after 0 seconds).

<h2 id="inject_random_order_for_select_without_order_by">
  inject\_random\_order\_for\_select\_without\_order\_by
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.10"},{"label": "0"},{"label": "New setting"}]}]} />

If enabled, injects 'ORDER BY rand()' 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, 'ORDER BY rand()' is injected into all children independently.
Only useful for testing and development (missing ORDER BY is a source of non-deterministic query results).

<h2 id="input_format">
  input\_format
</h2>

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": ""},{"label": "New setting to override the input format of the query."}]}]} />

Overrides the input format of the query. Wins over the format specified in the query.

<h2 id="interactive_delay">
  interactive\_delay
</h2>

<SettingsInfoBlock type="UInt64" default_value="100000" />

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

<h2 id="intersect_default_mode">
  intersect\_default\_mode
</h2>

<SettingsInfoBlock type="SetOperationMode" default_value="ALL" />

Set default mode in INTERSECT query. Possible values: empty string, 'ALL', 'DISTINCT'. If empty, query without mode will throw exception.

<h2 id="least_greatest_legacy_null_behavior">
  least\_greatest\_legacy\_null\_behavior
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.12"},{"label": "0"},{"label": "New setting"}]}]} />

If enabled, functions 'least' and 'greatest' return NULL if one of their arguments is NULL.

<h2 id="legacy_column_name_of_tuple_literal">
  legacy\_column\_name\_of\_tuple\_literal
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "21.7"},{"label": "0"},{"label": "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"}]}]} />

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.

<h2 id="limit">
  limit
</h2>

<SettingsInfoBlock type="Double" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": "0"},{"label": "Type widened from UInt64 to Float to support negative and fractional values, passed through to ClickHouse's native negative\/fractional `LIMIT` support."}]}]} />

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.

<h2 id="load_marks_asynchronously">
  load\_marks\_asynchronously
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

Load MergeTree marks asynchronously

Cloud default value: `1`.

<h2 id="lock_acquire_timeout">
  lock\_acquire\_timeout
</h2>

<SettingsInfoBlock type="Seconds" default_value="120" />

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.

<h2 id="low_priority_query_wait_time_ms">
  low\_priority\_query\_wait\_time\_ms
</h2>

<BetaBadge />

<SettingsInfoBlock type="Milliseconds" default_value="1000" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.4"},{"label": "1000"},{"label": "New setting."}]}]} />

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.

<h2 id="make_distributed_plan">
  make\_distributed\_plan
</h2>

<ExperimentalBadge />

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.5"},{"label": "0"},{"label": "New experimental setting."}]}]} />

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`;
* `use_skip_indexes_on_data_read = 0`;
* `compile_expressions = 0`;
* `query_plan_direct_read_from_text_index = 0`.

<h2 id="merge_table_max_tables_to_look_for_schema_inference">
  merge\_table\_max\_tables\_to\_look\_for\_schema\_inference
</h2>

<SettingsInfoBlock type="UInt64" default_value="1000" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.1"},{"label": "1000"},{"label": "A new setting"}]}]} />

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.

<h2 id="mongodb_throw_on_unsupported_query">
  mongodb\_throw\_on\_unsupported\_query
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.9"},{"label": "1"},{"label": "New setting."}]}, {"id": "row-2","items": [{"label": "24.10"},{"label": "1"},{"label": "New setting."}]}]} />

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. This option does not apply when 'allow\_experimental\_analyzer=0'.

<h2 id="multiple_joins_try_to_keep_original_names">
  multiple\_joins\_try\_to\_keep\_original\_names
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

Do not add aliases to top level expression list on multiple joins rewrite

<h2 id="normalize_function_names">
  normalize\_function\_names
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "21.3"},{"label": "1"},{"label": "Normalize function names to their canonical names, this was needed for projection query routing"}]}]} />

Normalize function names to their canonical names

<h2 id="offset">
  offset
</h2>

<SettingsInfoBlock type="Double" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": "0"},{"label": "Type widened from UInt64 to Float to support negative and fractional values, passed through to ClickHouse's native negative\/fractional `OFFSET` support."}]}]} />

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 theme={null}
CREATE TABLE test (i UInt64) ENGINE = MergeTree() ORDER BY i;
INSERT INTO test SELECT number FROM numbers(500);
```

Query:

```sql theme={null}
SET limit = 5;
SET offset = 7;
SELECT * FROM test LIMIT 10 OFFSET 100;
```

Result:

```text theme={null}
┌───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.

<h2 id="order">
  order
</h2>

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": ""},{"label": "New setting to add an ORDER BY clause around a query."}]}]} />

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.

<h2 id="output_format">
  output\_format
</h2>

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": ""},{"label": "New setting to override the output format of the query."}]}]} />

Overrides the output format of the query. Wins over the format specified in the query, in the file extension, or via `default_format`.

<h2 id="page">
  page
</h2>

<SettingsInfoBlock type="Double" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": "0"},{"label": "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`)."}]}]} />

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.

<h2 id="paimon_target_snapshot_id">
  paimon\_target\_snapshot\_id
</h2>

<ExperimentalBadge />

<SettingsInfoBlock type="Int64" default_value="-1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.5"},{"label": "-1"},{"label": "New setting."}]}]} />

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)

<h2 id="parallelize_output_from_storages">
  parallelize\_output\_from\_storages
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "23.5"},{"label": "1"},{"label": "Allow parallelism when executing queries that read from file\/url\/s3\/etc. This may reorder rows."}]}]} />

Parallelize output for reading step from storage. It allows parallelization of query processing right after reading from storage if possible

<h2 id="partial_result_on_first_cancel">
  partial\_result\_on\_first\_cancel
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

Allows query to return a partial result after cancel.

<h2 id="per_part_index_stats">
  per\_part\_index\_stats
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.8"},{"label": "0"},{"label": "New setting."}]}]} />

Logs index statistics per part

<h2 id="poll_interval">
  poll\_interval
</h2>

<SettingsInfoBlock type="UInt64" default_value="10" />

Block at the query wait loop on the server for the specified number of seconds.

<h2 id="polyglot_dialect">
  polyglot\_dialect
</h2>

<ExperimentalBadge />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.3"},{"label": ""},{"label": "New setting to specify the source SQL dialect for the polyglot transpiler."}]}]} />

Source SQL dialect for the polyglot transpiler (e.g. 'sqlite', 'mysql', 'postgresql', 'snowflake', 'duckdb').

<h2 id="postgresql_fault_injection_probability">
  postgresql\_fault\_injection\_probability
</h2>

<SettingsInfoBlock type="Float" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.2"},{"label": "0"},{"label": "New setting"}]}]} />

Approximate probability of failing internal (for replication) PostgreSQL queries. Valid value is in interval \[0.0f, 1.0f]

<h2 id="predicate_statistics_sample_rate">
  predicate\_statistics\_sample\_rate
</h2>

<SettingsInfoBlock type="UInt64" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.5"},{"label": "0"},{"label": "New setting to collect predicate selectivity statistics into system.predicate_statistics_log"}]}]} />

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.

<h2 id="prefetch_buffer_size">
  prefetch\_buffer\_size
</h2>

<SettingsInfoBlock type="UInt64" default_value="1048576" />

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.

<h2 id="print_pretty_type_names">
  print\_pretty\_type\_names
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.1"},{"label": "1"},{"label": "Better user experience."}]}]} />

Allows to print deep-nested type names in a pretty way with indents in `DESCRIBE` query and in `toTypeName()` function.

Example:

```sql theme={null}
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)
)
```

<h2 id="priority">
  priority
</h2>

<SettingsInfoBlock type="UInt64" default_value="0" />

Priority of the query. 1 - the highest, higher value - lower priority; 0 - do not use priorities.

<h2 id="push_external_roles_in_interserver_queries">
  push\_external\_roles\_in\_interserver\_queries
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.11"},{"label": "1"},{"label": "New setting."}]}]} />

Enable pushing user roles from originator to other nodes while performing a query.

<h2 id="query_metric_log_interval">
  query\_metric\_log\_interval
</h2>

<SettingsInfoBlock type="Int64" default_value="-1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.10"},{"label": "-1"},{"label": "New setting."}]}]} />

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

<h2 id="queue_max_wait_ms">
  queue\_max\_wait\_ms
</h2>

<SettingsInfoBlock type="Milliseconds" default_value="0" />

The wait time in the request queue, if the number of concurrent requests exceeds the maximum.

<h2 id="rabbitmq_max_wait_ms">
  rabbitmq\_max\_wait\_ms
</h2>

<SettingsInfoBlock type="Milliseconds" default_value="5000" />

The wait time for reading from RabbitMQ before retry.

<h2 id="readonly">
  readonly
</h2>

<SettingsInfoBlock type="UInt64" default_value="0" />

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.

<h2 id="recursive_cte_max_steps_in_type_inference">
  recursive\_cte\_max\_steps\_in\_type\_inference
</h2>

<SettingsInfoBlock type="UInt64" default_value="10" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.5"},{"label": "10"},{"label": "Maximum iterations for inferring column types in recursive CTEs via iterative getLeastSupertype"}]}]} />

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.

<h2 id="regexp_max_matches_per_row">
  regexp\_max\_matches\_per\_row
</h2>

<SettingsInfoBlock type="UInt64" default_value="1000" />

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.

<h2 id="reject_expensive_hyperscan_regexps">
  reject\_expensive\_hyperscan\_regexps
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

Reject patterns which will likely be expensive to evaluate with hyperscan (due to NFA state explosion)

<h2 id="remerge_sort_lowered_memory_bytes_ratio">
  remerge\_sort\_lowered\_memory\_bytes\_ratio
</h2>

<SettingsInfoBlock type="Float" default_value="2" />

If memory usage after remerge does not reduced by this ratio, remerge will be disabled.

<h2 id="remote_read_min_bytes_for_seek">
  remote\_read\_min\_bytes\_for\_seek
</h2>

<SettingsInfoBlock type="UInt64" default_value="4194304" />

Min bytes required for remote read (url, s3) to do seek, instead of read with ignore.

<h2 id="rename_files_after_processing">
  rename\_files\_after\_processing
</h2>

* **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.

### 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`

<h2 id="replication_wait_for_inactive_replica_timeout">
  replication\_wait\_for\_inactive\_replica\_timeout
</h2>

<SettingsInfoBlock type="Int64" default_value="120" />

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.

<h2 id="reserve_memory">
  reserve\_memory
</h2>

<ExperimentalBadge />

<SettingsInfoBlock type="UInt64" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.7"},{"label": "0"},{"label": "New setting to reserve memory for specific workload before starting a query."}]}]} />

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.

<h2 id="restore_replicated_merge_tree_to_shared_merge_tree">
  restore\_replicated\_merge\_tree\_to\_shared\_merge\_tree
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.2"},{"label": "0"},{"label": "New setting."}]}]} />

Replace table engine from Replicated*MergeTree -> Shared*MergeTree during RESTORE.

Cloud default value: `1`.

<h2 id="result_overflow_mode">
  result\_overflow\_mode
</h2>

<SettingsInfoBlock type="OverflowMode" default_value="throw" />

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" theme={null}
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" theme={null}
6666 rows in set. ...
```

<h2 id="resumable_backup_from_snapshot">
  resumable\_backup\_from\_snapshot
</h2>

<ExperimentalBadge />

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": "0"},{"label": "New experimental setting to enable resumable `BACKUP FROM SNAPSHOT`."}]}]} />

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`.

<h2 id="rows_before_aggregation">
  rows\_before\_aggregation
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.8"},{"label": "0"},{"label": "Provide exact value for rows_before_aggregation statistic, represents the number of rows read before aggregation"}]}]} />

When enabled, ClickHouse will provide exact value for rows\_before\_aggregation statistic, represents the number of rows read before aggregatio

<h2 id="run_query_in_background">
  run\_query\_in\_background
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": "0"},{"label": "New setting to run a query in the background, detached from the connection that submitted it, discarding the result."}]}]} />

If enabled, the server schedules the query in the background, immediately returns an empty successful result, and runs the query to completion regardless of what happens to the connection.

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.

<h2 id="secondary_indices_enable_bulk_filtering">
  secondary\_indices\_enable\_bulk\_filtering
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.5"},{"label": "1"},{"label": "A new algorithm for filtering by data skipping indices"}]}]} />

Enable the bulk filtering algorithm for indices. It is expected to be always better, but we have this setting for compatibility and control.

<h2 id="select">
  select
</h2>

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": ""},{"label": "New setting to wrap a query in `SELECT <expr_list> FROM (<query>)`."}]}]} />

Wraps the query as a subquery with an explicit `SELECT` expression list. When non-empty, the result-producing query is wrapped as `SELECT <expr_list> FROM (<query>)`.

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.

<h2 id="select_sequential_consistency">
  select\_sequential\_consistency
</h2>

<SettingsInfoBlock type="UInt64" default_value="0" />

<Note>
  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.
</Note>

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](/reference/settings/session-settings/insert-quorum#insert_quorum)
* [insert\_quorum\_timeout](/reference/settings/session-settings/insert-quorum#insert_quorum_timeout)
* [insert\_quorum\_parallel](/reference/settings/session-settings/insert-quorum#insert_quorum_parallel)

<h2 id="session_timezone">
  session\_timezone
</h2>

<BetaBadge />

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`

Examples:

```sql theme={null}
SELECT timeZone(), serverTimeZone() FORMAT CSV

"Europe/Berlin","Europe/Berlin"
```

```sql theme={null}
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 theme={null}
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
```

<Warning>
  Not all functions that parse DateTime/DateTime64 respect `session_timezone`. This can lead to subtle errors.
  See the following example and explanation.
</Warning>

```sql theme={null}
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)

<h2 id="set_overflow_mode">
  set\_overflow\_mode
</h2>

<SettingsInfoBlock type="OverflowMode" default_value="throw" />

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.

<h2 id="single_join_prefer_left_table">
  single\_join\_prefer\_left\_table
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

For single JOIN in case of identifier ambiguity prefer left table

<h2 id="skip_redundant_aliases_in_udf">
  skip\_redundant\_aliases\_in\_udf
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.12"},{"label": "0"},{"label": "When enabled, this allows you to use the same user defined function several times for several materialized columns in the same table."}]}]} />

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 theme={null}
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 theme={null}
SELECT ((4 + 2) + 1 AS y, y + 2)
```

Query:

```sql theme={null}
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 theme={null}
SELECT ((4 + 2) + 1, ((4 + 2) + 1) + 2)
```

<h2 id="sleep_after_receiving_query_ms">
  sleep\_after\_receiving\_query\_ms
</h2>

<SettingsInfoBlock type="Milliseconds" default_value="0" />

Time to sleep after receiving query in TCPHandler

<h2 id="snappy_mode">
  snappy\_mode
</h2>

<SettingsInfoBlock type="SnappyMode" default_value="basic" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.7"},{"label": "basic"},{"label": "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."}]}]} />

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.

<h2 id="sort">
  sort
</h2>

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": ""},{"label": "New setting to add a simple ORDER BY clause around a query."}]}]} />

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.

<h2 id="sort_overflow_mode">
  sort\_overflow\_mode
</h2>

<SettingsInfoBlock type="OverflowMode" default_value="throw" />

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.

<h2 id="splitby_max_substrings_includes_remaining_string">
  splitby\_max\_substrings\_includes\_remaining\_string
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

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.

<h2 id="statistics_max_set_size_for_exact_selectivity_estimation">
  statistics\_max\_set\_size\_for\_exact\_selectivity\_estimation
</h2>

<SettingsInfoBlock type="UInt64" default_value="10000" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": "10000"},{"label": "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. Before 26.8 the estimation was uncapped, so the previous value is 0 (no limit) and `compatibility` with an earlier version restores the exact ranges for sets of any size."}]}]} />

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.

<h2 id="stop_refreshable_materialized_views_on_startup">
  stop\_refreshable\_materialized\_views\_on\_startup
</h2>

<ExperimentalBadge />

<SettingsInfoBlock type="Bool" default_value="0" />

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 <name>` afterwards. Also applies to newly created views. Has no effect on non-refreshable materialized views.

<h2 id="tcp_keep_alive_timeout">
  tcp\_keep\_alive\_timeout
</h2>

<SettingsInfoBlock type="Seconds" default_value="290" />

The time in seconds the connection needs to remain idle before TCP starts sending keepalive probes

<h2 id="temporary_data_in_cache_reserve_space_wait_lock_timeout_milliseconds">
  temporary\_data\_in\_cache\_reserve\_space\_wait\_lock\_timeout\_milliseconds
</h2>

<SettingsInfoBlock type="UInt64" default_value="600000" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.4"},{"label": "600000"},{"label": "Wait time to lock cache for space reservation in temporary data in filesystem cache"}]}]} />

Wait time to lock cache for space reservation for temporary data in filesystem cache

<h2 id="throw_if_no_data_to_insert">
  throw\_if\_no\_data\_to\_insert
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

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/cli) or using the [gRPC interface](/concepts/features/interfaces/grpc).

<h2 id="time_series_prefer_recent_samples_table">
  time\_series\_prefer\_recent\_samples\_table
</h2>

<ExperimentalBadge />

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.8"},{"label": "1"},{"label": "New setting to read from the recent samples table of a TimeSeries table when the requested time range fits in its TTL window."}]}]} />

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).

<h2 id="timeout_before_checking_execution_speed">
  timeout\_before\_checking\_execution\_speed
</h2>

<SettingsInfoBlock type="Seconds" default_value="10" />

Checks that execution speed is not too slow (no less than `min_execution_speed`),
after the specified time in seconds has expired.

<h2 id="transfer_overflow_mode">
  transfer\_overflow\_mode
</h2>

<SettingsInfoBlock type="OverflowMode" default_value="throw" />

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.

<h2 id="transform_null_in">
  transform\_null\_in
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

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 theme={null}
┌──idx─┬─────i─┐
│    1 │     1 │
│    2 │  NULL │
│    3 │     3 │
└──────┴───────┘
```

Query:

```sql theme={null}
SELECT idx, i FROM null_in WHERE i IN (1, NULL) SETTINGS transform_null_in = 0;
```

Result:

```text theme={null}
┌──idx─┬────i─┐
│    1 │    1 │
└──────┴──────┘
```

Query:

```sql theme={null}
SELECT idx, i FROM null_in WHERE i IN (1, NULL) SETTINGS transform_null_in = 1;
```

Result:

```text theme={null}
┌──idx─┬─────i─┐
│    1 │     1 │
│    2 │  NULL │
└──────┴───────┘
```

**See Also**

* [NULL Processing in IN Operators](/reference/statements/in#null-processing)

<h2 id="traverse_shadow_remote_data_paths">
  traverse\_shadow\_remote\_data\_paths
</h2>

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.3"},{"label": "0"},{"label": "Traverse shadow directory when query system.remote_data_paths."}]}]} />

Traverse frozen data (shadow directory) in addition to actual table data when query system.remote\_data\_paths

<h2 id="union_default_mode">
  union\_default\_mode
</h2>

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).

<h2 id="unknown_packet_in_send_data">
  unknown\_packet\_in\_send\_data
</h2>

<SettingsInfoBlock type="UInt64" default_value="0" />

Send unknown packet instead of data Nth data packet

<h2 id="variant_throw_on_type_mismatch">
  variant\_throw\_on\_type\_mismatch
</h2>

<SettingsInfoBlock type="Bool" default_value="1" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.4"},{"label": "1"},{"label": "New setting to control type mismatch behavior in default Variant implementation"}]}]} />

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.

<h2 id="wait_changes_become_visible_after_commit_mode">
  wait\_changes\_become\_visible\_after\_commit\_mode
</h2>

<ExperimentalBadge />

<SettingsInfoBlock type="TransactionsWaitCSNMode" default_value="wait_unknown" />

Wait for committed changes to become actually visible in the latest snapshot

<h2 id="workload">
  workload
</h2>

<SettingsInfoBlock type="String" default_value="default" />

Name of workload to be used to access resources

<h2 id="write_full_path_in_iceberg_metadata">
  write\_full\_path\_in\_iceberg\_metadata
</h2>

<ExperimentalBadge />

<SettingsInfoBlock type="Bool" default_value="0" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.8"},{"label": "0"},{"label": "New setting."}]}]} />

Write full paths (including s3://) into iceberg metadata files.

<h2 id="zstd_window_log_max">
  zstd\_window\_log\_max
</h2>

<SettingsInfoBlock type="Int64" default_value="0" />

Allows you to select the max window log of ZSTD (it will not be used for MergeTree family)
