Repository navigation
Apply skip indexes at analysis time on tables with max_partitions_to_read - #126792
Conversation
`max_partitions_to_read` is checked in `ReadFromMergeTree::initializePipeline`, before the read. With `use_skip_indexes_on_data_read = 1` the index analysis leaves skip indexes to the read, so parts a skip index would drop still count against the limit, and a query that relies on a skip index to stay under it fails with `TOO_MANY_PARTITIONS` on a cold query condition cache. This was hidden when parallel replicas were enabled with `parallel_replicas_min_number_of_rows_per_replica > 0`: the planner's row estimate ran a full analysis with skip indexes first and filled the query condition cache. Automatic parallel replicas analyze the executed read before that estimate (or skip it), which exposed the failure. Treat `max_partitions_to_read` like `max_rows_to_read` with `read_overflow_mode = 'throw'` in `supportsSkipIndexesOnDataRead`: skip indexes are applied during index analysis when the limit is set. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [8095104] Summary: ✅
AI ReviewSummaryPR #126792 applies skip indexes during analysis when Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units124 translation units recompiled, 1526 s compile time in total, 124 of them have a recent master baseline. |
…nalysis With `parallel_replicas_local_plan = 1` and `parallel_replicas_index_analysis_only_on_coordinator = 1` a follower skips index analysis and keeps every part, leaving range assignment to the coordinator. `checkLimits` then counted those parts against `max_partitions_to_read`, so the follower failed with `TOO_MANY_PARTITIONS` even though the coordinator pruned the read to fewer partitions. The initiator tolerated the failed replica, which silently lost its share of the work. The initiator still checks the limit on the coordinator's analysis. The test now disables the row limits of the test profile, which already turned read-time skip indexes off and made it pass without the fix, and the query condition cache, so earlier queries cannot prune the parts for later ones. It also covers the follower case. Addresses the AI review: #126792 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # src/Processors/QueryPlan/ReadFromMergeTree.cpp # src/Processors/QueryPlan/ReadFromMergeTree.h
…_done_on_initiator` The old name read like a mirror of `parallel_replicas_index_analysis_only_on_coordinator`, while the field is set only on a follower that skipped its own analysis. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… plan A follower skipped its own index analysis whenever `parallel_replicas_local_plan` was set, but the initiator builds no local plan with `parallel_replicas_prefer_local_replica = 0`, inside a `Distributed` sub-query, or when the leaf timeout disables it. Then nobody analyzed the indexes, and since the previous commit nobody checked `max_partitions_to_read` either: a remote-only parallel read went past the limit. Use `ClusterProxy::canUseLocalPlanForParallelReplicas`, which decides whether the initiator runs a local plan, so in the other cases the followers analyze and check the limit themselves. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cherry pick #126792 to 26.10: Apply skip indexes at analysis time on tables with `max_partitions_to_read`
…les with `max_partitions_to_read`
Backport #126792 to 26.10: Apply skip indexes at analysis time on tables with `max_partitions_to_read`
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
TOO_MANY_PARTITIONSfor queries on tables withmax_partitions_to_readwhose filter rules out partitions only through a skip index: withuse_skip_indexes_on_data_readenabled and a cold query condition cache, parts that the skip index would drop were counted against the limit. Skip indexes are now applied during index analysis whenmax_partitions_to_readis set.max_partitions_to_readis checked inReadFromMergeTree::initializePipeline, before the read. Withuse_skip_indexes_on_data_read = 1(the default), index analysis leaves skip indexes to the read, so parts that a skip index would drop still count against the limit. A query that relies on a skip index to stay under the limit therefore fails withTOO_MANY_PARTITIONSon a cold query condition cache, even without parallel replicas.The failure was hidden for users with parallel replicas and
parallel_replicas_min_number_of_rows_per_replica > 0: the planner's row estimate runs first, applies skip indexes during its own analysis and fills the query condition cache, so the executed read then drops those parts from the cache. Automatic parallel replicas analyze the executed read before that estimate, or skip the estimate for plan shapes without a probe plan, which exposed it.supportsSkipIndexesOnDataReadalready turns read-time skip indexes off formax_rows_to_readwithread_overflow_mode = 'throw', a limit that is also checked before the read.max_partitions_to_read(query setting if changed, otherwise the table setting, as incheckLimits) is now treated the same way. The cost is that tables with a partition limit no longer get read-time skip indexes.Workflow [PR]
Sync PR [sync-upstream/pr/126792]
Version info
26.11.1.438-master(included in26.11and later)26.10.2.68