Never use random within your loop, that kills your performance.
just try this:
> //insert
> int COUNT = 1000 * 1000;
> FileUtils.deleteRecursively(new File(DIRECTORY));
> GraphDatabaseService gdb = new
> GraphDatabaseFactory().newEmbeddedDatabase(DIRECTORY);
> long time = System.currentTimeMillis();
> Transaction tx = gdb.beginTx();
> nodeIndex = gdb.index().forNodes("persons");
> for (int i = 1; i <= COUNT; i++)
> {
> Node node = gdb.createNode();
> node.setProperty("name", "name"+i);
> node.setProperty("lastname", "lastname"+i);
> node.setProperty("address", "this is an address"+i);
>
> if (i % 50000 == 0)
> {
> tx.success();
> tx.finish();
> tx = gdb.beginTx();
> }
> }
> tx.success();
> tx.finish();
> time = System.currentTimeMillis() - time;
> System.out.println("import of " + COUNT + " nodes took " + time
> / 1000 + " seconds.");
> gdb.shutdown();
Am 09.02.2014 um 14:13 schrieb Mitja Rogl <[email protected]>:
> hello friends.
>
> I'm using Neo4j Java API 2.0 for importing large data of nodes(1 million).
> But the problem is that performance is very poor.
> See the code for inserting:
>
> //insert
> int COUNT = 1000 * 1000;
> FileUtils.deleteRecursively(new File(DIRECTORY));
> GraphDatabaseService gdb = new
> GraphDatabaseFactory().newEmbeddedDatabase(DIRECTORY);
> long time = System.currentTimeMillis();
> Transaction tx = gdb.beginTx();
> for (int i = 1; i <= COUNT; i++)
> {
> nodeIndex = gdb.index().forNodes("persons");
>
> Node node = gdb.createNode();
> node.setProperty("name",
> TestDataGenerator.getRandomName());
> node.setProperty("lastname",
> TestDataGenerator.getRandomLastName());
> node.setProperty("address",
> TestDataGenerator.getRandomAddress());
>
> if (i % 50000 == 0)
> {
> tx.success();
> tx.finish();
> tx = gdb.beginTx();
> }
> }
> tx.success();
> tx.finish();
> time = System.currentTimeMillis() - time;
> System.out.println("import of " + COUNT + " nodes took " + time
> / 1000 + " seconds.");
> gdb.shutdown();
>
>
>
> The performance for inserting is: 307s
> If I have just nodes without properites, the performance is much higher
> around 30s.
> Where is the catch?
>
>
> --
> 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/groups/opt_out.
--
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/groups/opt_out.