6

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

Gady
  • 1,514
  • 2
  • 16
  • 32
  • Can you maybe share your graph somewhere? – Luanne Mar 07 '13 at 05:22
  • try http://console.neo4j.org/ and http://console.neo4j.org/usage.html – Peter Neubauer Mar 07 '13 at 10:39
  • Otherwise zip your database directory and upload it somewhere? – Luanne Mar 07 '13 at 13:02
  • 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 Mar 15 '13 at 05:25
  • 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 Mar 25 '13 at 18:59
  • What is your neo4j configuration? I second Stefan, is that the first time the query runs or a subsequent one? And sharing your graph.db directory as a zipfile would be great. – Michael Hunger May 07 '13 at 13:56

1 Answers1

2

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