Using Neo4J 2.1.5.

Data: 

   - 2000 Persons
   - KNOWS relationships between some of them


Goal of the query: 

For each person, display her fullname + amount of friends + amount of 
friends' friends +  amount of friends' friends' friends. 


MATCH (person:Person) 
WITH person 
OPTIONAL MATCH person-[:KNOWS]-(p:Person) 
WITH person, count(p) as f1 
OPTIONAL MATCH path = shortestPath(person-[:KNOWS*..2]-(f2:Person)) 
WHERE length(path) = 2 
WITH count(nodes(path)[-1]) AS f2, person, f1 
OPTIONAL MATCH path = shortestPath(person-[:KNOWS*..3]-(f3:Person)) 
WHERE length(path) = 3 
WITH count(nodes(path)[-1]) AS f3, person, f2, f1 
RETURN person._firstName + " " + person._lastName, f1, f2, f3


This query lasts long ! : 60 seconds ! 

Is there a tips to optimize it?

Thanks,

Michael

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to