v.20.4Improvement

Evaluate Constant Expressions for optimize_skip_unused_shards

Evaluate constant expressions for optimize_skip_unused_shards (i.e. SELECT * FROM foo_dist WHERE key=xxHash32(0)) #8846 (Azat Khuzhin)
ClickHouse now evaluates constant expressions in the optimize_skip_unused_shards setting, allowing queries such as SELECT * FROM foo_dist WHERE key=xxHash32(0) to be optimized by skipping unused shards.

Why it matters

This feature improves query performance on distributed tables by enabling the evaluation of constant expressions for shard skipping. It enhances the optimization process by allowing more complex filters involving constant expressions to be recognized, reducing unnecessary shard scans and improving overall efficiency.

How to use it

Users can benefit from this feature by using constant expressions in their query filters when optimize_skip_unused_shards is enabled. For example, write queries like:

SELECT * FROM foo_dist WHERE key=xxHash32(0)


and ClickHouse will evaluate the constant expression and skip shards accordingly.