Me and my team are trying to write a query where we count the number of information that is possessed by more than a given number of people. In Cypher terms, here's our query
MATCH (info:Info) WITH info, size((:Person)-[:HAS_INFO]->(info)) as peopleCount WHERE peopleCount > 3 RETURN count(info)
We currently have around 150,000
info in the database, and the query profiling of this is pretty terrible. Here's what we can see
As you can see, neo4j seem to be iterating over all the data only to count it, and indeed, this query performs really poorly (500ms).
We tried looking for a different approach that would use the count store, but we can't seem to find a way to make this query faster.
Is there a magic apoc procedure or anything that would allow us to speed up this request, considering the number of info will increase in time?