简体   繁体   中英

Cypher slowly create relations with some type nodes

I have one type of node and one type of relationship.

USING PERIODIC COMMIT 500
load csv from 'http://host.int:8787/rel_import.csv' as line FIELDTERMINATOR ';'
match(c1)
with c1,line, trim(line[0]) as abs1, trim(line[1]) as abs2
match(c2)
where (c1.abs = abs1 and c2.abs = abs2) or (c1.abs = abs2 and c2.abs = abs1) 
create (c1)-[rel:relations{abs1:line[0], abs2:line[1], kind:line[2],personId:line[3], rel_k1:line[4], rel_k2:line[5],contact:line[6], id:line[7]}]->(c2)

So, it was fast.

I div one type node (now five types, old type deleted, summary count of entities not changed), and have problem with speed creating relationship. structure of nodes not changed, indexes created for all types.

How do it right?

I think the problem is the where clause in your join is complex. I find complex where clauses on joins cause it to be really slow. Could you do: "where c1.abs <> c2.abs?"

Are you able to do something like this:

USING PERIODIC COMMIT 500
load csv from 'http://host.int:8787/rel_import.csv' as line FIELDTERMINATOR ';'
with line, trim(line[0]) as abs1, time(line[1] as abs2
match(c1{abs: abs1})
match(c2 {abs:abs2})
match c3 {abs: abs2})
match c4 {abs: abs1})
where c1.abs <> c2.abs and c3.abs <> c4.abs
create (c1)-[rel:relations{abs1:line[0], abs2:line[1], kind:line[2],personId:line[3], rel_k1:line[4], rel_k2:line[5],contact:line[6], id:line[7]}]->(c2)
create (c3)-[rel:relations{abs1:line[0], abs2:line[1], kind:line[2],personId:line[3], rel_k1:line[4], rel_k2:line[5],contact:line[6], id:line[7]}]->(c4)

If possible I'd break up the match c1, c2 and the match c3, c4 and run LOAD CSV twice, I find it's best when possible to do fewer steps within the LOAD CSV.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM