Repository navigation
perf(cypher): prune named paths by all() equalities and accept bare booleans - #205
Merged
Merged
Conversation
WHERE, WHEN and list comprehension filters rejected a boolean value on its own, so `WHERE n.active` and `r.day = 5 AND r.ok` were syntax errors. A bare value now counts as a condition on its own, next to AND or OR, or after NOT, and reads as `value = true`, so false and null both fail. A value alone in a projection stays a value.
`WHERE all(r IN relationships(p) WHERE r.day = 5)` on a named variable-length path built every path up to the maximum length and filtered afterwards, so its cost followed the unfiltered fan-out. Copy the equalities on `r` into each relationship's property map, which the path operator already checks edge by edge, so a failing edge ends that branch. The WHERE still runs. Shortest paths are left alone, since pruning would change which path is shortest. Fixes #179
Deploying lance-csr with
|
| Latest commit: |
24b084b
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ecc0a9b8.lance-csr.pages.dev |
| Branch Preview URL: | https://perf-prune-paths-by-all-pred.lance-csr.pages.dev |
prrao87
marked this pull request as ready for review
November 25, 2026 02:59
This was referenced Nov 25, 2026
This was referenced Nov 25, 2026
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.
Why
Fixes #179. A common investigation query expands a few hops with the same condition on every relationship:
lance-csr built every path up to the maximum length and applied the
all(...)filter afterwards, so the cost followed the unfiltered fan-out, not the few paths that pass. Users had to rewrite the pattern as explicit hops, one query per length.While testing, a second gap showed up: a boolean value on its own was a syntax error in any condition, so
WHERE n.activeandall(r IN relationships(p) WHERE r.day = 5 AND r.ok)both failed to parse.What changed
ANDterm of the formall(r IN relationships(p) WHERE ...)on a named path, the planner copies eachr.key = <literal or $param>into the property map of every relationship inp. The path operator already checks those maps edge by edge, so a failing edge now ends its branch during the walk. TheWHEREitself still runs, so anything not copied is still checked after the walk; it just isn't faster.any,single,OR,NOT, non-equality comparisons such asr.day >= 5, keys the inline map already sets, andshortestPath, where pruning edges would change which path is shortest.WHERE n.active,CASE WHEN n.active), next toANDorOR, or afterNOT. It reads asvalue = true, sofalseandnullboth fail, as in openCypher. A value alone in a projection, such asRETURN n.name, still parses as a value.all()behaviour next to the existing property-map note and adds bare booleans to the operator table; the internals page describes the rewrite.Validation
cargo test --workspace,cargo clippy --workspace --all-targets -- -D warningsandcargo fmtpass.make test(1800 passed, 2 skipped) andmake lintpass.zensical build --strictandtypospass.New tests: planner tests for which equalities are copied and which forms are left alone; a parser test for each bare boolean position; Python tests comparing pruned results with filtering after the walk (with and without CSR, including a
$param) and bare booleans withfalseandnullrows.Timing on the issue's repro (20,000 nodes, 3M random edges, one start node,
use_csr=True), debug builds of this branch and ofmain, best of 3, same counts on both:mainall()on*1..3all()with$dayThese are debug builds, not the release benchmark suites, and I didn't run the LANL graph. The remaining gap to explicit hops is likely the edge inventory build over all 3M edges; that isn't profiled here.
Not yet run: a check of the new queries against a second Cypher engine, and CI.
🤖 Generated with Claude Code