How Can speed up Neo4j Importing CSV FILE

I'm using the code below to import the data, but it takes a very long time, knowing that the size of data is not large only (3.3 megabytes). Is it possible to modify the code or use another method to speed up the data import process?

code:

LOAD CSV WITH HEADERS FROM 'file:///Musae-Github.csv' as line

WITH toInteger(line.source) AS Source, toInteger(line.destination) AS Destination

MERGE (a:person {name:Source})

MERGE (b:person {name:Destination})

MERGE (a)-[:Freind ]-(b)

RETURN *

Try deleting the RETURN * statement.

Also, have an index one :person(name) property, once you are matching.

Forgot, try batching in multiple transactions using call subquery with transactions.

Hi,

try adding unique constraint on the name property if it's the case (name is unique for a given person in your data), otherwise you can add an "id" unique property for each person

you may separate the creation of persons from the creation of relations between them,

  • Create unique constraints on name property
  • Create a liste of unique persons that you import with CREATE queries (that are match faster than merge queries),
  • Create the relation FREIND, by Match(a:Person{name:}) Match(b:Person{name:}) MERGE (a)-[:Freind ]-(b)