According to Chris those create-requests are not batched into few http
requests but each of them sends a separate request (not sure if they share
all one tx).

It is more efficient to batch them e.g. put 10-50k values into a list and
send it as "data" parameter to a cypher statement like this:

UNWIND {data} as value CREATE (:TestItem {index: value});

or if you have multiple properties create a list of dictionaries as param

UNWIND {data} as row CREATE (:TestItem {index: row.index, foo: row.foo,
bar: row.bar});

for merge operations you can do:

UNWIND {data} as row MERGE (t:TestItem {index: row.index}) ON CREATE SET
 t.foo=row.foo, t.bar = row.bar;

or even

UNWIND {data} as row MERGE (t:TestItem {index: row.index}) ON CREATE SET  t
+= row;

or

UNWIND {data} as row MERGE (t:TestItem {index: row.index}) ON CREATE SET  t
+= row.props;

HTH

Michael



On Fri, Feb 26, 2016 at 8:24 PM, Rob Smith <[email protected]> wrote:

> I am trying to understand the performance of Cypher Vertex creation when
> creating items with a C# client.
>
> I am using Neo4j Community Edition 2.3.2.
>
> I am creating 1,000,000 (useless) vertices in a Neo4j instance, and
> measuring how long it takes.
>
> Here is my code:
>
>             var client = new GraphClient(new Uri("
> http://localhost:7474/db/data";), "neo4j", "password");
>             client.Connect();
>
>             DateTime t = DateTime.Now;
>             Debug.WriteLine(t);
>
>             for (int j = 0; j < 100; j++ ) {
>                 using (var scope = new TransactionScope(
>                     TransactionScopeOption.Required,
>                     new TransactionOptions {IsolationLevel =
> IsolationLevel.ReadCommitted}
>                     ))
>                 {
>                     for (int i = 0; i < 10000; i++) {
>                         var index = new Category { label = i.ToString() };
>                                 client.Cypher
>                                     .Create("(class:testItem {index})")
>                                     .WithParam("index", index)
>                                     .ExecuteWithoutResults();
>                     }
>                     scope.Complete();
>                 }
>                 Debug.WriteLine(j);
>             }
>
>
>             Debug.WriteLine(DateTime.Now.Subtract(t).Seconds);
>
> .....
>     public class Category
>     {
>         public String label { get; set; }
>     }
>
> This takes 923 s, which seems far too long to me. Am I doing something
> horrifically inefficient in this code?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to