title: how to optimize cypher query using optional match clause in a big graph database?
body: <p>when I use an optional match clause in a simple cypher query like the following:</p>
  
  <pre><code>MATCH ()-[R0:relationshipclazz0]-() 
  OPTIONAL MATCH ()-[R0:relationshipclazz0]-&gt;(N0:entityclazz0)
  WITH distinct R0, R0.att0 as AR0att0, N0  
  WITH ID(R0) as i,   R0.att0 as O1,  (N0.att0) as O2, R0 
  RETURN  O1, O2, count(i) 
  ORDER BY  O1, O2
  </code></pre>
  
  <p>this query take 381 seconds in a graph database with 50 000 relationships and 6000 nodes</p>
  
  <p>please have you any idea how can I optimize this query  knowing that I have to optional match because I have null values that I want to descover in my database because using only match clause I didn't get null values</p>
  
  <p>Thanks in advance</p>