Skip to content

PHOENIX-6791 WHERE optimizer redesign#2428

Draft
kadirozde wants to merge 1 commit intoapache:masterfrom
kadirozde:6791
Draft

PHOENIX-6791 WHERE optimizer redesign#2428
kadirozde wants to merge 1 commit intoapache:masterfrom
kadirozde:6791

Conversation

@kadirozde
Copy link
Copy Markdown
Contributor

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.

@kadirozde kadirozde marked this pull request as draft April 28, 2026 07:58
@kadirozde kadirozde changed the title PHOENIX-6791 Replace WHERE optimizer with N-dimensional key-space model PHOENIX-6791 WHERE optimizer redesign Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant