3

I'm trying to insert a single node in my graph without any relationships and it takes 1/10 sec, so when I need to insert 10 nodes that should take 1 sec which is a lot comparing with some results I found in my google search for some people who claim to insert 30k nodes in 1 sec.
I use the neo4jclient with cypher queries to do that :

            gclient.Cypher
   .Create("(p:Post {newPost})")
   .WithParams((new
   {
       newPost = post
   }))
   .ExecuteWithoutResults();

Is there something I miss ? thanks in advance



Edit : I'm using neo4jclient with .net .

dna
  • 1,498
  • 1
  • 14
  • 35
Rawhi
  • 6,155
  • 8
  • 36
  • 57

2 Answers2

3

I'm guessing you're using a REST API client, i.e. connecting to a web endpoint. That involves of course going through multiple protocol layers (JSON, HTTP, etc), and tends to be slower.

People who are doing 30k nodes in 1 second aren't going through the REST API, they may be using batch insertion, the import tool, or possibly LOAD CSV.

FrobberOfBits
  • 17,634
  • 4
  • 52
  • 86
  • 1
    please note that it depends of the performance of the api client too (e.g. instantiation etc..), 100ms for 1 node is really slow, I can run 1200 cypher statements in around 180ms via the rest api. – Christophe Willemsen Jun 22 '15 at 20:35
  • @Christophe Willemsen , can I make a contact with you via email? I have a lot of questions about this,, but if you can't :) ,, I can ask here : how you can achieve such a result ? thanks in advance. – Rawhi Jun 22 '15 at 20:37
  • the answer is easy, small statements in one transaction and commit(); unfortunately for .net I'll not be able to help that much – Christophe Willemsen Jun 22 '15 at 20:41
  • what do you mean by small statements in one transaction and commit() ? can you give an example ? thank you – Rawhi Jun 22 '15 at 20:44
  • 1
    I think what Christophe was saying is that, when writing to the graph, you have to take into account many different things. There's the overhead/inefficiency of REST, there's the drivers, but there's also the overhead of ACID transactions. In many cases, you will need/want to tweak the size of the transactions that you are doing. if begin/commit every single write atomically, there's going to be a big overhead. If you batch several statements together in 1 transaction, the overhead per write will be smaller. That's what "small statements in one transaction" means, I believe. – Rik Van Bruggen Jun 23 '15 at 05:59
  • 1
    Generally I think everyone here has it right - the only problem you have is that `neo4jclient` doesn't handle transactions at the moment. If you're looking to get that speed and it's just a one-off type thing (initialising for example) - I would look at the import tool or load csv as @FrobberOfBits said. – Charlotte Skardon Jun 23 '15 at 06:58
0

You should also check your indexes and constraints. Unique constraints can slow down inserts and updates dramatically.

Anton Maximov
  • 251
  • 2
  • 6