Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-07-2020 11:21 AM
USING PERIODIC COMMIT 500
I am trying to load a csv and based on the the departmentId field starting with SUB_ then create the Label on node as ChildDepartment or ignore it.
Here i know that SUB_ will be present only in case its Child, so i can also use Contains.
I wants to check which one has good performance. or both are same.
Also Is it good to go with regex.
LOAD CSV WITH HEADERS FROM 'file:///data.csv' AS row
MERGE (dept:Department {DepartmentId: row.departmentId})
ON CREATE SET dept.Name=row.Name, dept.Count=row.count, acc.ChangedDate=timestamp(), acc.CreatedDate=timestamp(),
FOREACH (_ IN case WHEN row.departmentId STARTS WITH 'SUB_' then [1] else end | SET dept:SubDepartment)
ON MATCH acc.ChangedDate=timestamp()
RETURN count(dept);
01-07-2020 12:06 PM
In general, in any string matching starts with will always outperform contains. Since you are looking at a value you already hold in memory and doing a starts with on a short string you are unlikely to see much of a difference, but the starts with should still be faster.
If you were querying nodes and filtering them by an indexed property, then with 'starts with' it would be able to leverage the index.
01-07-2020 12:25 PM
You will need to fix up your query... FOREACH is its own clause, you can't use that within ON CREATE SET.
Additionally, since it's its own clause, you can't use it between ON CREATE SET and ON MATCH SET. Those two clauses must be adjacent to each other, with no other clauses between.
All the sessions of the conference are now available online