Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-05-2020 10:24 PM
I have 200,000,000 relationships to write into my database. The data is a nested list like b = [[1, 2],[3, 4], [5, 6]]. Right I am using Neo4j Bolt Driver for Python to write data. But the writing is very slow, it would take 5 days to finish all the writing.
I am using the following query:
query='''WITH $names AS nested
UNWIND nested AS x
MERGE (w:Patent {name: x[0]})
MERGE (n:Patent {name: x[1]})
MERGE (w)-[r:NIHAO]-(n)
'''
Is there anyone who can help me with the writing? Many thanks!
Solved! Go to Solution.
02-06-2020 09:13 AM
Did you create a constraint on Patent.name
?
CREATE CONSTRAINT ON (p:Patent) ASSERT p.name IS UNIQUE
02-05-2020 11:27 PM
Is it a new database, or an existing database?
If it's a new, it's more efficient to use the neo4j-admin import tool.
If it's an existing, it can be beneficial to do the imports in parallel using apoc.periodic.iterate – but only if you can do it in a way where you are sure to avoid deadlock situations.
Also, if you are sure that the Patent's exist, it will be more beneficial to match them, rather than merge them.
02-06-2020 10:19 AM
Thanks Thomas, it's a new database. I tried neo4j-admin import, it is reaally fast. The thing is, if I use csv, I have like 1600 csvs to import, I'll try to find a way to make some Concatenation.
Also thanks for the MATCH suggestion, definitely I'll give it a try.
02-06-2020 09:13 AM
Did you create a constraint on Patent.name
?
CREATE CONSTRAINT ON (p:Patent) ASSERT p.name IS UNIQUE
02-06-2020 09:16 AM
Moreover don't try to send the 2*10^8 relationships to the UNWIND all in once, try split them in batches of 10/20k
02-06-2020 10:20 AM
Thanks Conker for let me know UNIQUE, I'll have a try.
02-06-2020 11:55 AM
Thank you Conker again, it's super fast!
All the sessions of the conference are now available online