Repository navigation
Plan a distributed query once for all remote shards - #130655
KochetovNicolai merged 2 commits into
Conversation
The header that a remote shard returns, and the planner context for filters that are pushed down, were calculated by planning the query again for each shard. Shards could differ in the types of `Object` columns, which do not exist any more.
|
Workflow [PR], commit [07be589] Summary: ✅
AI ReviewSummaryReviewed PR #130655 at Final Verdict✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units27 translation units recompiled, 355 s compile time in total, 27 of them have a recent master baseline. Median compile-time ratio to the baselines is ×0.94 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
ClickHouse#130655 and `fa76a947810d` ("Do not use inactive replicas as `make_distributed_plan` workers") on `master` renamed the static `getActiveReplicasForParallelReplicas(context, cluster)` to the exported `getReplicasLiveness(cluster_name, cluster)`. The merge kept the new name, but the call in `getActiveReplicasCountForParallelReplicas` added by this PR still used the old one. Pass the `cluster_for_parallel_replicas` setting as the cluster name, which is what the old function read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #77144
Related: #60497
Related: #85718
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Speed up planning of distributed queries with many shards: the initiator plans the query once for all remote shards, not once for each of them (unless
serialize_query_planis enabled).Description
For each remote shard, the initiator plans the query again to get the header of the shard's result, and the planner context for filters that are pushed down. With a complex query and many shards, this can take seconds (#77144).
It has been like that since #60497 (24.3):
Objectcolumns could have different types on the shards, so the header could differ. The type was removed in #85718.Now shards with the same query tree share its text, header and planner context. Shards have their own trees, and are planned separately as before, if
INmay be rewritten for each of them (optimize_skip_unused_shards_rewrite_in). So are they withserialize_query_plan, where each has its own plan to send.The overload of
createForShardthat takes an AST had no callers, so it is removed.Time of
EXPLAINfor the query of the added performance test, in milliseconds:allow_experimental_analyzer = 1The second part of #77144,
addFilters, is not changed.Tests:
05534_distributed_query_planned_once_for_all_shards,tests/performance/distributed_planning.xml.Workflow [PR]
Sync PR [sync-upstream/pr/130655]
Version info
26.11.1.2732-master(included in26.11and later)