Commit b3f67ce
Document lower bound restriction for shortestPath() and allShortestPath() functions (#1146)
Document that the shortestPath() and allShortestPath() functions can
only have a lower bound of 0 or 1 for its variable length pattern.
This is not allowed:
` MATCH p=shortestPath((a:A)-[:R*2..]->(b:B)) RETURN 1`
A lower bound can be specified using a filter, but might lead to
executing a possibly very slow fallback plan.
` MATCH p=shortestPath((a:A)-[:R*]->(b:B)) WHERE length(p)>2 RETURN 1`
The possibly very slow fallback plan is this part:
```
| | +Top | 3 | anon_1 ASC LIMIT 1 | 1 | In Pipeline 6 |
| | | +----+-------------------------------------------------------+----------------+---------------------+
| | +Projection | 4 | length(p) AS anon_1 | 1 | |
| | | +----+-------------------------------------------------------+----------------+ |
| | +Filter | 5 | length(p) > $autoint_0 | 1 | |
| | | +----+-------------------------------------------------------+----------------+ |
| | +Projection | 6 | (a)-[anon_0*]->(b) AS p | 4 | |
| | | +----+-------------------------------------------------------+----------------+ |
| | +VarLengthExpand(Into) | 7 | (a)-[anon_0:R*]->(b) | 4 | |
| | | +----+-------------------------------------------------------+----------------+ |
| | +Argument | 8 | a, b | 100 | Fused in Pipeline 5 |
| | +----+-------------------------------------------------------+----------------+---------------------+
```
Within this query plan:
```
+--------------------------+----+-------------------------------------------------------+----------------+---------------------+
| Operator | Id | Details | Estimated Rows | Pipeline |
+--------------------------+----+-------------------------------------------------------+----------------+---------------------+
| +ProduceResults | 0 | `1` | 30 | |
| | +----+-------------------------------------------------------+----------------+ |
| +Projection | 1 | $autoint_1 AS `1` | 30 | |
| | +----+-------------------------------------------------------+----------------+ |
| +AntiConditionalApply | 2 | | 30 | Fused in Pipeline 7 |
| |\ +----+-------------------------------------------------------+----------------+---------------------+
| | +Top | 3 | anon_1 ASC LIMIT 1 | 1 | In Pipeline 6 |
| | | +----+-------------------------------------------------------+----------------+---------------------+
| | +Projection | 4 | length(p) AS anon_1 | 1 | |
| | | +----+-------------------------------------------------------+----------------+ |
| | +Filter | 5 | length(p) > $autoint_0 | 1 | |
| | | +----+-------------------------------------------------------+----------------+ |
| | +Projection | 6 | (a)-[anon_0*]->(b) AS p | 4 | |
| | | +----+-------------------------------------------------------+----------------+ |
| | +VarLengthExpand(Into) | 7 | (a)-[anon_0:R*]->(b) | 4 | |
| | | +----+-------------------------------------------------------+----------------+ |
| | +Argument | 8 | a, b | 100 | Fused in Pipeline 5 |
| | +----+-------------------------------------------------------+----------------+---------------------+
| +Apply | 9 | | 100 | |
| |\ +----+-------------------------------------------------------+----------------+---------------------+
| | +Optional | 10 | a, b | 100 | In Pipeline 4 |
| | | +----+-------------------------------------------------------+----------------+---------------------+
| | +ShortestPath | 11 | p = (a)-[anon_0:R*]->(b) WHERE length(p) > $autoint_0 | 30 | |
| | | +----+-------------------------------------------------------+----------------+ |
| | +Argument | 12 | a, b | 100 | Fused in Pipeline 3 |
| | +----+-------------------------------------------------------+----------------+---------------------+
| +CartesianProduct | 13 | | 100 | In Pipeline 2 |
| |\ +----+-------------------------------------------------------+----------------+---------------------+
| | +NodeByLabelScan | 14 | b:B | 10 | In Pipeline 1 |
| | +----+-------------------------------------------------------+----------------+---------------------+
| +NodeByLabelScan | 15 | a:A | 10 | In Pipeline 0 |
+--------------------------+----+-------------------------------------------------------+----------------+---------------------+
```
Better is to use the keyword-based SHORTEST.
`MATCH p = SHORTEST 1 (a:A)-[:R]->{2,}(b:B) RETURN 1`
---------
Co-authored-by: Jens Pryce-Åklundh <[email protected]>1 parent f26f17a commit b3f67ce
1 file changed
+4
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1372 | 1372 | | |
1373 | 1373 | | |
1374 | 1374 | | |
| 1375 | + | |
1375 | 1376 | | |
1376 | 1377 | | |
1377 | 1378 | | |
| |||
1414 | 1415 | | |
1415 | 1416 | | |
1416 | 1417 | | |
1417 | | - | |
| 1418 | + | |
1418 | 1419 | | |
1419 | 1420 | | |
1420 | 1421 | | |
| |||
1427 | 1428 | | |
1428 | 1429 | | |
1429 | 1430 | | |
| 1431 | + | |
| 1432 | + | |
1430 | 1433 | | |
1431 | 1434 | | |
1432 | 1435 | | |
| |||
0 commit comments