Skip to content

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 into
backport/26.9/123403from
cherrypick/26.9/123403
Oct 12, 2026
Merged

robot-clickhouse-ci-2 merged 11 commits into
backport/26.9/123403from
cherrypick/26.9/123403

Conversation

@robot-ch-test-poll3

Copy link
Copy Markdown
Contributor

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-pick locally.
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:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

aschoube and others added 10 commits October 2, 2026 09:00
#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.
…_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
@robot-ch-test-poll3 robot-ch-test-poll3 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Oct 12, 2026
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]>
@robot-clickhouse-ci-2
robot-clickhouse-ci-2 merged commit bd0b43f into backport/26.9/123403 Oct 12, 2026
1 check passed
@robot-clickhouse-ci-2
robot-clickhouse-ci-2 deleted the cherrypick/26.9/123403 branch October 12, 2026 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants