Last active
August 29, 2015 14:10
-
-
Save vranac/52f453c8194065c2236a to your computer and use it in GitHub Desktop.
Neo4j relationships
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE INDEX ON :Airport(IataCode); | |
CREATE INDEX ON :Deal(OriginId); | |
CREATE INDEX ON :Deal(DestinationId); | |
MATCH (ao:Airport),(d:Deal) | |
WHERE d.OriginId = ao.IataCode | |
MERGE (ao)-[ro:ORIGIN]->(d); | |
MATCH (ad:Airport),(d:Deal) | |
WHERE d.DestinationId = ad.IataCode | |
MERGE (d)-[rd:DESTINATION]->(ad); |
This should work better than the cross product:
MATCH (ao:Airport)
MATCH (d:Deal)
WHERE d.OriginId = ao.IataCode
MERGE (ao)-[ro:ORIGIN]->(d);
same here:
MATCH (ad:Airport)
MATCH (d:Deal)
WHERE d.DestinationId = ad.IataCode
MERGE (d)-[rd:DESTINATION]->(ad);
You should be able to profile both statements in neo4j-shell
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OK, so I have two node labels, Airport and Deal.
Indexes created for them.
I need to create two type of relationships:
I triggered the creation of origin relationships on 5m deal nodes and 3.5k airports, 3.5hours later still working with some ~220k relationships created.
Can this be optimised, and is there something I am missing?