Repository navigation
perf(cypher): prune named paths by any all() or none() condition - #215
Merged
Merged
Conversation
`WHERE all(r IN relationships(p) WHERE ...)` dropped a failing edge during the walk only for equalities on `r`; ranges, IN lists, OR and none() were checked once each path was complete, so their cost followed the unfiltered fan-out. The planner now turns the all() and none() conjuncts over a named path's relationships into one condition on the relationship columns, when it reads only r's properties, parameters and literals. PathMatch ANDs it into each step's per-edge check on both the CSR walk and the edge inventory. Only the condition's parameters are logical expressions of the node, so cached plans bind them per execution without DataFusion typing columns the inputs lack. A property a table lacks reads as null, and a condition that reads no column of a table is evaluated once for all its edges. The WHERE still runs, and shortest paths are left alone. Closes #207
Deploying lance-csr with
|
| Latest commit: |
245fc16
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b0cc9cef.lance-csr.pages.dev |
| Branch Preview URL: | https://perf-named-path-relationship.lance-csr.pages.dev |
prrao87
marked this pull request as ready for review
November 26, 2026 00:04
prrao87
added a commit
to MuddyBootsCode/lance-csr
that referenced
this pull request
Nov 26, 2026
Resolve conflicts with named-path CSR walks (hyperdimensionalcomputingai#211) and all()/none() pruning (hyperdimensionalcomputingai#215): - path_ops.rs: keep both the trail builders and main's csr_route. - logical_plan.rs: pass no relationship condition at the two shared-trail calls of plan_inventory_path, since only named paths have one. - operators.md: describe main's two PathMatch routes, then trails across segments of an unnamed path in their own subsection. - test_path_csr_walk.py: an unnamed multi-type segment now takes iterative CsrExpand. Rows still match the edge inventory, and on LDBC SF1 it runs in 0.5 ms instead of 2.8 ms (knows|studyAt*1..2) and 6 ms instead of 140 ms (knows|workAt*1..3).
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
#205 let
WHERE all(r IN relationships(p) WHERE ...)on a named variable-length path drop a failing relationship during the walk, but only for equalities onr. Any other condition on a single relationship was checked once each path was complete, so its cost followed the unfiltered fan-out, as in #179:This change prunes the walk for any per-relationship condition in
all()andnone().What changed
all(r IN relationships(p) WHERE x)andnone(r IN relationships(p) WHERE x)conjuncts of theWHEREinto one condition every relationship must meet, withr.keyread as the columnkeyandnoneread asNOT x. Comparisons,<>,IN,OR,IS NULL, bare booleans and parameters all qualify. This replaces the equality-only lowering from perf(cypher): prune named paths by all() equalities and accept bare booleans #205.r's properties, parameters and literals. Predicates that refer to other variables, toritself or to a nested comprehension's element stay out, as doany,single, anall()underORorNOT, and shortest paths. TheWHEREstill runs in every case, so pruning only saves work.EdgeFilterState, as before) and the edge inventory. A property a relationship table lacks reads as null. On the CSR walk, a condition that reads no column of a table is evaluated once for all of that table's edges.Validation
cargo fmt --all,cargo clippy --workspace --all-targets -- -D warningsandcargo test --workspacepass.make test(1833 passed, 2 skipped) andmake lintpass inpython/.zensical build --strictandtypos@1.52.0pass.all()/none()underOR(which is not pruned), binding a parameter twice to reuse the cached plan.Benchmark suites
Release wheels from
main(bbec0b7) and this branch (245fc16), run with theCONTRIBUTING.mdharness: both modes,mainand branch alternated twice each. Every query's result check passed on both wheels. The customgraph-benchmarksuite (100K persons, 2.4MFOLLOWSedges) runs in memory mode only. Apple M5, 24 GiB, macOS 26.6.2, load average 2.7 to 5.0. Suite commits: graph-benchmark-ldbc 1998520, graph-benchmark-ldbc-complex 220e956, graph-benchmark 66a2f51.mainrun 2 / run 1No suite query uses
all()ornone()over a named path, and no physical plan changed. The captured EXPLAIN text differs only for IC14, whose graph plan now printsrelationship_condition: None, and for IC3, whose map entries print in a different order between runs. Every per-query change is within the 15 to 20% run-to-run noise thatCONTRIBUTING.mddescribes. The largest moves are IC12 lazy (0.88) and IC2 lazy (1.05).Every query (mean ms, average of 2 runs per wheel)
graph-benchmark-ldbc / memory
geomean branch/main 1.0064; main run 2/run 1 1.0444; plans changed: none
graph-benchmark-ldbc / lazy
geomean branch/main 1.0004; main run 2/run 1 0.9990; plans changed: none
graph-benchmark-ldbc-complex / memory
geomean branch/main 0.9997; main run 2/run 1 1.0146; plans changed: ['test_benchmark_query14', 'test_benchmark_query3']
graph-benchmark-ldbc-complex / lazy
geomean branch/main 0.9981; main run 2/run 1 1.0065; plans changed: ['test_benchmark_query14']
graph-benchmark / memory
geomean branch/main 1.0038; main run 2/run 1 1.0048; plans changed: none
Rerouted shapes
The suites don't exercise this route, so the shapes it changes were timed directly on SF1 (
knowsfrom person 1131,creationDateagainst adatetimeparameter) and on a random graph (20K nodes, 600KRedges withdayin 0..57, 60KSedges with noday), on both the CSR walk and the edge inventory. Times are the best of 3 runs, minimum over 2 alternated passes per wheel, in ms. Queries were capped at 10 s. Both wheels returned the same result for every shape that finished.OR(which is not pruned), are unchanged.CsrExpandExecrule). When a condition prunes little on a short walk, those reads cost more than they save. The randomR|S *1..2shape went from 2.9 to 5.2 ms in lazy mode. On SF1*1..2the gain is small in lazy mode (about 0.95), against 0.42 in memory. Equality filters from perf(cypher): prune named paths by all() equalities and accept bare booleans #205 already behave this way.Closes #207
🤖 Generated with Claude Code