Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-09-2021 03:57 AM
Hello all,
I'm working with a fairly complex dataset (although it is only consists of ~665,000 nodes) and understand it will take a while to build... however, it seems to be taking so long that it's become clear that trying to keep things as simple as possible is not working.
Nodes were uploaded with no trouble. Relationships are taking a lot longer.
Can I please ask for advice on how to speed up this(?):
LOAD CSV WITH HEADERS FROM 'file:///test.csv' AS row
MERGE (mother:Particle {Unknown: row.Unknown})
MERGE (daughter:Particle)
CREATE (mother)-[:DECAY {Tr0Ppi: toFloat(row.Tr0Ppi), Tr1Ppi: toFloat(row.Tr1Ppi), Tr2Ppi: toFloat(row.Tr2Ppi)}]->(daughter)
SET daughter.Ptpi = toFloat(row.Ptpi)
Thank you in advance!!
03-09-2021 04:31 AM
How does this bit of your query work?
MERGE (daughter:Particle)
Should it not be finding a specific Particle
node?
03-09-2021 04:50 AM
I should have posted the node creation command(!):
LOAD CSV WITH HEADERS FROM “file:///test.csv” AS row
CREATE (particle:Particle {Unknown:row.Unknown})
SET particle.isLcBkg = toInteger(row.isLcBkg),
particle.PtLc = toFloat(row.PtLc),
particle.DecayL = toFloat(row.DecayL),
particle.DecayLXY = toFloat(row.DecayLXY),
particle.DCATr0 = toFloat(row.DCATr0),
particle.DCATr1 = toFloat(row.DCATr1),
particle.DCATr2 = toFloat(row.DCATr2),
particle.DCAMax = toFloat(row.DCAMax),
particle.CosP=toFloat(row.CosP)
I'm working with physics data that involves creating many subgraphs of nodes with triplet relationships (i.e. one node connects to three others within the subgraph).
First particles are created. Then I want to define relationships between mother and daughter particles.
The above is an attempt to connect a mother particle to its respective daughter particle, via their unique relationship.
Then, I'll repeat the process to connect to the other two types of daughter particles.
I've done it this way before - although it was over a year ago! So, I'm aware that the issue could be due to my outdated Neo4j knowledge --- or/and my poor internet connection!
03-09-2021 05:25 AM
Ok that makes sense. I'm still not understanding the daughter part of your 1st query though. The way it's written now means that the mother node will be connected to every other Particle
node in the graph...is that what you want to happen?
See my screenshot where I create two Particle
nodes and then do a MERGE (p:Particle) RETURN p
03-10-2021 12:49 AM
0 - ALWAYS create constraints before any date importation, or as soon as your graph grows up any match clause will take a year, Neo4j is not built for this kind random reading operation you absolutely need a constraint or at least an index.
1 - Use MATCH instead of MERGE to find the entity who must be related together.
2 - Use MERGE instead of match to create the relation, or you will get duplicates.
All the sessions of the conference are now available online