0

i've install the graphaware timetree, and im trying to run a range query using cypher. the query below doesnt give me the best performance. can you please advise if this is the right way?

MATCH ps=(n:Event)-[:VISIT_ON]-(m:Minute{value:0})--(h:Hour{value:0})--(d:Day{value:8})--(M:Month{value:2})--(y:Year{value:2016})  
match pe=(n1:Event)-[:VISIT_ON]-(m1:Minute{value:59})--(h1:Hour{value:23})--(d1:Day{value:8})--(M1:Month{value:2})--(y1:Year{value:2016})  
MATCH ph=shortestPath((m)-[:NEXT*]->(m1)) 
WITH nodes(ph) AS minutes
UNWIND minutes as minute 
MATCH (minute)-[:VISIT_ON]->(e:Event) 
.....
return ...
Lior Goldemberg
  • 866
  • 13
  • 26
  • 1
    There's a REST API for what you're trying to do as well, if you want the best performance. In Neo4j 3.0, you will be able to call a stored procedure directly from Cypher without needing to write the query yourself. Good times ahead. – Michal Bachman Apr 05 '16 at 08:41

1 Answers1

0

after adding relations names explicitly, and distinct at the end, it runs better.. i'm keeping it here for future reference..:

MATCH ps=(n:Event)-[:VISIT_ON]->(m:Minute{value:0})<-[:CHILD]-(h:Hour{value:0})<-[:CHILD]-(d:Day{value:8})<-[:CHILD]-(M:Month{value:2})<-[:CHILD]-(y:Year{value:2016})  
match pe=(n1:Event)-[:VISIT_ON]->(m1:Minute{value:59})<-[:CHILD]-(h1:Hour{value:23})<-[:CHILD]-(d1:Day{value:8})<-[:CHILD]-(M1:Month{value:2})<-[:CHILD]-(y1:Year{value:2016})  
MATCH ph=shortestPath((m)-[:NEXT*]->(m1)) 
with distinct nodes(ph) as minutes
return size(minutes)
Lior Goldemberg
  • 866
  • 13
  • 26