feat: cysql - optimize traversal lowering and predicate planning#104
Conversation
|
Warning Review limit reached
Next review available in: 28 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (26)
WalkthroughThis PR adds PostgreSQL optimizer decisions for exact relationship ranges and path predicates, integrates them into translation and traversal handling, updates clause reordering, expands SQL and optimizer tests, and reorganizes development and translation documentation. ChangesPostgreSQL optimization and translation
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant CypherQuery
participant BuildLoweringPlan
participant PostgreSQLTranslator
participant PostgreSQLSQL
CypherQuery->>BuildLoweringPlan: analyze exact ranges and path predicates
BuildLoweringPlan->>PostgreSQLTranslator: provide lowering decisions
PostgreSQLTranslator->>PostgreSQLTranslator: build fixed traversals and edge-ID predicates
PostgreSQLTranslator->>PostgreSQLSQL: emit joins and EXISTS/NOT EXISTS SQL
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cypher/models/pgsql/README.md`:
- Around line 4-6: Update the documentation text in the README so the reference
on line 5 consistently uses the exact capitalization “openCypher,” matching the
surrounding terminology.
In `@docs/development.md`:
- Around line 3-4: Update the documentation scope description in
docs/development.md to accurately state that the top-level README keeps the main
quick-start commands and links to detailed documentation, or move the referenced
workflow sections such as benchmarks and plan-corpus usage out of README.md.
In `@docs/postgresql_translation.md`:
- Around line 86-88: The PostgreSQL validation section embeds undated,
changeable corpus counts. Update the documentation near the
`ExactRangeExpansion` and `PathRelationshipPredicate` summary by removing the
specific totals, or replace them with a clearly labeled dated/generated snapshot
reference.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 78dcc54c-023e-45fc-94a2-86fc47bdc392
📒 Files selected for processing (26)
README.mdcmd/plancorpus/README.mdcypher/models/pgsql/README.mdcypher/models/pgsql/optimize/OPTIMIZATION_PLAN.mdcypher/models/pgsql/optimize/lowering.gocypher/models/pgsql/optimize/lowering_plan.gocypher/models/pgsql/optimize/optimizer_test.gocypher/models/pgsql/optimize/reordering.gocypher/models/pgsql/test/translation_cases/pattern_binding.sqlcypher/models/pgsql/test/translation_cases/shortest_paths.sqlcypher/models/pgsql/translate/function.gocypher/models/pgsql/translate/function_test.gocypher/models/pgsql/translate/match.gocypher/models/pgsql/translate/model.gocypher/models/pgsql/translate/optimizer_safety_test.gocypher/models/pgsql/translate/path_functions.gocypher/models/pgsql/translate/predicate_placement.gocypher/models/pgsql/translate/projection.gocypher/models/pgsql/translate/quantifiers.gocypher/models/pgsql/translate/relationship.gocypher/models/pgsql/translate/renamer.gocypher/models/pgsql/translate/renamer_test.gocypher/models/pgsql/translate/translator.gocypher/models/pgsql/translate/traversal.godocs/development.mddocs/postgresql_translation.md
💤 Files with no reviewable changes (1)
- cypher/models/pgsql/optimize/OPTIMIZATION_PLAN.md
| Recent PostgreSQL-only plan-corpus validation captured 425 PostgreSQL records. `ExactRangeExpansion` was planned and | ||
| applied in 6 cases, and `PathRelationshipPredicate` was planned and applied in 1 case, with no skipped entries for | ||
| either lowering. |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Avoid embedding undated corpus counts in evergreen documentation.
The “recent” totals will drift as fixtures and optimizer rules change. Remove them, or link to a dated/generated capture artifact and label the snapshot explicitly.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/postgresql_translation.md` around lines 86 - 88, The PostgreSQL
validation section embeds undated, changeable corpus counts. Update the
documentation near the `ExactRangeExpansion` and `PathRelationshipPredicate`
summary by removing the specific totals, or replace them with a clearly labeled
dated/generated snapshot reference.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cypher/models/pgsql/optimize/lowering_plan.go`:
- Around line 132-134: Gate dependent planning on an emitted ExactRangeExpansion
decision rather than structural eligibility. In the relevant logic, including
the branches near the reading-clause check and the classifications around lines
364 and 474, verify that decision.Target or stepTarget is present in
plan.ExactRangeExpansion before treating the range as expanded; otherwise retain
normal range traversal behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7a3c1a93-90b7-4343-9ce4-df3a2ef3e697
📒 Files selected for processing (26)
README.mdcmd/plancorpus/README.mdcypher/models/pgsql/README.mdcypher/models/pgsql/optimize/OPTIMIZATION_PLAN.mdcypher/models/pgsql/optimize/lowering.gocypher/models/pgsql/optimize/lowering_plan.gocypher/models/pgsql/optimize/optimizer_test.gocypher/models/pgsql/optimize/reordering.gocypher/models/pgsql/test/translation_cases/pattern_binding.sqlcypher/models/pgsql/test/translation_cases/shortest_paths.sqlcypher/models/pgsql/translate/function.gocypher/models/pgsql/translate/function_test.gocypher/models/pgsql/translate/match.gocypher/models/pgsql/translate/model.gocypher/models/pgsql/translate/optimizer_safety_test.gocypher/models/pgsql/translate/path_functions.gocypher/models/pgsql/translate/predicate_placement.gocypher/models/pgsql/translate/projection.gocypher/models/pgsql/translate/quantifiers.gocypher/models/pgsql/translate/relationship.gocypher/models/pgsql/translate/renamer.gocypher/models/pgsql/translate/renamer_test.gocypher/models/pgsql/translate/translator.gocypher/models/pgsql/translate/traversal.godocs/development.mddocs/postgresql_translation.md
💤 Files with no reviewable changes (1)
- cypher/models/pgsql/optimize/OPTIMIZATION_PLAN.md
✅ Files skipped from review due to trivial changes (5)
- cypher/models/pgsql/README.md
- cmd/plancorpus/README.md
- docs/postgresql_translation.md
- docs/development.md
- README.md
🚧 Files skipped from review as they are similar to previous changes (18)
- cypher/models/pgsql/translate/match.go
- cypher/models/pgsql/translate/predicate_placement.go
- cypher/models/pgsql/translate/renamer_test.go
- cypher/models/pgsql/translate/path_functions.go
- cypher/models/pgsql/translate/function.go
- cypher/models/pgsql/optimize/lowering.go
- cypher/models/pgsql/translate/quantifiers.go
- cypher/models/pgsql/translate/projection.go
- cypher/models/pgsql/translate/relationship.go
- cypher/models/pgsql/translate/function_test.go
- cypher/models/pgsql/translate/renamer.go
- cypher/models/pgsql/translate/model.go
- cypher/models/pgsql/test/translation_cases/pattern_binding.sql
- cypher/models/pgsql/translate/translator.go
- cypher/models/pgsql/translate/traversal.go
- cypher/models/pgsql/optimize/reordering.go
- cypher/models/pgsql/optimize/optimizer_test.go
- cypher/models/pgsql/translate/optimizer_safety_test.go
Description
Improves PostgreSQL Cypher planning and SQL emission for common traversal-heavy queries.
Key changes include:
*1..1and*2..2ranges to fixed traversal steps instead of recursive CTEs while preserving relationship uniqueness and path projections.ANY/NONEexpressions overrelationships(p)toEXISTS/NOT EXISTSchecks against path edge IDs, avoiding unnecessary path relationship materialization andunnestscans.Resolves: N/A
Type of Change
Testing
make test_allwithCONNECTION_STRINGset)Validation performed:
make testmake test_allrunScreenshots (if appropriate):
N/A
Driver Impact
drivers/pg)drivers/neo4j)Checklist
go.mod/go.sumare up to date if dependencies changedSummary by CodeRabbit
Summary by CodeRabbit
New Features
ANY/NONEpath-relationship predicates.startNode()/endNode()with edge-composite typing.Bug Fixes
Documentation