title: Need to optimize Neo4j Query
body: <p>I am creating a social media app whose back-end is Neo4j. Here, I want to fetch friends activities on user's homepage. I have put a limit of 10 activities per scroll.
  This is my current Neo4j Query:</p>
  <pre><code>MATCH (m:Person { id: '$id'})-[:FOLLOWS*1..1]-&gt;(f:Person)-[:HAS_ACTIVITY]-&gt;(la:Activity)-[:NEXT*0..]-&gt;(act:Activity)
  WHERE act.verb IN ['post' ,'post_media_item' ,'watch_activity'] 
  RETURN f, act ORDER BY act.published DESC LIMIT 10
  </code></pre>
  <p>In the above query user are depicted by Person node and User-feed is depicted by Activity node. &quot;m&quot; is current user whose friends &quot;f&quot; are depicted by the relationship &quot;Follows&quot;. Activity for each user are interlinked with the relationship &quot;NEXT&quot; and are linked with Person node with relationship &quot;HAS_ACTIVITY&quot;. It is intentional to keep maximum hops blank as a Person can have any number of activities.</p>
  <p>For this query as Friend List of a person grows, so does the overall query execution time.
  Currently for a user having 50 friends the time taken is 3-5 seconds.
  I have to perform further aggregation from the result of this query which takes query execution time to 7-10 seconds.</p>
  <p>Please find attached a screenshot of PROFILE and EXPLAIN:</p>
  <p><a href="https://i.stack.imgur.com/UjzVS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UjzVS.png" alt="PROFILE" /></a>
  <a href="https://i.stack.imgur.com/ioQIa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ioQIa.png" alt="PROFILE" /></a></p>
  <p>How can I optimize my Cypher query so that I get the quickest result irrespective of a number of friends?</p>
  <p>Neo4j Version used: 3.0.6</p>