PHOENIX-6791 WHERE optimizer redesign#2428
Draft
kadirozde wants to merge 1 commit intoapache:masterfrom
Draft
Conversation
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.
Introduces a v2 WHERE optimizer in compile/keyspace/ that models each expression as a list of per-PK-column KeyRange tuples (KeySpace), with AND as per-dim intersection and OR governed by containment + equal-on-N-1 merge rules. Key-range conversion is deferred until trailing dims are dropped against a cartesian bound, making the algorithm O(N^2) in PK arity. RVC inequalities and IN lists are lowered to lexicographic OR-of-AND form in a single ExpressionNormalizer pass so per-dim intersection composes uniformly with every other predicate.
Feature flag phoenix.where.optimizer.v2.enabled routes WhereOptimizer .pushKeyExpressionsToScan to the v2 driver; default is now true. The legacy implementation is untouched and remains the fallback when the flag is disabled. All 138 WhereOptimizerTest methods pass under both flag values; 37 byte-shape divergences are captured in isV2Optimizer() branches with verbose comments explaining why v2 differs from v1 (DESC encoding, RVC clip, tautology simplification, trim-trailing, scalar-function composition limits, filter shape). 37 new keyspace- level unit tests cover the algebra, normalization, visitor, and extractor in isolation.