Hi folks
I'm sending a command through the Neo4j Python driver where I am executing a session.run()
and giving a query string + JSON object as a parameter. The JSON object is a list of records that I'm iterating through on the other end to make relationships between nodes.
The query, as-is, partially works. I'm making 291 Python requests to the database which is currently making 1804 relationships and has 44 failures. It is the failures that bring me here.
From the debug I can see there are no relationships being created greater than 10, and the failures are giving me a CartesianProduct
notification leading me to believe the failures are the result of wanting to make more than 10 relationships but the database is refusing because the query needs optimising.
Here's the query:
CALL apoc.load.json($saleslist) YIELD value
UNWIND value.data AS record
MATCH (a:thesenodes), (b:thosenodes) WHERE
b.spec_id = record.that_val_1 AND
a.other_id = record.that_val_2 AND
a.third_id = record.that_val_3
CREATE (b)-[r:TEST_RELATIONSHIP {date: DATETIME(record.that_val_4)}]->(a)
RETURN (r);
My database has indexes for the node properties used in the MATCH
.
Is it possible to optimise this query? Could there be some pre-processing on the loaded JSON records where all values of a specific key are placed into a LIST
and only nodes (belonging to either a
or b
) are referenced according to what is in the list?