How to run the match match merge query in periodic iterate

Hello Team,

I need help in knowing how to run the MATCH MATCH MERGE query in periodic iterate.

Below is my query:

USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "file:///granite2csv_path_ONT_CKT.csv" as row
MATCH (n:SPLITTER2_IN_PORT {SPLITTER2_NAME: row.PATH_ASIDE_EQUIPMENT})
MATCH (m:SPLITTER2_OUT_PORT {SP2_OUT_PORT_NAME: row.PATH_ASIDE_PORT})',
MERGE (n)-[r:SP2_INPORT_2_SP2_OUTPORT]->(m)
return r

Please help!

Regards
Akshat

Hello Akshat,

Remove the comma after the second match. Returning the relationship is not very useful, but you can certainly do it,

Elaine

Hello Elaine,

Apologies for my mistake. , I forgot to remove that comma but in actual that comma is not present in my query. Hence I need to run the below query in periodic iterate.

Below query is taking too much time ( running from last 6 hours or elapsedTimeMillis = 20084612 ).

Please suggest better way to make this execution fast.

CSV contains 10 Lacs records.

USING PERIODIC COMMIT 1000
LOAD CSV WITH HEADERS FROM "file:///granite2csv_path_ONT_CKT.csv" as row
MATCH (n:SPLITTER2_IN_PORT {SPLITTER2_NAME: row.PATH_ASIDE_EQUIPMENT})
MATCH (m:SPLITTER2_OUT_PORT {SP2_OUT_PORT_NAME: row.PATH_ASIDE_PORT})
MERGE (n)-[r:SP2_INPORT_2_SP2_OUTPORT]->(m)
return r

Best Regards
Akshat

Hello Team ,

Please suggest on above query asked!

Thanks

Regards
Akshat

We don't recommend returning anything when doing a load (especially with PERIODIC COMMIT), try removing the RETURN.

Also, make sure you have an index on :SPLITTER2_IN_PORT(SPLITTER2_NAME) as well as on :SPLITTER2_OUT_PORT(SP2_OUT_PORT_NAME). You can double check using EXPLAIN to make sure you see two NodeIndexSeek operators and no NodeByLabelScan operators.