Repository navigation
perf(planner): plan a path whose name nothing reads as the unnamed pattern - #237
Merged
Merged
Conversation
…ttern A named path reads its label's node table in full into PathMatch, even when the query only counts paths or returns their ends. When the name appears nowhere else in its query, drop it before planning, so the path gets the plan it would get unnamed. Add a test that equivalent phrasings of a query get one physical plan and one answer.
Deploying lance-csr with
|
| Latest commit: |
9e9fdc2
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ffe959f4.lance-csr.pages.dev |
| Branch Preview URL: | https://perf-named-path-inventory.lance-csr.pages.dev |
7 of 16 tasks
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.
Part of #223.
Why
A named path is planned with
PathMatch, which reads its label's node table in full, every column, into an inventory of nodes for building path values. It does that even when nothing reads the path.MATCH p = (c:Account {id: 1})-[:T*1..2]->(d) RETURN count(*)therefore read 20,000 accounts with their 500-byte notes, while the same pattern withoutp =read one row. In the shape suite's phrasing group, which writes one query eight equivalent ways, the named phrasings were 2.8 times slower than the unnamed ones in memory mode and 7.1 times slower in lazy mode, with 92 MiB peak memory against 2 MiB.What changed
PathMatch. A name that is read, or only passed along (WITH b, p RETURN count(b)), keepsPathMatchas before.d.name = 'p') keeps the path named. That case plans exactly as before.test_plan_equivalence.pywrites four queries several ways each (anchor inline or inWHERE, pattern written from either end, path named or unnamed) and checks that each query gets one physical plan and one answer, with Arrow tables and with Lance datasets.PathMatchExec: endpointsfor unread paths now expect the unnamed plan, and the docs describe the rule (cypher.md,internals/operators.md,internals/optimizer.md).One phrasing difference is left. When a query reads the path (
RETURN length(p)), its anchor written inWHEREis pushed into the start scan (#225), but theWHEREalso stays abovePathMatchas a redundant filter, so that plan differs from the inline phrasing's by oneFilterExec. Removing it means tracking whichWHEREeach pushed condition came from, so the new test leaves that case out. I've left the #223 item "Tests assert that equivalent phrasings of a query get the same plan" for you to judge.Validation
cargo test --workspace,cargo clippy --workspace --all-targets -- -D warnings,make test(1,836 passed),make lint, the strict docs build andtypospass locally. CI has not run yet.CONTRIBUTING.md: release wheels frommain(93d7268) and this branch (9e9fdc2), alternatingmainand branch twice each,memoryandlazy. Every answer check and every shape-suite phrasing and plan check passed.main). No SF1 query has a named path other than a shortest path, so SF1 moves below are noise.Shape suite headlines (
smallgraph):Only the four named phrasings moved by 10% or more: 1.40–1.44 ms to 0.51–0.52 ms (−64%) in memory mode, 4.53–4.61 ms to 0.65–0.66 ms (−86%) in lazy mode, and peak memory 10.4 to 1.7 MiB and 92.5 to 2.1 MiB. The lazy
early_exitnotes headline moved becausehop_limit_notesran 7% slower; that query has no named path and the same plan on both wheels.SF1 suites:
mainmainrun 2 / run 1graph-benchmark-ldbc in memory mode was noisy:
main's two runs differed by up to 21% on one query. q16 (+11%) and q30 (−12%) moved by 10% or more, both within that spread and with unchanged plans.Machine: Apple M5 MacBook Pro, 24 GB, macOS 26.6.2. Load average about 10 when the run started, right after the release builds, and 3.1 to 7.8 later on; another terminal app was also running.
Every SF1 query
graph-benchmark, memory
Geomean branch/main: 0.996; main run 2 / run 1: 0.996 (largest single-query main gap 2%)
graph-benchmark-ldbc, memory
Geomean branch/main: 1.002; main run 2 / run 1: 1.067 (largest single-query main gap 21%)
graph-benchmark-ldbc, lazy
Geomean branch/main: 1.000; main run 2 / run 1: 1.003 (largest single-query main gap 4%)
graph-benchmark-ldbc-complex, memory
Geomean branch/main: 0.994; main run 2 / run 1: 0.987 (largest single-query main gap 8%)
graph-benchmark-ldbc-complex, lazy
Geomean branch/main: 0.982; main run 2 / run 1: 1.021 (largest single-query main gap 6%)
🤖 Generated with Claude Code