You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I would create let's say 100 Person entities in a for loop, I'll have to explicitly save them inside the loop.
for (inti = 0; i < 100; ++i) {
Personp = newPerson();
p.save();
This would actually make 100 distinct requests to the database.
It would be more performant to defer the actions against the database until an explicit call. For example the code could look like the following (taken from the php-ogm ) :
for (inti = 0; i < 100; ++i {
Personp = newPerson();
session.persist(p);
}
session.flush();
The call to session.persist(Object o) only inform the session (and thus the mapping context) that this entity should be managed.
When the call to session.flush(); is made, it will actually create the 100 nodes in batch.
NB: The OGM cypher query generator is already ready for this type of implementation
UNWIND {rows} as row CREATE (n:User) SET n += row.props
But you don't really benefit from it.
Nb: Very simple example showing the benefits being 10x faster
If I would create let's say 100
Person
entities in a for loop, I'll have to explicitly save them inside the loop.This would actually make 100 distinct requests to the database.
It would be more performant to defer the actions against the database until an explicit call. For example the code could look like the following (taken from the php-ogm ) :
The call to
session.persist(Object o)
only inform the session (and thus the mapping context) that this entity should be managed.When the call to
session.flush();
is made, it will actually create the 100 nodes in batch.NB: The OGM cypher query generator is already ready for this type of implementation
But you don't really benefit from it.
Nb: Very simple example showing the benefits being 10x faster
ikwattro@8a855f4
Referenced SO question with performance improvements test :
http://stackoverflow.com/questions/38556713/why-is-neo4js-insert-speed-so-low-in-this-example
The text was updated successfully, but these errors were encountered: