Skip to content
ClickHouse Docs
ClickHouse DocsClickHouse Docs

optimize_rewrite_* session settings

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

optimize_rewrite_aggregate_function_with_if

Type
Bool
Default
1

Rewrite aggregate functions with if expression as argument when logically equivalent. For example, avg(if(cond, col, null)) can be rewritten to avgOrNullIf(cond, col). It may improve performance.

optimize_rewrite_array_exists_to_has

Type
Bool
Default
1
Version history
VersionDefault valueComment
26.41Enable arrayExists to has rewrite optimization by default, now that type compatibility is checked before rewriting.

Rewrite arrayExists() functions to has() when logically equivalent. For example, arrayExists(x -> x = 1, arr) can be rewritten to has(arr, 1)

optimize_rewrite_has_to_in

Type
Bool
Default
1
Version history
VersionDefault valueComment
26.61New setting

Rewrite has functions to IN when the first argument is a constant array. For example, has([1, 2, 3], x) can be rewritten to x IN [1, 2, 3] for better performance with constant arrays

optimize_rewrite_like_perfect_affix

Type
Bool
Default
1
Version history
VersionDefault valueComment
25.101New setting

Rewrite LIKE expressions with perfect prefix or suffix (e.g. col LIKE 'ClickHouse%') to startsWith or endsWith functions (e.g. startsWith(col, 'ClickHouse')).

optimize_rewrite_regexp_functions

Type
Bool
Default
1
Version history
VersionDefault valueComment
25.81A new setting

Rewrite regular expression related functions into simpler and more efficient forms

optimize_rewrite_sum_if_to_count_if

Type
Bool
Default
1
Version history
VersionDefault valueComment
24.41Only available for the analyzer, where it works correctly

Rewrite sumIf() and sum(if()) function countIf() function when logically equivalent

Navigation