Hi everyone
I'm building an api(c#) when running this API i'm doing Neo4j Cypher queries. A worst case big query can consist of up to
1000 queries(creating a distance matrix), this will take about 10 minutes... I'm running this in individual queries(in same session). Is there a way to improve performance? Or should i tackle this from a different angle, model it differently, change my query, etc , all input appreciated :)
This is my cypher query:
MATCH (from:Location {name: 'A'})-[route1:Route]-(to:Location {name: 'B'})
RETURN route1.distanceInCm AS Route1Distance
I added an index on the 'name' property but this did not give any effect...
CREATE INDEX index_location_name FOR (n:Location) ON (n.name);
Wow that is amazing from 10 min to 3 seconds! Soo happy :) You are the best thanks a bunch
Modified qyery:
WITH ['A', 'B', 'C'] AS locationIds
UNWIND locationIds AS fromId
UNWIND locationIds AS toId
MATCH (from:Location {name: fromId}), (to:Location {name: toId})
OPTIONAL MATCH (from)-[route:Route]-(to)
RETURN fromId, toId, coalesce(route.distanceInCm, -1) AS distance