Repository navigation
Cherry pick #123403 to 26.9: Do not let use_skip_indexes = 0 disable part min-max pruning - #125436
Merged
robot-clickhouse-ci-2 merged 11 commits intoOct 12, 2026
Merged
Conversation
#103952 added `|| !use_skip_indexes` to `skip_analysis` of the per-part min-max condition, both in `ReadFromMergeTree::buildPartitionPruningIndexes` and in `MergeTreeData::getMinMaxCountProjectionBlock`. Since 26.5, queries with `use_skip_indexes = 0` no longer prune parts by the partition-key min-max index and read every part whose partition is not removed by the partition pruner. `use_skip_indexes` controls data-skipping indexes only. Gate the part min-max index on `use_partition_pruning` again, as before #103952 and as the partition pruner next to it already is. Fixes #123363.
The `partition_key_prunes_something` cell relied on `use_skip_indexes = 0` leaving the Min-Max stage inert, so that only the Partition stage pruned. Min-Max now prunes there too, so compare the granules left after Partition with the granules Min-Max started from instead.
With `part_minmax_index_columns = 'with_block_number_offset'` the part min-max index also covers `_block_number` and `_block_offset`. A condition on them alone made the min-max condition useful, so `force_index_by_date` did not throw `INDEX_NOT_USED` although there is no condition on the partition key. This already happened with the default `use_skip_indexes = 1`; after the previous commit it also happens with `use_skip_indexes = 0`. Require the min-max condition to use at least one partition-key column. The block number columns come after the partition-key columns in the min-max index, so it is enough to compare the used column positions.
- 04328: `use_skip_indexes = 0` no longer disables part-level min-max pruning, so it is not an unindexed oracle anymore. Use `use_partition_pruning = 0, use_statistics_for_part_pruning = 0` instead, which really reads every part. - 05317: disable the query condition cache, which ignores `use_skip_indexes`, and statistics on the #115271 table, so the `Statistics` step can not remove the part before the partition pruner runs.
…ue repro Related: #123363 Co-authored-by: Copilot <[email protected]>
…_alter_partition` `use_skip_indexes = 0` no longer disables the part-level `Min-Max` analysis, so the `pruned plan` check failed. Use parts whose `c1` range covers the searched value, so only the partition pruner can exclude one. Related: #123403 Co-authored-by: Copilot <[email protected]>
Revert the `force_index_by_date` change in `MergeTreeDataSelectExecutor` and remove `05317_minmax_pruning_with_use_skip_indexes_disabled` and `05318_force_index_by_date_minmax_block_number`, so the only new test is `05326_minmax_pruning_use_skip_indexes_repro`. Co-authored-by: Copilot <[email protected]>
…indexes Do not let use_skip_indexes = 0 disable part min-max pruning
Keep 26.9's older `04947_modulo_partition_key_alter_partition`, which lacks the `mod_prune` section the PR adjusts, and drop the edit for the missing `04328` test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 #123403
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