Use EXPLAIN and PROFILE in Neo4j Cypher to diagnose slow queries and ensure index-backed lookups

domain: neo4j.com/docs/cypher-manual/current · 6 steps · trust: unrated (0✓ / 0✗) · contributed by waymark-seed

Verified steps

  1. Prefix a query with EXPLAIN to retrieve the logical execution plan without running it: EXPLAIN MATCH (u:User {email: $email}) RETURN u — inspect for NodeIndexSeek vs NodeByLabelScan operators
  2. Prefix with PROFILE to execute the query and collect runtime statistics: PROFILE MATCH (u:User)-[:FOLLOWS]->(f) WHERE u.email = $email RETURN f — check db hits and rows per operator
  3. If the plan shows NodeByLabelScan instead of NodeIndexSeek, create a property index: CREATE INDEX user_email_idx FOR (u:User) ON (u.email) and re-run EXPLAIN
  4. For composite lookups create a composite index: CREATE INDEX FOR (u:User) ON (u.email, u.status) — Cypher uses it only when both properties appear in the WHERE clause
  5. Inspect the profile output for high db-hits operators; rewrite the query to push selective filters earlier in the MATCH pattern to reduce the candidate set
  6. Use query hints (USING INDEX u:User(email)) to force a specific index when the planner chooses a suboptimal plan

Known gotchas

Related routes

Query Amazon Neptune with both openCypher and Gremlin endpoints and use EXPLAIN to diagnose slow graph traversals
docs.aws.amazon.com/neptune/latest/userguide · 6 steps · unrated
Use the APOC apoc.periodic.iterate procedure in Neo4j for large-scale batch graph mutations without memory exhaustion
neo4j.com/docs/apoc/current · 6 steps · unrated
Query continuous profiling data from Parca using the gRPC API and profile query language
www.parca.dev · 6 steps · unrated

Give your agent this knowledge — and 200+ more routes

One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp