1
votes

I have a cypher query

match (n)-[r]->(m) where n.value in L return n.id, m.id

and L is a list with size 10K. It took forever for the query to finish. How Neo4j process this query? Would it run the query in parallel? If I manually partition L to several lists and run several sub-queries with each sub-list, then merge the results from sub-queries, will that help?

1
Hi, I think the modelling is not right here, but apart from that, do you have an index on that property? - utnaf
@utnaf is exactly right. You should index on n.value and include a USING INDEX statement right after the match and before the where. - Adrian Keister

1 Answers

1
votes

Create an index if not yet existing then use UNWIND which is like a 'for loop'.

1. CREATE INDEX index_name IF NOT EXISTS FOR (n:Foo) ON (n.value)

2. Run below query

   WITH ['value0', 'value1',...'value9999'] as L
   UNWIND L as inputValue
   MATCH (n)-[r]->(m) WHERE n.value = inputValue
   RETURN n.id, m.id