Skip to content

Commit 0950ed0

Browse files
authored
Merge pull request ldbc#338 from ldbc/cypher-path-query-opt
Cypher path query optimizations
2 parents 6090f61 + b554d36 commit 0950ed0

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ workflows:
99

1010
jobs:
1111
test:
12-
resource_class: large
12+
resource_class: xlarge
1313
machine:
1414
image: ubuntu-2204:2022.04.1
1515
steps:

cypher/queries/interactive-complex-13.cypher

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
8796093022357 AS person2Id
66
}
77
*/
8-
OPTIONAL MATCH // the 'OPTIONAL' modifier can be deleted if the parameter curation ensures that both person1 and person2 exist
8+
MATCH
99
(person1:Person {id: $person1Id}),
1010
(person2:Person {id: $person2Id})
1111
OPTIONAL MATCH

cypher/queries/interactive-complex-14.cypher

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ YIELD graphName
1313
WITH count(*) AS dummy
1414
// ----------------------------------------------------------------------------------------------------
1515

16+
// Check whether a path exists -- if there is no path, the query will return an empty result
17+
MATCH
18+
path = shortestPath((person1 {id: $person1Id})-[:KNOWS*]-(person2 {id: $person2Id}))
19+
20+
// ----------------------------------------------------------------------------------------------------
21+
// the actual values are not important,
22+
// we are only interested in whether there is a row or not
23+
WITH 42 AS dummy
24+
// ----------------------------------------------------------------------------------------------------
25+
26+
MATCH (person1:Person {id: $person1Id}), (person2:Person {id: $person2Id})
1627
CALL gds.graph.project.cypher(
1728
'q14graph',
1829
'MATCH (p:Person) RETURN id(p) AS id',
@@ -32,10 +43,9 @@ CALL gds.graph.project.cypher(
3243
YIELD graphName
3344

3445
// ----------------------------------------------------------------------------------------------------
35-
WITH count(*) AS dummy
46+
WITH person1, person2
3647
// ----------------------------------------------------------------------------------------------------
3748

38-
MATCH (person1:Person {id: $person1Id}), (person2:Person {id: $person2Id})
3949
CALL gds.shortestPath.dijkstra.stream(
4050
'q14graph', {sourceNode: person1, targetNode: person2, relationshipWeightProperty: 'weight'}
4151
)

0 commit comments

Comments
 (0)