hello guys, I have a problem when I want to load this query, it takes a very long time, up to 2 hours, does anyone know why?

LOAD CSV WITH HEADERS FROM 'file:///neo4j_new.csv' AS row
MERGE (p:Pemegang_saham {id_pejabat: row.no_identitas_pemegang_saham})
ON CREATE SET p.nama = row.nama_pemegang_saham
MERGE (c:Company {npwp_perseroan : [toString(row.npwp_perseroan)]})

ON CREATE SET
c.kategorisasi = row.kategorisasi,
c.perusahaan = row.nama_perseroan,
c.nib = [toString(row.nib)],
c.eksim = row.eksim,
c.id_pejabat = [toString(row.no_identitas_pemegang_saham)],
c.kd_fasilitas = row.kd_fasilitas
ON MATCH SET
c.id_pejabat = CASE
WHEN toString(row.no_identitas_pemegang_saham) IN c.id_pejabat
THEN c.id_pejabat
ELSE c.id_pejabat + [toString(row.no_identitas_pemegang_saham)]
END,
c.eksim = CASE
WHEN toString(row.eksim) IN c.eksim
THEN c.eksim
ELSE c.eksim + [toString(row.eksim)]
END

MERGE (p)-[r:MENJABAT_DI]->(c)
ON CREATE SET r.jabatan = row.jabatan_pemegang_saham
MERGE (c)-[:MEMILIKI_PEJABAT]->(p);

hello guys, I have a problem when I want to load this query, it takes a very long time, up to 2 hours, does anyone know why?

@mocharizal252

a. What Neo4j version?

b. how many rows in the the file neo4j_new.csv?

c. do you have indexes on the label and property which is used in the MERGE statements? i.e. for MERGE (p:Pemegang_saham {id_pejabat: row.no_identitas_pemegang_saham}) to be fast we would expect an index on :Pemegang_saham(id_pejabat);. This is simply an example, you have other MERGE statements which would benefit from indexes

What @dana_canzano recommended for indexes on both of your match properties should give you a big improvement.

Just a note, you should not need toString when importing, as load csv imports every value as a string.