Repository navigation
Cherry pick #129339 to 26.10: Let automatic parallel replicas handle direct read from a text index - #131627
Merged
Conversation
… a text index The plan for automatic parallel replicas is optimized with `query_plan_optimize_primary_key` off, so `optimizePrimaryKeyConditionAndLimit` never builds the indexes of its reads. Direct read from a text index takes the conditions it rewrites from those indexes, so the single-node plan got `__text_index_*` virtual columns while the replicas plan kept `hasToken`. The steps hashed differently, every such query ended in `AutoParallelReplicasPlansNotComparable`, and parallel replicas were never enabled for it. Build the index conditions for a read of a table with a text index even when the pass is off. Index analysis is lazy, so this builds conditions only, and `adoptFiltersFrom` replaces them with the single-node read's if the replicas plan is chosen. On a 20M-row table with query-based parallel replicas, a `hasToken` query with `GROUP BY` now gets `AutoParallelReplicasApplied` and runs on 3 replicas instead of `PlansNotComparable`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ing them The previous commit ran `optimizePrimaryKeyConditionAndLimit` on reads of the probe plan of automatic parallel replicas. That is not condition-only: building `KeyCondition` executes the subquery of every `IN` whose set the probe plan could not adopt from the single-node plan, such as the UUID-keyed set of `query_plan_convert_join_to_in`. The subquery ran a second time even when the candidate was rejected, so a query near `max_rows_to_read` could throw `TOO_MANY_ROWS`. Adopting the single-node read's `indexes` into the probe read is no better: `updatePrewhereInfo` takes their presence as the sign that `applyFilters` ran and builds the PREWHERE sets. Leave the probe reads untouched. The builder of the probe plan gets a lookup of the single-node read each probe read stands for, paired by table expression name as `transplantAnalysisToAllReads` pairs them, and only `collectTextIndexReadInfos` uses it, for a read with no index conditions of its own. Both plans then rewrite the same text-search functions, and nothing is built that the single-node plan has not already built. The test now also checks that a JOIN converted to `IN` next to a `hasToken` predicate builds its set once and reads as many rows as without parallel replicas; with the previous commit it built the set twice. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…allel replicas Now that the plan for automatic parallel replicas rewrites its reads for direct read from a text index, `optimizeTrivialCountFromTextIndex` matched those reads. They have no index analysis, so the pass ran it over the rewritten filter, where the text index is of no use, and `force_data_skipping_indices` threw `INDEX_NOT_USED`. When the single-node plan answers the count from the text index, automatic parallel replicas does not consider the query, so the pass has nothing to do there. Failures: `02346_text_index_bug110350`, `04654_text_index_merge_with_empty_part` with `automatic_parallel_replicas_mode = 2`. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=129339&sha=latest&name_0=PR #129339 05507 also runs the query in mode 1 after collecting statistics and checks that the plan with parallel replicas is applied, is used, and returns the single-node result. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…irect-read # Conflicts: # src/Processors/QueryPlan/Optimizations/considerEnablingParallelReplicas.cpp
Let automatic parallel replicas handle direct read from a text index
Member
|
@copilot resolve the merge conflicts in this pull request |
…thub.com/ClickHouse/ClickHouse into cherrypick/26.10/129339 # Conflicts: # src/Interpreters/InterpreterSelectQueryAnalyzer.cpp # src/Processors/QueryPlan/Optimizations/considerEnablingParallelReplicas.cpp Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Contributor
🕵 Resolved and pushed in merge commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Original pull-request #129339
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Before you resolve anything
Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job