Skip to content

Conversation

@rsill-neo4j
Copy link
Contributor

No description provided.

Comment on lines 664 to 667
. It only supports exact seeks on range indexes (no full text or spatial).
. The index order cannot be leveraged, so the planner must insert separate ordering if required later on in the query.
. Parallel runtime seeks and scans are single-threaded.
. The planner doesn't combine multiple property index seeks when generating the results for the dynamic part of the query. For example, using `$any` in combination with multiple labels that share an index on a property result in the planner choosing one of the indexes based on selectivity and then stepping through the seek results and filtering for the remainder of the expression.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • These come out as numbered. Should they be bullet pointed instead?
  • The last point is quite hard to follow. Maybe some example cypher could help? e.g.
CREATE RANGE INDEX actor_has_birthyear FOR (a:Actor) ON (a.birthYear)
CREATE RANGE INDEX director_has_birthyear FOR (d:Director) ON (d.birthYear)

// The below MATCH can leverage one of the indexes, but not both
MATCH (p:$any(["Actor", "Director"]) { birthYear: 1983 }) RETURN p.name

Also, on the last point: it is technically the operator that does this index selection and filtering, not the planner. (I'm assuming we try to make the distinction in the docs between planning and runtime/operator phases. You tell me though!)

Comment on lines 67 to 70
CREATE RANGE INDEX actor_has_birthyear FOR (a:Actor) ON (a.birthYear)
CREATE RANGE INDEX director_has_birthyear FOR (d:Director) ON (d.birthYear)
MATCH (p:$all(["Actor", "Director"]) {birthYear: 1983}) RETURN p.name

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this example is a bit confusing in combination with the caveat overleaf which states we can't actually use both the indexes for the MATCH. Perhaps this would be better:

CREATE RANGE INDEX actor_has_birthyear FOR (a:Actor) ON (a.birthYear);

// The below MATCH can leverage the created index and then filter for the Director label
MATCH (p:$all(["Actor", "Director"]) { birthYear: 1983 }) RETURN p.name;

Copy link

@jamthief jamthief Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or perhaps - worth checking with Matthew Wood which he prefers - a LOAD CSV example:

// people.csv
label,name,birthYear
Actor,Henry Cavill,1983
CREATE RANGE INDEX actor_has_name_and_birthyear FOR (a:Actor) ON (a.name, a.birthYear);

LOAD CSV WITH HEADERS FROM 'people.csv' AS row
// The below MERGE can leverage the index to check for existence before a CREATE
MERGE (:$(row.label) { name: row.name, birthYear: row.birthYear) })

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I like the LOAD CSV example better, if that helps!

Copy link

@jamthief jamthief left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Minor last comments, so approving proactively. 🍪


[source, cypher, role=test-skip]
----
CREATE RANGE INDEX actor_has_name_and_birthyear FOR (a:Actor) ON (a.name, a.birthYear);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why I made this more complicated than it needs to be now 😕

The point can still be illustrated with a single property index. Feel free to slim it down, or leave as is.

// people.csv
label,name
Actor,Henry Cavill
CREATE RANGE INDEX actor_has_name FOR (a:Actor) ON (a.name);

LOAD CSV WITH HEADERS FROM 'people.csv' AS row
// The MERGE below can leverage the index to check for existence before a CREATE
MERGE (:$(row.label) { name: row.name })

@neo4j-docops-agent
Copy link
Collaborator

This PR includes documentation updates
View the updated docs at https://neo4j-docs-cypher-1440.surge.sh

Updated pages:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants