Neo4j 5.18.1: massive performance hit compared to 4.4.32

Hi @dana_canzano,

thanks you for pushing the idea of checking whether the indexes were actually created.

It turns out that I had the following code block:

for label, unique_prop_list in constraints.items():
    for unique_prop in unique_prop_list:
        try:
            self._log.debug("Graph: creating unique contraint on %s:%s", label, unique_prop)
            session.run(f"CREATE CONSTRAINT FOR (n:{label}) REQUIRE n.{unique_prop} IS UNIQUE")
        except ClientError as e:
            if e.code == "Neo.ClientError.Schema.EquivalentSchemaRuleAlreadyExists":
                continue

Which was written based on Neo4J 4.0 syntax:

Where [IF NOT EXISTS] wasn't available, hence the try catch.

And I forgot to reraise the exception !

        except ClientError as e:
            if e.code == "Neo.ClientError.Schema.EquivalentSchemaRuleAlreadyExists":
                continue
            raise e  # forgot this bit

Additionaly, the constraint syntax changed from Neo4j 4.x to Neo4j 5.x, leading to a Cypher error:

neo4j.exceptions.CypherSyntaxError: {code: Neo.ClientError.Statement.SyntaxError} {message: Invalid constraint syntax, ON and ASSERT should not be used. Replace ON with FOR and ASSERT with REQUIRE. (line 1, column 1 (offset: 0))

In conclusion, my issue was an absence of indexes due to a Cypher query that was silently failing.

Once that has been fixed, perf with 5.18.1 is even better !
45,634 total

Thank you very much for your help on this @dana_canzano and sorry for this oversight ! :rocket:

3 Likes