Skip to content

Cypher MATCH predicate in write statements (MATCH...CREATE) full-scans instead of using unique index #5107

Description

@tae898

Summary

In the opencypher surface, a MATCH ... WHERE p.<prop> = <value> predicate inside a write statement (MATCH ... CREATE ...) does not use the unique index on the property — it appears to full-scan the vertex type. The same predicate in a pure read uses the index fine, and the same write expressed in SQL is ~40x faster.

Reproduce

Schema and data (100k Person vertices; also reproduced at 10k and 1M):

CREATE VERTEX TYPE Person;
CREATE PROPERTY Person.id LONG;
CREATE PROPERTY Person.name STRING;
CREATE PROPERTY Person.age INTEGER;
CREATE PROPERTY Person.city STRING;
CREATE INDEX ON Person (id) UNIQUE;
CREATE EDGE TYPE KNOWS;
CREATE PROPERTY KNOWS.since INTEGER;
-- ingest 100k Person vertices with sequential ids

Timings (p50 over 30 executions, one statement per transaction, embedded; server via HTTP shows the same shape):

statement p50
cypher write: MATCH (p:Person) WHERE p.id = 42 CREATE (q:Person {id: 900001, name: 'w', age: 33, city: 'c'}) CREATE (p)-[:KNOWS {since: 2026}]->(q) 31.6 ms
same semantics in sqlscript: CREATE VERTEX Person SET id = 900001, ...; CREATE EDGE KNOWS FROM (SELECT FROM Person WHERE id = 42) TO (SELECT FROM Person WHERE id = 900001) SET since = 2026 0.75 ms
cypher read: MATCH (p:Person) WHERE p.id = 42 RETURN p.name 0.30 ms

Scan evidence

The cypher write latency is linear in vertex count, which matches a full scan of Person for the MATCH:

Person count cypher write p50
10k 4.6 ms
100k 31.6 ms
1M 371 ms

The SQL write and the cypher read stay flat (index lookup) across all three sizes.

Environment

  • 26.7.2-SNAPSHOT (main as of early July 2026), reproduced in embedded (JVM in-process) and server (HTTP command endpoint, language=cypher) modes
  • Linux x86_64, JDK 21

Happy to provide the full benchmark harness that found this if useful.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions