0
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 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

3 Comments

Why do we need 2 WITH? I am new to cypher but with just make a,b the only variables in the query right?
the first WITH is needed to break from a MATCH clause to a CALL clause, the WITH inside the subquery is needed to imported variables from the outer scope to the inner scope.
The first WITH is not actually needed in that query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.