> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# max_* session settings

> ClickHouse session settings in the max_* generated group.

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>;
};

export const ExperimentalBadge = () => {
  return <div 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. <u><a href="/docs/docs/beta-and-experimental-features#experimental-features">Learn more.</a></u>
        </div>;
};

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

<h2 id="max_analyze_depth">
  max\_analyze\_depth
</h2>

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

Maximum number of analyses performed by interpreter.

<h2 id="max_autoincrement_series">
  max\_autoincrement\_series
</h2>

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

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

The limit on the number of series created by the `generateSerialID` function.

As each series represents a node in Keeper, it is recommended to have no more than a couple of millions of them.

<h2 id="max_backup_bandwidth">
  max\_backup\_bandwidth
</h2>

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

The maximum read speed in bytes per second for particular backup on server. Zero means unlimited.

<h2 id="max_block_size">
  max\_block\_size
</h2>

<SettingsInfoBlock type="NonZeroUInt64" default_value="65409" />

In ClickHouse, data is processed by blocks, which are sets of column parts. The internal processing cycles for a single block are efficient but there are noticeable costs when processing each block.

The `max_block_size` setting indicates the recommended maximum number of rows to include in a single block when loading data from tables. Blocks the size of `max_block_size` are not always loaded from the table: if ClickHouse determines that less data needs to be retrieved, a smaller block is processed.

The block size should not be too small to avoid noticeable costs when processing each block. It should also not be too large to ensure that queries with a LIMIT clause execute quickly after processing the first block. When setting `max_block_size`, the goal should be to avoid consuming too much memory when extracting a large number of columns in multiple threads and to preserve at least some cache locality.

<h2 id="max_columns_to_read">
  max\_columns\_to\_read
</h2>

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

The maximum number of columns that can be read from a table in a single query.
If a query requires reading more than the specified number of columns, an exception
is thrown.

<Tip>
  This setting is useful for preventing overly complex queries.
</Tip>

`0` value means unlimited.

<h2 id="max_compress_block_size">
  max\_compress\_block\_size
</h2>

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

The maximum size of blocks of uncompressed data before compressing for writing to a table. By default, 1,048,576 (1 MiB). Specifying a smaller block size generally leads to slightly reduced compression ratio, the compression and decompression speed increases slightly due to cache locality, and memory consumption is reduced.

<Note>
  This is an expert-level setting, and you shouldn't change it if you're just getting started with ClickHouse.
</Note>

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

<h2 id="max_consume_snapshots">
  max\_consume\_snapshots
</h2>

<ExperimentalBadge />

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

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

Maximum number of Paimon snapshots to consume per incremental read. 0 means no limit.

<h2 id="max_estimated_execution_time">
  max\_estimated\_execution\_time
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.1"},{"label": "0"},{"label": "Separate max_execution_time and max_estimated_execution_time"}]}]} />

