v.19.14Improvement
When Determining Shards of a Distributed Table to Be Covered by a Read Query (for Optimize_skip_unused_shards = 1) Clickhouse Now Checks Conditions from Both Prewhere and Where Clauses of Select Statement
When determining shards of aDistributedtable to be covered by a read query (foroptimize_skip_unused_shards= 1) ClickHouse now checks conditions from bothprewhereandwhereclauses of select statement. #6521 (Alexander Kazakov)
Why it matters
The feature enhances query efficiency by more accurately determining which shards are relevant for a read query. It leverages filtering conditions from both theprewhere and where clauses, reducing unnecessary shard reads and improving overall query performance on distributed tables.How to use it
Enable the optimization by settingoptimize_skip_unused_shards = 1 in your query or session settings. Then, conditions specified in both the prewhere and where clauses will be used to skip irrelevant shards automatically.