I am using the neo4j python API and connecting to a local database. I have a graph which contains 700.000 nodes. I can very quickly create the nodes by using:
with session.begin_transaction() as tx: cypher_query = 'UNWIND $batch as row ' \ 'CREATE (n:Node) ' \ 'SET n += row' tx.run(cypher_query, batch=batch)
The graph presents 4M relationships, and I am trying to create them in the following way:
with session.begin_transaction() as tx: cypher_query = 'UNWIND $batch as row ' \ 'MATCH (head:Node) WHERE head.id = row.head_id ' \ 'MATCH (tail:Node) WHERE tail.id = row.tail_id ' \ 'CREATE (head)-[rel:RELATIONSHIP]->(tail) ' \ 'SET rel += row.properties' tx.run(cypher_query, batch=batch)
The batch size is 10K.
The creation of the relationships is extremely slow. I calculated that it'd take around 30 days. Do you know a work around? Is it normal for it to be so slow?