Maximum query estimate execution time in seconds. Checked on every data block
when [`timeout_before_checking_execution_speed`](/docs/reference/settings/session-settings/other#timeout_before_checking_execution_speed)
expires.

<h2 id="max_expanded_ast_elements">
  max\_expanded\_ast\_elements
</h2>

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

Maximum size of query syntax tree in number of nodes after expansion of aliases and the asterisk.

<h2 id="max_fetch_partition_retries_count">
  max\_fetch\_partition\_retries\_count
</h2>

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

Amount of retries while fetching partition from another host.

<h2 id="max_final_threads">
  max\_final\_threads
</h2>

<SettingsInfoBlock type="MaxThreads" default_value="auto(N)" />

Sets the maximum number of parallel threads for the `SELECT` query data read phase with the [FINAL](/docs/reference/statements/select/from#final-modifier) modifier.

Possible values:

* Positive integer.
* 0 or 1 — Disabled. `SELECT` queries are executed in a single thread.

<h2 id="max_http_get_redirects">
  max\_http\_get\_redirects
</h2>

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

Max number of HTTP GET redirects hops allowed. Ensures additional security measures are in place to prevent a malicious server from redirecting your requests to unexpected services.\n\nIt is the case when an external server redirects to another address, but that address appears to be internal to the company's infrastructure, and by sending an HTTP request to an internal server, you could request an internal API from the internal network, bypassing the auth, or even query other services, such as Redis or Memcached. When you don't have an internal infrastructure (including something running on your localhost), or you trust the server, it is safe to allow redirects. Although keep in mind, that if the URL uses HTTP instead of HTTPS, and you will have to trust not only the remote server but also your ISP and every network in the middle.

Cloud default value: `10`.

<h2 id="max_limit_for_vector_search_queries">
  max\_limit\_for\_vector\_search\_queries
</h2>

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

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

SELECT queries with LIMIT bigger than this setting cannot use vector similarity indices. Helps to prevent memory overflows in vector similarity indices.

<h2 id="max_number_of_partitions_for_independent_aggregation">
  max\_number\_of\_partitions\_for\_independent\_aggregation
</h2>

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

Maximal number of partitions in table to apply optimizatio

<h2 id="max_os_cpu_wait_time_ratio_to_throw">
  max\_os\_cpu\_wait\_time\_ratio\_to\_throw
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.5"},{"label": "0"},{"label": "Setting values were changed and backported to 25.4"}]}, {"id": "row-2","items": [{"label": "25.4"},{"label": "0"},{"label": "New setting"}]}]} />

Max ratio between OS CPU wait (OSCPUWaitMicroseconds metric) and busy (OSCPUVirtualTimeMicroseconds metric) times to consider rejecting queries. Linear interpolation between min and max ratio is used to calculate the probability, the probability is 1 at this point.

<h2 id="max_parallel_replicas">
  max\_parallel\_replicas
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.1"},{"label": "1000"},{"label": "Use up to 1000 parallel replicas by default."}]}]} />

The maximum number of replicas for each shard when executing a query.

Possible values:

* Positive integer.

**Additional Info**

This options will produce different results depending on the settings used.

### Parallel processing using `SAMPLE` key

A query may be processed faster if it is executed on several servers in parallel. But the query performance may degrade in the following cases:

* The position of the sampling key in the partitioning key does not allow efficient range scans.
* Adding a sampling key to the table makes filtering by other columns less efficient.
* The sampling key is an expression that is expensive to calculate.
* The cluster latency distribution has a long tail, so that querying more servers increases the query overall latency.

### Parallel processing using [parallel\_replicas\_custom\_key](/docs/reference/settings/session-settings/parallel-replicas#parallel_replicas_custom_key)

This setting is useful for any replicated table.

<h2 id="max_parsing_threads">
  max\_parsing\_threads
</h2>

<SettingsInfoBlock type="MaxThreads" default_value="auto(N)" />

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.4"},{"label": "0"},{"label": "Add a separate setting to control number of threads in parallel parsing from files"}]}]} />

The maximum number of threads to parse data in input formats that support parallel parsing. By default, it is determined automatically.

<h2 id="max_partition_size_to_drop">
  max\_partition\_size\_to\_drop
</h2>

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

Restriction on dropping partitions in query time. The value `0` means that you can drop partitions without any restrictions.

Cloud default value: 1 TB.

<Note>
  This query setting overwrites its server setting equivalent, see [max\_partition\_size\_to\_drop](/docs/reference/settings/server-settings/settings#max_partition_size_to_drop)
</Note>

<h2 id="max_parts_to_move">
  max\_parts\_to\_move
</h2>

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

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

Limit the number of parts that can be moved in one query. Zero means unlimited.

<h2 id="max_projection_rows_to_use_projection_index">
  max\_projection\_rows\_to\_use\_projection\_index
</h2>

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

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

If the number of rows to read from the projection index is less than or equal to this threshold, ClickHouse will try to apply the projection index during query execution.

<h2 id="max_query_size">
  max\_query\_size
</h2>

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

The maximum number of bytes of a query string parsed by the SQL parser.
Data in the VALUES clause of INSERT queries is processed by a separate stream parser (that consumes O(1) RAM) and not affected by this restriction.

<Note>
  `max_query_size` cannot be set within an SQL query (e.g., `SELECT now() SETTINGS max_query_size=10000`) because ClickHouse needs to allocate a buffer to parse the query, and this buffer size is determined by the `max_query_size` setting, which must be configured before the query is executed.
</Note>

<h2 id="max_recursive_cte_evaluation_depth">
  max\_recursive\_cte\_evaluation\_depth
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.4"},{"label": "1000"},{"label": "Maximum limit on recursive CTE evaluation depth"}]}]} />

Maximum limit on recursive CTE evaluation depth

<h2 id="max_replica_delay_for_distributed_queries">
  max\_replica\_delay\_for\_distributed\_queries
</h2>

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

Disables lagging replicas for distributed queries. See [Replication](/docs/reference/engines/table-engines/mergetree-family/replication).

Sets the time in seconds. If a replica's lag is greater than or equal to the set value, this replica is not used.

Possible values:

* Positive integer.
* 0 — Replica lags are not checked.

To prevent the use of any replica with a non-zero lag, set this parameter to 1.

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

<h2 id="max_reverse_dictionary_lookup_cache_size_bytes">
  max\_reverse\_dictionary\_lookup\_cache\_size\_bytes
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "25.12"},{"label": "104857600"},{"label": "New setting. Maximum size in bytes of the per-query reverse dictionary lookup cache used by the function `dictGetKeys`. The cache stores serialized key tuples per attribute value to avoid re-scanning the dictionary within the same query."}]}]} />

