Neo4j out of memory exception when creating relationships via Neo4J Browser

26 Views Asked by At
MATCH (a:PARENT), (b:CHILD) WHERE a.id = b.id MERGE (b)-[:PART_OF]->(a)

I am running the above Neo4J query but I run into a memory exception, "the transaction size reached"

I updated the value of db.memory.transaction.max to 2g but I faced the same error when I tried to create a relationship among nodes of 2 labels. I am using Neo4j 5.17 community edition in a docker container, label A contains around 150K nodes and B contains around 280K nodes.

Can the above relationship creation be done in batches using apoc.periodic.iterate?

My machine has 16GB ram, what value should db.memory.transaction.max be set to for good performance?

1

There are 1 best solutions below

3
Christophe Willemsen On

You can use the CALL IN TRANSACTIONS OF x ROWS method to commit periodically after the desired x amount of rows

MATCH (a:PARENT), (b:CHILD) WHERE a.id = b.id 
WITH a, b
CALL {
    WITH a, b
    MERGE (b)-[:PART_OF]->(a)
} IN TRANSACTIONS OF 50_000 ROWS