Repository navigation
perf(cypher): share a filter state across an undirected step - #214
Merged
prrao87 merged 1 commit intoNov 25, 2026
Merged
Conversation
Both halves of an undirected named-path step read the same relationship table with the same filter, but each kept its own EdgeFilterState, so on Lance each could read the whole filter column into its own mask. Hops of one step over the same type now share one state. Closes #210
Deploying lance-csr with
|
| Latest commit: |
646d9ab
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://423766a2.lance-csr.pages.dev |
| Branch Preview URL: | https://perf-share-undirected-filter.lance-csr.pages.dev |
prrao87
marked this pull request as ready for review
November 25, 2026 22:41
prrao87
added a commit
that referenced
this pull request
Nov 25, 2026
* perf(cypher): walk the CSR for named trail paths Named paths (`MATCH p = ...`) built an inventory of every edge of the relationship table before walking, so a selective path over a large table paid for the whole table. When the engine has a CSR for every type and direction a trail follows, the path now walks that CSR from its start node instead, as explicit hops do. Each step checks its relationship equalities only on the edges it reaches, using the same per-edge-then-mask rule as CsrExpandExec, and relationship records are built only for returned paths, once per distinct edge in a batch. The design follows Kùzu, which evaluates relationship predicates inside recursive joins over CSR adjacency lists. Shortest paths and types without a CSR keep the edge inventory. Closes #208 * fix(cypher): give a relationship one identity on every path route The CSR walk named an edge by its row in the engine's edge store (the row address on Lance), while the edge inventory, which shortest paths still use, named it by its position in a scan. On a Lance table with several fragments or deleted rows, a trail and a shortest path in one query then disagreed: `relationships(p)[0] = relationships(q)[0]` was false for the same edge. For a relationship type the engine has a CSR for, the inventory now reads the rows the CSR stores, with their row identity, instead of scanning the table, so both routes name each edge the same way. Both routes build the identity through one helper, and the CSR route reads its rows from the same place. * perf(cypher): share a filter state across an undirected step (#214) Both halves of an undirected named-path step read the same relationship table with the same filter, but each kept its own EdgeFilterState, so on Lance each could read the whole filter column into its own mask. Hops of one step over the same type now share one state. Closes #210 * perf(cypher): skip path values the query never reads (#213) A named path whose variable nothing references still built an Arrow path value per path, and on the CSR walk read every relationship record for it. The column-pruning optimizer rule now drops the path column from PathMatch when no expression uses it, and the CSR walk skips relationship records when no output needs them.
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
When a named path walks the CSR (#211), each step checks its relationship filter only on the edges it reaches. On a Lance table it switches to one read of the whole filter column once it has checked 1/256 of the edges. An undirected step is planned as two hops over the same table, the outgoing and the incoming CSR, and each hop kept its own filter state. So each half counted its checks separately and could read the whole column into its own mask, doing the same read twice.
Closes #210.
What changed
PathMatchExecnotes the shared state.This PR is stacked on #211, whose branch it targets. It needs retargeting to
mainonce #211 merges.Validation
*1..3path on a 400k-edge Lance table. The filter column was read twice before this change and once after. The CSR walk and the edge inventory both returned the same 1,543 paths in each run.cargo test -p lance-csr --lib: 490 passed.cargo clippy -D warnings,cargo fmt --check, the strict docs build andtypospass.🤖 Generated with Claude Code