Maximum size in bytes of the per-query reverse dictionary lookup cache used by the function `dictGetKeys`. The cache stores serialized key tuples per attribute value to avoid re-scanning the dictionary within the same query. When the limit is reached, entries are evicted using LRU. Set to 0 to disable caching.

<h2 id="max_sessions_for_user">
  max\_sessions\_for\_user
</h2>

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

Maximum number of simultaneous sessions per authenticated user to the ClickHouse server.

Example:

```xml theme={null}
<profiles>
    <single_session_profile>
        <max_sessions_for_user>1</max_sessions_for_user>
    </single_session_profile>
    <two_sessions_profile>
        <max_sessions_for_user>2</max_sessions_for_user>
    </two_sessions_profile>
    <unlimited_sessions_profile>
        <max_sessions_for_user>0</max_sessions_for_user>
    </unlimited_sessions_profile>
</profiles>
<users>
    <!-- User Alice can connect to a ClickHouse server no more than once at a time. -->
    <Alice>
        <profile>single_session_user</profile>
    </Alice>
    <!-- User Bob can use 2 simultaneous sessions. -->
    <Bob>
        <profile>two_sessions_profile</profile>
    </Bob>
    <!-- User Charles can use arbitrarily many of simultaneous sessions. -->
    <Charles>
        <profile>unlimited_sessions_profile</profile>
    </Charles>
</users>
```

Possible values:

* Positive integer
* `0` - infinite count of simultaneous sessions (default)

<h2 id="max_subquery_depth">
  max\_subquery\_depth
</h2>

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

If a query has more than the specified number of nested subqueries, throws an
exception.

<Tip>
  This allows you to have a sanity check to protect against the users of your
  cluster from writing overly complex queries.
</Tip>

<h2 id="max_table_size_to_drop">
  max\_table\_size\_to\_drop
</h2>

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

Restriction on deleting tables in query time. The value `0` means that you can delete all tables without any restrictions.

Cloud default value: 1 TB.

<Note>
  This query setting overwrites its server setting equivalent, see [max\_table\_size\_to\_drop](/docs/reference/settings/server-settings/settings#max_table_size_to_drop)
</Note>

<h2 id="max_untracked_memory">
  max\_untracked\_memory
</h2>

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

Small allocations and deallocations are grouped in thread local variable and tracked or profiled only when an amount (in absolute value) becomes larger than the specified value. If the value is higher than 'memory\_profiler\_step' it will be effectively lowered to 'memory\_profiler\_step'.

<h2 id="max_wkb_geometry_elements">
  max\_wkb\_geometry\_elements
</h2>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "26.4"},{"label": "1000000"},{"label": "New setting to limit element counts in WKB geometry parsing, preventing excessive memory allocation on malformed data."}]}]} />

Maximum number of points, rings, or polygons allowed in a single WKB geometry element during parsing by `readWKB` and related functions. This protects against excessive memory allocations from malformed WKB data. Set to 0 to use the hard-coded limit (100 million).
