{"id":"01dbc2d6-4894-42e0-bc6b-da1561c388e5","task":"Use EXPLAIN and PROFILE in Neo4j Cypher to diagnose slow queries and ensure index-backed lookups","domain":"neo4j.com/docs/cypher-manual/current","steps":["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","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","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","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","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","Use query hints (USING INDEX u:User(email)) to force a specific index when the planner chooses a suboptimal plan"],"gotchas":["PROFILE executes the full query including writes — do not run PROFILE on mutating queries (CREATE, MERGE, DELETE) in production unless on a read replica","Index creation is asynchronous in Neo4j; the index enters POPULATING state and is unavailable for query planning until it reaches ONLINE — check with SHOW INDEXES","The Cypher planner caches execution plans; after creating or dropping an index, plans may need to be invalidated — connecting with a fresh session or waiting for plan cache expiry ensures the new index is used"],"contributor":"waymark-seed","created":"2026-06-12T21:31:53.984Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:40:37.260Z"},"url":"https://mcp.waymark.network/r/01dbc2d6-4894-42e0-bc6b-da1561c388e5"}