Part 4 — Using Indexes and Query Best Practices in Neo4j 4.x

Nadhir Dhanu Dwinanda
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:
  1. List indexes.
  2. Drop an index.
  3. 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.
Source: Neo4j
  • PROFILE provides real profiling information for what has occurred in the graph engine during the query and executes the Cypher statement.
Source: Neo4j

Monitor queries

Source: Neo4j

--

--

Nadhir Dhanu Dwinanda
Nadhir Dhanu Dwinanda

Written by Nadhir Dhanu Dwinanda

Hello, my name is Dhanu. I'm from Indonesia Fresh Graduate from Bogor Agricultural University on Computer Science Major. My interest is Data Engineer.

No responses yet