Hello
I'm working with a graph database that represents public transport and I'm trying to calculate certain shortest paths through it. The following query takes 14 seconds to complete and I'd love any help on speeding it up:
MATCH (schulort:Haltestelle { BPUIC: 8502202 })
CALL gds.alpha.shortestPath.deltaStepping.stream({
nodeProjection: 'Haltestelle',
relationshipProjection: {
FAHRT_NACH: {
type: 'FAHRT_NACH',
properties: 'Reisedauer'
}
},
startNode: schulort,
relationshipWeightProperty: 'Reisedauer',
delta: 3.0
})
YIELD nodeId AS zielId, distance AS Reisedauer
WHERE gds.util.isFinite(Reisedauer)
WITH schulort, Reisedauer, gds.util.asNode(zielId) AS ziel
CALL gds.alpha.shortestPath.write({
nodeProjection: 'Haltestelle',
relationshipProjection: {
FAHRT_NACH: {
type: 'FAHRT_NACH',
properties: 'Ausfälle'
}
},
startNode: schulort,
endNode: ziel,
relationshipWeightProperty: 'Ausfälle'
})
YIELD nodeCount AS tempCount, totalCost AS Ausfälle
CALL gds.alpha.shortestPath.write({
nodeProjection: 'Haltestelle',
relationshipProjection: {
FAHRT_NACH: {
type: 'FAHRT_NACH',
properties: 'Verspätung'
}
},
startNode: schulort,
endNode: ziel,
relationshipWeightProperty: 'Verspätung'
})
YIELD nodeCount AS tempCount2, totalCost AS Verspätung
MATCH (ziel:Haltestelle)-[:BEFINDET_SICH_IN]->(o:Ortschaft)-[:GEHOERT_ZU]->(k:Kanton)
RETURN
k.Kürzel AS Kanton,
o.Name AS Ort,
k.Mietpreis AS Mietpreis,
k.Steuerfuss AS Steuerfuss,
k.Einbrüche AS Einbrüche,
min(Reisedauer) AS Reisedauer,
min(Ausfälle) AS Ausfälle,
min(Verspätung) AS Verspätung
The execution plan is the following:
One issue I see is that the anchoring query doesn't use an index. But I'm unsure why the rest takes so long. Some help would be appreciated.