Why does my CREATE CONSTRAINT take so long to complete

When creating a constraint, for example

CREATE CONSTRAINT ON (n:ZipCode) ASSERT n.name IS UNIQUE;

this will require a lock on all nodes with the label the constraint is being created for, in this case ZipCode

If you have another transaction which was opened prior to the CREATE CONSTRAINT Cypher statement and it has a lock on the same Node label, for example

Begin
create (n:ZipCode {name:'94401'}) return n;

then the CREATE CONSTRAINT will not progress until the open transaction is comitted/rolled back. ”’

  • Last Modified: 2020-09-23 21:26:58 UTC by Dana Canzano.
  • Relevant for Neo4j Versions: 2.3, 3.0.
  • Relevant keywords logging, server.