Loading data with LOAD CSV using batching
When you have a large amount of data, then you should try to commit the data in batches so that you do not need a large heap to process the data.
There are two options to process the data in batches.
USING
PERIODIC COMMIT
CALL
IN TRANSACTIONS
Let’s now go through these two options next.
USING PERIODIC COMMIT
This is an older syntax and is deprecated from Neo4j 4.4 version onward, but if you are using Neo4j software prior to this version, then you must use this option to commit data in batches:
:auto USING PERIODIC COMMIT 1 LOAD CSV WITH HEADERS from "file:///data.csv" AS row WITH row MERGE (p:Person {id:row.id}) SET p.firstName = row.firstName, p.lastName = row.lastName
This command will execute a commit after processing one row at a time.
CALL IN TRANSACTIONS
This is the newer syntax and is available from Neo4j 4.4 onward:
:auto LOAD CSV WITH HEADERS from ...