devcrafter's Description of Work
parallel_replicas_allow_in_with_subquery = 0 disables parallel replicas for a query whose prepared
sets have subqueries, because the query-based implementation has every follower execute the IN
subquery. Plan-based creates the set on the initiator in a CreatingSet branch before the main query
and ships a fragment that only refers to the finished set, so no follower executes the subquery and
the setting has nothing to protect against. The check now applies to the query-based implementation
only.
What it costs today is the set subquery's own read, not the main one.
ParallelReplicasQueryCount for a count() filtered by IN (SELECT ... FROM <MergeTree>),
with parallel_replicas_local_plan = 0:
allow_in_with_subquery = 0
= 1
parallel_replicas_plan_based = 1, before
1
2
parallel_replicas_plan_based = 1, after
2
2
parallel_replicas_plan_based = 0, before and after
1
1
The new test asserts the two counts under plan-based and the result either way; it reads 1 for the
first row on master.
Related: https://github.com/ClickHouse/ClickHouse/pull/112351
Changelog category (leave one):
- Improvement
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
With parallel_replicas_plan_based enabled, parallel_replicas_allow_in_with_subquery = 0 no longer
switches parallel replicas off for the subquery that builds an IN set.
๐ค Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/127064]
<!-- CI automatic block end :ci_links: -->