I have a Neo4j graph which is made up by a total of 100.000 users and 2.000.000 relationships (friendships between the users). A user has about 20 friendships.
Now I'm trying to see how much time it takes to find the friends of a specific user (depth 1), the friends of friends (depth 2) and the friends of friends of friends (depth 3).
This is the cypher queries I ran (for user with id 86660):
For depth 1
MATCH (u1:User{idUtente:"86660"})-[:FRIEND_OF]->(u2:User)
RETURN u2.name
For depth 2
MATCH (u1:User{idUtente:"86660"})-[:FRIEND_OF]->(u2:User)-[:FRIEND_OF]->(u3:User)
RETURN u3.name
For depth 3
MATCH (u1:User{idUtente:"86660"})-[:FRIEND_OF]->(u2:User)-[:FRIEND_OF]->(u3:User)-[:FRIEND_OF]->(u4:User)
RETURN u4.name
depth 1 (it returns me 17 results) and depth 2 (it returns 320 results) queries took few milliseconds while depth 3 is endless.
How can I get the result for depth3 in a reasonable time?
UPDATE
With PROFILE I get this:
PROFILE
MATCH (u1:User{idUtente:"86660"})-[:FRIEND_OF]->(u2:User)-[:FRIEND_OF]->(u3:User)-[:FRIEND_OF]->(u4:User)
RETURN u4.name
MATCH (u1:User{idUtente:"86660"})-[:FRIEND_OF*3..3]->(u2:User) RETURN u2.name
just for fun i have no clue if it will help – Tomaž Bratanič