Part 4 — Using Indexes and Query Best Practices in Neo4j 4.x
2 min readOct 16, 2023
Defining Constraints for your Data
- Create a uniqueness constraint for a node property in the graph.
- Create an existence constraint for a node property in the graph.
- Create a uniqueness constraint for a set of node properties in the graph.
- Manage constraints in the graph.
Using Indexes
- Describe when indexes are used in Cypher.
- Create a single property index.
- Create a multi-property index.
- Create a full-text schema index.
- Use a full-text schema index.
- Manage indexes:
- List indexes.
- Drop an index.
- Drop a full-text schema index.
Using Query Best Practices
Use parameters in your Cypher statements
MATCH (p:Person)-[:ACTED_IN]->(m:Movie)
WHERE p.name = $actorName
RETURN m.released, m.title ORDER BY m.released DESC
Analyze Cypher execution
There are two Cypher keywords you can prefix a Cypher statement with to analyze a query:
EXPLAIN
provides estimates of the graph engine processing that will occur, but does not execute the Cypher statement.
PROFILE
provides real profiling information for what has occurred in the graph engine during the query and executes the Cypher statement.