Skip to content
ClickHouse Docs
ClickHouse DocsClickHouse Docs

max_streams_* session settings

These settings are available in system.settings and are autogenerated from source.

max_streams_for_files_processing_in_cluster_functions

Type
UInt64
Default
0
Version history
VersionDefault valueComment
25.120Add a new setting that allows to limit number of streams for files processing in *Cluster table functions

If is not zero, limit the number of threads reading data from files in *Cluster table functions.

max_streams_for_merge_tree_reading

Type
UInt64
Default
0

If is not zero, limit the number of reading streams for MergeTree table.

max_streams_for_union_step

Type
UInt64
Default
0
Version history
VersionDefault valueComment
26.50New setting to limit the number of simultaneously active data streams in a UNION step to reduce peak memory usage.

Limits the number of simultaneously active data streams in a UNION step (applies to both UNION ALL and UNION DISTINCT, because UNION DISTINCT is implemented via a UNION ALL step followed by a DISTINCT step). When a UNION query has many subqueries, all of them open their read buffers at the same time, leading to memory usage proportional to the number of subqueries. This setting inserts Concat processors to narrow the pipeline so that at most this many streams are active at once, drastically reducing peak memory. The actual limit is the minimum of this value and max_threads * max_streams_for_union_step_to_max_threads_ratio (either one being 0 means it is ignored). When both are 0, no narrowing is applied. The limit is also not applied when the query plan requires each output stream of the UNION to stay individually sorted (for example, when the read-in-order optimization is applied across the UNION); in that case correctness of the ordering takes precedence and narrowing is skipped.

max_streams_for_union_step_to_max_threads_ratio

Type
Float
Default
8
Version history
VersionDefault valueComment
26.58New setting: the limit on simultaneously active streams in a UNION step is computed as min(max_streams_for_union_step, max_threads * max_streams_for_union_step_to_max_threads_ratio), either being 0 disables that input.

This ratio multiplied by max_threads determines a limit on simultaneously active streams in a UNION step (applies to both UNION ALL and UNION DISTINCT). The actual limit is the minimum of this computed value and max_streams_for_union_step (either one being 0 means it is ignored). For example, with max_threads = 8 and this ratio set to 1, at most 8 streams will be active. Set to 0 to disable this ratio-based limit. Like max_streams_for_union_step, the limit is not applied when the query plan requires each output stream of the UNION to stay individually sorted.

max_streams_multiplier_for_merge_tables

Type
Float
Default
5

Ask more streams when reading from Merge table. Streams will be spread across tables that Merge table will use. This allows more even distribution of work across threads and is especially helpful when merged tables differ in size.

max_streams_to_max_threads_ratio

Type
Float
Default
1

Allows you to use more sources than the number of threads - to more evenly distribute work across threads. It is assumed that this is a temporary solution since it will be possible in the future to make the number of sources equal to the number of threads, but for each source to dynamically select available work for itself.

Navigation