Reputation: 114
I have a graph in Neo4j (3.5) containing approximately 12m nodes and 16m edges. The graph is running on a RHEL VM with 8 vCPU Cores and 8gb of Memory.
When performing updates on the graph such as the one below, I'm seeing that the updates take approximately 15 seconds to complete.
I've reviewed the Neo4j indexing recommendations and cannot find anything that indicates it will speed up the update at all. The schema for the graph shows I have create an index on the matching attribute; :Liability(Liability ID) ONLINE
MATCH (n {`Liability ID`: {liability_id}})
SET n.`Creditor Reference`= {reference},
n.`Liability Type`= {liability_type},
n.`Liability Sub-Type`= {liability_subtype}
RETURN n.`Liability ID`
Any help is appreciated.
Edit: I've also tried replacing the index with a constraint with the following schema: :Liability(Liability ID) ONLINE (for uniqueness constraint)
, this did not speed up the update and instead made it 1 second slower.
Upvotes: 1
Views: 55
Reputation: 67009
Since an index is associated with a label AND a property name, in order to use an index you must specify the label and the property name in your MATCH
pattern. If you do not specify the label in the pattern, then Cypher is forced to scan through all nodes, which prevents it from using your index.
For example, this should cause the Cypher planner to generate a plan that uses your index (the only real change is in the MATCH
clause):
MATCH (n:Liability {`Liability ID`: {liability_id}})
SET
n.`Creditor Reference` = {reference},
n.`Liability Type` = {liability_type},
n.`Liability Sub-Type` = {liability_subtype}
RETURN n.`Liability ID`;
Upvotes: 3