perf(parser): elide redundant static edge type filters - #2559
Draft
linhongyu510 wants to merge 2 commits into
Draft
perf(parser): elide redundant static edge type filters#2559linhongyu510 wants to merge 2 commits into
linhongyu510 wants to merge 2 commits into
Conversation
Add an EXPLAIN regression that expects a statically typed relationship predicate to produce the same filter-free plan as the equivalent MATCH without the redundant type check.\n\nRefs apache#2481
Preserve non-redundant predicates and avoid mutating the original OPTIONAL MATCH WHERE tree. Refs apache#2481
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.
Summary
type(r) = "<label>"when the same fixed-length relationship variable is already constrained byMATCH ... [r:<label>]OPTIONAL MATCHWHERE treeCorrectness boundary
The rewrite is intentionally conservative. It only handles a direct equality whose left side is
type(<single relationship variable>)and whose right side is the exact static relationship label. It does not rewrite OR expressions, unlabeled relationships, variable-length relationships, mismatched labels, or ambiguous repeated bindings.Verification
master: the EXPLAIN regression failed because thePrelationship scan still contained_label_name(...) = "P"expr,cypher_match, andcypher_vlepassedBenchmark
20,000
(:X)-[:P]->(:Y)relationships, 12 alternating query pairs in an isolated PostgreSQL 18.6 container:type(r)medianmasterAll 24 measured queries returned
20000. This demonstrates removal of the redundant runtime filter in this environment; it does not claim universal absolute latency.Closes #2481
Implementation and verification were AI-assisted. I reviewed the AST constraints, final diff, regression output, and benchmark results before submission.