title: neo4j complex hieharchical Cypher query slow performance
body: <p>I have a complex hierarchical query which looks like this:</p>
  
  <pre><code>MATCH (comp:Company {id: 7})-[:HAS_SPACE]-&gt;(s:Space)-[:HAS_BOARD]-&gt;(b),
  (col)&lt;-[:HAS_COLUMN]-(b)-[:HAS_LANE]-&gt;(lane)
  OPTIONAL MATCH (b)-[:HAS_CARD]-&gt;(card {archived: false}),
  (cardCol:Column)-[:HAS_CARD]-&gt;(card {archived: false})&lt;-[:HAS_CARD]-(cardLane:Lane)
  WITH s, b, col, lane, { id: card.id, title: card.title, sort_order: card.sort_order, column_id: cardCol.id, lane_id: cardLane.id } as crd
  WITH s, { id: b.id, title: b.title, left: b.left, top: b.top,
  columns: collect(distinct {id: col.id, title: col.title, col_count: col.col_count, sort_order: col.sort_order}), 
  lanes: collect(distinct {id: lane.id, title: lane.title, row_count: lane.row_count, sort_order: lane.sort_order}), 
  cards: collect(distinct crd)} as brd 
  RETURN {id: s.id, title: s.title, boards: collect(distinct brd)}
  </code></pre>
  
  <p>This query slows down to 10 sec when number of cards becomes about 200. What is the problem with it and also how can I profile it? Looks like there is a PROFILE keyword, but the output doesn't look like really informative. Btw, we are using GrapheneDB on heroku.</p>