1
votes

match (n:A)-[r:Transaction]-(m:B) with n,count(r) num where num>1 return n

explain of query

There are 100M nodes and 250M relations in the graph. The above query is a simple group by in a relational DB and returns in < 5mins. It takes forever in Cypher, any ideas what can make it faster

1
It is possible to direct the relation? (n:A)-[r:Transaction]->(m:B).alacambra

1 Answers

2
votes

So you want nodes of type A that have more than one :Transaction relationship with one or more nodes of type B?

Try

MATCH (n:A) WHERE size((n:A)-[:Transaction]-(m:B)) > 1
RETURN n

Check out this blog post for more on efficient relationship counting.