Skip to content Skip to sidebar Skip to footer

Query Writing Performance On Neo4j With Py2neo

Currently im struggle on finding a performant way, running multiple queries with py2neo. My problem is a have a big list of write queries in python that need to be written to neo4j

Solution 1:

You may want to read up on Michael Hunger's tips and tricks for fast batched updates.

The key trick is using UNWIND to transform list elements into rows, and then subsequent operations are performed per row.

There are supporting functions that can easily create lists for you, like range().

As an example, if you wanted to create 10k nodes and add a name property, then return the node name and its graph id, you could do something like this:

UNWIND range(1, 10000) as index
CREATE (n:Node {name:'Node ' + index})
RETURN n.name as name, id(n) as id

Likewise if you have a good amount of data to import, you can create a list of parameter maps, call the query, then UNWIND the list to operate on each entry at once, similar to how we process CSV files with LOAD CSV.


Post a Comment for "Query Writing Performance On Neo4j With Py2neo"