Repository navigation
Improve prewhere optimization for conditions like func(primary_column) = 'xx' and column in (xxx) - #85529
Merged
Conversation
Contributor
|
Workflow [PR], commit [96fc362] Summary: ❌
|
func(primary_column) = 'xx' and func(column) in (xxx) func(primary_column) = 'xx' and column in (xxx)
Contributor
Author
|
@alexey-milovidov hope for your reviews, thanks very much! |
hanfei1991
reviewed
Aug 26, 2025
Member
|
looks like |
Contributor
Author
|
@hanfei1991 thanks for your reviews! Let's wait for next CI. |
hanfei1991
approved these changes
Aug 27, 2025
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.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Improve prewhere optimization for conditions like
func(primary_column) = 'xx'andcolumn in (xxx)For example:
lower(country) = 'cn', and country is one of the primary index columns, we should not move the condition to the end of prewhere even ifmove_primary_key_columns_to_end_of_prewhereis enabled. Becauselower(country) = 'cn'can't make use of primary index. We should decide its position in prewhere conditions according to compressed column sizes and estimated rows(if allow_statistics_optimize is enabled).value in ('x', 'y', 'z'), its estimated selectivity is always1.0because current process aboutinfunctions is not right inConditionSelectivityEstimator::extractAtomFromTree. This PR fixed it.Documentation entry for user-facing changes