Fix incorrect partition pruning for not IN/ not has function#96241
Merged
alexey-milovidov merged 7 commits intoClickHouse:masterfrom Feb 8, 2026
Merged
Fix incorrect partition pruning for not IN/ not has function#96241alexey-milovidov merged 7 commits intoClickHouse:masterfrom
not IN/ not has function#96241alexey-milovidov merged 7 commits intoClickHouse:masterfrom
Conversation
Contributor
|
Workflow [PR], commit [115776c] Summary: ❌
|
not has functionnot IN/ not has` function
not IN/ not has` functionnot IN/ not has function
nihalzp
commented
Feb 7, 2026
| if (adjusted_indexes_mapping.size() < set_types.size() || is_constant_transformed) | ||
| out.relaxed = true; | ||
|
|
||
| if (out.set_index->size() > 1 || out.relaxed) |
Member
Author
There was a problem hiding this comment.
As per my understanding, we do not need:
if (out.set_index->size() > 1 || out.relaxed)
relaxed = true;at all for correctness. As a side effect, it only disables exact count projection optimization which can be enabled by removing it. For example, with this check, we do not use the optimization for queries like:
CREATE TABLE test ( i UInt32 )
ENGINE = MergeTree ORDER BY i SETTINGS index_granularity = 1;
INSERT INTO test SELECT number % 30 FROM numbers(1000000);
EXPLAIN indexes = 1
SELECT count() FROM test WHERE i IN (1, 2, 3);But let's keep it for now to preserve old behavior as we will backport the fix.
alexey-milovidov
approved these changes
Feb 8, 2026
robot-clickhouse-ci-1
added a commit
that referenced
this pull request
Feb 8, 2026
Cherry pick #96241 to 25.12: Fix incorrect partition pruning for `not IN`/ `not has` function
robot-clickhouse
added a commit
that referenced
this pull request
Feb 8, 2026
…`/ `not has` function
This was referenced Feb 8, 2026
Merged
robot-clickhouse-ci-1
added a commit
that referenced
this pull request
Feb 8, 2026
Cherry pick #96241 to 26.1: Fix incorrect partition pruning for `not IN`/ `not has` function
robot-clickhouse
added a commit
that referenced
this pull request
Feb 8, 2026
clickhouse-gh bot
added a commit
that referenced
this pull request
Feb 8, 2026
Backport #96241 to 26.1: Fix incorrect partition pruning for `not IN`/ `not has` function
nihalzp
added a commit
that referenced
this pull request
Feb 8, 2026
Backport #96241 to 25.12: Fix incorrect partition pruning for `not IN`/ `not has` function
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.
For
not IN, we always had this bug:The following query gives
[0,2]but should be[0,1,2].Since 25.12, for this table:
The following query gives 936 but should be 959.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix incorrect partition pruning for
not INandnot hasfunction in some cases.Documentation entry for user-facing changes