Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-04-2019 10:54 PM
Hi all,
I have a graph data with millions of nodes which is grouped with property. For several reason, I don't use node label.
When I filter nodes which have multiple relationships, Neo4j returned "Out of memory" error and I cannot complete my query like this.
MATCH (n) WHERE n.idtype='ip'
WITH n
MATCH p=(n)-[r:have_ip]->()
WITH count(r) as cntr, p
WHERE cntr>2
RETURN p LIMIT 100
Neo.TransientError.General.OutOfMemoryError: There is not enough memory to perform the current task. Please try increasing 'dbms.memory.heap.max_size' in the neo4j configuration (normally in 'conf/neo4j.conf' or, if you you are using Neo4j Desktop, found through the user interface) or if you are running an embedded installation increase the heap by using '-Xmx' command line flag, and then restart the database.
How do I complete my query efficiently (without tweaking heap size) ?
Any comment is welcome !
Solved! Go to Solution.
02-04-2019 11:37 PM
For one, you really should be using labels, AllNodesScans are expensive.
Second, you can use the size()
of a pattern with just the relationship type and/or direction to get the degree of a relationship without paying the cost of expanding it, that's a more efficient way to get the info you need.
MATCH (n)
WHERE n.idtype='ip' AND size((n)-[:have_ip]->()) > 1
WITH n
LIMIT 50 // every node would have at least 2 relationships, so at least 100 paths total
MATCH p = (n)-[:have_ip]->()
RETURN p
LIMIT 100
02-04-2019 11:36 PM
Resolved by myself... Haha.
MATCH (n) WHERE n.idtype='ip'
WITH n
MATCH p=(n)-[r:have_ip]->()
WITH count(r) as cntr, n
WHERE cntr>2
WITH n
MATCH p=(n)-[:have_ip]->()<--()
RETURN p LIMIT 50
02-04-2019 11:37 PM
For one, you really should be using labels, AllNodesScans are expensive.
Second, you can use the size()
of a pattern with just the relationship type and/or direction to get the degree of a relationship without paying the cost of expanding it, that's a more efficient way to get the info you need.
MATCH (n)
WHERE n.idtype='ip' AND size((n)-[:have_ip]->()) > 1
WITH n
LIMIT 50 // every node would have at least 2 relationships, so at least 100 paths total
MATCH p = (n)-[:have_ip]->()
RETURN p
LIMIT 100
02-04-2019 11:38 PM
So informative. Thanks much !
All the sessions of the conference are now available online