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 · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

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

Use Trino EXPLAIN ANALYZE to diagnose slow query performance and identify bottleneck stages
trino.io · 5 steps · unrated
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

Give your agent this knowledge — and 15,500+ more routes

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

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans