I have a simple graph model. In this graph, Each node has an attribute {NodeId}. Each Edge will link two nodes without other attributes. It is an directed graph and has about 10^6 nodes.
Here is my situation: I created index on attribute {NodeId} at first.Then I created 10^6 nodes. In this time, I have a graph with 10^6 nodes and no edges. When I want to randomly add edges, I found that the speed is very slow. I can only add about 40 edges per second.
Did I miss any configurations? I don't think this is a reasonable speed.
The Code for adding edges:
public static void addAnEdge(GraphClient client, Node a, Node b)
{
client.Cypher
.Match("(node1:Node)", "(node2:Node)")
.Where((Node node1) => node1.Id == a.Id)
.AndWhere((Node node2) => node2.Id == b.Id)
.Create("node1-[:Edge]->node2")
.ExecuteWithoutResults();
}
Should I add index on edges? If so, How to do it in neo4jClient? Thanks for your help.
Batch all my queries into one transaction is a good ieal. I execute following statement in my browser(http://localhost:7474):
MATCH (user1:Node), (user2:Node)
WHERE user1.Id >= 5000000 and user1.Id <= 5000100 and user2.Id >= 5000000 and user2.Id <= 5000100
CREATE user1-[:Edge]->user2
In this statement I create 10000 edges in one transaction. So I think the http overhead is not so serious now. The result is:
Created 10201 relationships, statement executed in 322969 ms.
That means I add 30 edges per second.