title: neo4j count nodes performance on 200K nodes and 450K relations
body: <p>We're developing an application based on <a href="/questions/tagged/neo4j" class="post-tag" title="show questions tagged 'neo4j'" rel="tag">neo4j</a> and <a href="/questions/tagged/php" class="post-tag" title="show questions tagged 'php'" rel="tag">php</a> with about <strong>200k</strong> nodes, which every node has a property like <code>type='user'</code> or  <code>type='company'</code>  to denote a specific entity of our application. We need to get the count of all nodes of a specific type in the graph.</p>
  
  <p>We created an index for every entity like <code>users</code>, <code>companies</code> which holds the nodes of that property. So inside <code>users</code> index resides <strong>130K</strong> nodes, and the rest on <code>companies</code>.</p>
  
  <p>With Cypher we quering like this.</p>
  
  <pre><code>START u=node:users('id:*')
  RETURN count(u)
  </code></pre>
  
  <p>And the results are</p>
  
  <pre><code>Returned 1 row.Query took 4080ms
  </code></pre>
  
  <p>The Server is configured as default with a little tweaks, but 4 sec is too for our needs. Think that the database will grow in 1 month 20K, so we need this query performs very very much.</p>
  
  <p>Is there any other way to do this, maybe with Gremlin, or with some other server plugin?
  I'll cache those results, but I want to know if is possible to tweak this.</p>
  
  <p>Thanks a lot and sorry for my poor english.</p>