title: How to increase the speed of cypher queries in neo4j?
body: <p>I have established a Neo4J database with 14k nodes and 15k relationships. When I run this query: </p>
  
  <pre><code>  MATCH (n:RealNode {gid:'12'})&lt;-[:contains*..4]-&gt;(z) RETURN DISTINCT ID(z), z.id,n.id as InternalID
  </code></pre>
  
  <p>it takes more than 5 secs to get a response. If I change 4 to 10 it takes much more.</p>
  
  <p>I attach a screenshot of the nodes and relations for a specific node:</p>
  
  <p><img src="https://i.stack.imgur.com/0qoiY.png" alt="enter image description here"></p>
  
  <p>My n:RealNode is the pink one and the nodes with the CONTAINS relation are the grey ones.</p>
  
  <p>My questions are the following: 
  1) How can I optimize the speed of the queries (apart from indexes).
  2) Would it make a difference in the speed if I have all the grey nodes under the pink node directly?</p>