cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Best Practice for Replacement of USING PERIODIC COMMIT to CALL {} IN TRANSACTIONS

omerule
Graph Buddy

Good morning,
After upgrading to version 4.4 And running some Import scripts I get new errors about ' to many current transactions'. or 'not enough memory '. This happens with importing CSV files creating merging update etc. I made the import steps small with PERIODIC COMMIT. But now it seems that PERIODIC COMMIT is Deprecated and use CALL {subquery} IN TRANSACTIONS instead. I have been able to ' transform' some of the import steps from PERIODIC COMMIT to CALL {} IN TRANSACTIONS. But I got stuck with Importing a CSV file which does something like
LOAD CSV FROM "person2computer" AS csv
CALL { WITH csv
MATCH (a:Person WHERE a.name = csv.name), (b:Computer WHERE b.computername = csv.computername)
MERGE (a)-[r:OWNS]->(b) SET r.since = csv.year etc...
} IN TRANSACTIONS
The error i now get = ' can only start inner transactions in an implicit transaction'.

What is the best practice when you want to use CALL {} IN TRANSACTIONS as a replacement for USING PERIODIC COMMIT. And what is causing the last error message?

Yours Kindly
Omer

1 ACCEPTED SOLUTION

Hi @omerule ,

When running with Neo4j Browser, prepend the query with :auto to instruct Browser so submit the query as an implicit (also known as auto-commit) transaction.

For example:

:auto LOAD CSV WITH HEADERS from "example.csv" AS line
CALL {
    with line
    CREATE (n:Example)
    SET n = line
} IN TRANSACTIONS OF 10 ROWS

You can read more about explicit vs implicit transactions here Transactions - Neo4j Cypher Manual

Best,
ABK

View solution in original post

3 REPLIES 3

Hi @omerule ,

When running with Neo4j Browser, prepend the query with :auto to instruct Browser so submit the query as an implicit (also known as auto-commit) transaction.

For example:

:auto LOAD CSV WITH HEADERS from "example.csv" AS line
CALL {
    with line
    CREATE (n:Example)
    SET n = line
} IN TRANSACTIONS OF 10 ROWS

You can read more about explicit vs implicit transactions here Transactions - Neo4j Cypher Manual

Best,
ABK

I notice the :auto is some videos Thank for explaining this and I will read the manual about Transactions, and try the translate this to the current PERIODIC COMMIT issues I have.

Yours Kindly Omer.

Unable to run my 700k mode delete query with the stated solution of prepending with `auto`

auto: MATCH (n) WHERE n.external=true CALL { WITH n DELETE n} IN TRANSACTIONS OF 10000 ROWS;

This code does still work:

CALL apoc.periodic.iterate("MATCH (n) where n.external=true return n LIMIT 700000;","DELETE n;", {batchSize:10000, parallel: true})

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online