6
votes

I'm trying to find out why my cypher query is running so slow (2-5 seconds for only 5000 nodes). The query is trying to find all the jobs the a profile can reach inside his network (a job the his friends or his friends of friends work in the same company)

This is the query :

Start current_profile= node:node_auto_index(neoid_unique_id = "Profile:1")
 Match current_profile-[r:friendships*0..2]->friends-[:roles]->company-[:positions]->jobs
 return distinct company.fmj_id

I tried trimming down the query to see what I'm doing wrong and even this simple query takes too long:

START root=node(0)
Match root-[:job_subref]->j-[:jobs]->jobss
return jobss

Am I doing anything wrong?

I'm using neoid that is based on neography gem

1
Can you maybe share your graph somewhere?Luanne
Otherwise zip your database directory and upload it somewhere?Luanne
Maybe, that would help you (in my case I gained much speed-up with this trick): split your match statement by using with statement, i.e., first match current_profile-->friends, then friends-->company and finally company-->jobs within single cypher query.npobedina
is the slowness upon first call (after starting up neo4j) or after a subsequent call? Remember Neo4j benefits a lot from warmed up caches.Stefan Armbruster

1 Answers

2
votes

What about trying this query

Start current_profile= node:node_auto_index(neoid_unique_id = "Profile:1")
Match current_profile-[r:friendships*0..2]->friends
WITH friends
friends-[:roles]->company-[:positions]->jobs
RETURN company.fmj_id