neo4j-query-tuning-skill

Diagnose slow Neo4j Cypher queries by interpreting EXPLAIN/PROFILE execution plans.

101|35|Updated Jan 20, 2026
One-click install
npx skills add https://github.com/neo4j-contrib/neo4j-skills --skill neo4j-query-tuning-skill
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: neo4j-query-tuning-skill
Source: https://github.com/neo4j-contrib/neo4j-skills/tree/main/neo4j-query-tuning-skill
Command: npx skills add https://github.com/neo4j-contrib/neo4j-skills --skill neo4j-query-tuning-skill

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Neo4j users get stuck with slow or unpredictable Cypher queries without knowing which plan operators, missing indexes, or runtime choices are causing the slowness.

Core Features & Use Cases

  • Plan interpretation (EXPLAIN vs PROFILE): Decide when to use each and read key metrics like dbHits, estimatedRows, and pageCacheHitRatio to validate whether the plan matches reality.
  • Operator diagnostics with targeted fixes: Identify bad signals such as AllNodesScan, NodeByLabelScan, CartesianProduct, and Eager, then prescribe concrete remedies like indexes, query rewrites, hints, and LIMIT placement.
  • Planner accuracy & monitoring workflow: Detect stale cardinality estimation and trigger replanning or index resampling, while using SHOW QUERIES / SHOW TRANSACTIONS to diagnose and terminate problematic live queries.

Use Case: When a query is slow and PROFILE shows high dbHits and a plan containing a scan operator, use this Skill to pinpoint the exact operator and apply the appropriate index/hint/runtime strategy to reduce IO and improve selectivity.

Quick Start

Ask the Skill to analyze the output of PROFILE for your slow Cypher query and propose the smallest targeted changes to eliminate the specific bad plan operators it identifies.

Frequently Asked Questions about neo4j-query-tuning-skill

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix a slow Neo4j Cypher query using PROFILE output?

To fix a slow Cypher query, analyze PROFILE output for high dbHits and scan operators like AllNodesScan or NodeByLabelScan, then apply targeted changes such as adding indexes, using USING INDEX hints, or pushing LIMIT earlier to reduce IO.

What is the difference between EXPLAIN and PROFILE for Neo4j query tuning?

EXPLAIN generates the execution plan without running the query to validate structural choices, while PROFILE executes the query and returns concrete metrics like estimatedRows, dbHits, and pageCacheHitRatio to reveal whether the plan matches reality.

How do I resolve stale cardinality estimation in Neo4j execution plans?

To resolve stale cardinality estimation, trigger replanning or index resampling when estimatedRows diverge significantly from actual rows, ensuring the query planner selects optimal operators based on accurate data statistics.

When should I use USING INDEX or USING SCAN hints in Cypher queries?

Use USING INDEX or USING SCAN hints when the planner selects inefficient operators like CartesianProduct or Eager, forcing better join strategies and selectivity to improve overall query performance.

How do I monitor and terminate problematic live Neo4j queries?

Monitor and terminate problematic live Neo4j queries by using SHOW QUERIES and SHOW TRANSACTIONS to identify long-running transactions, then terminating them while leveraging db.stats.retrieve for performance diagnostics.

Which Neo4j runtime should I select for slow Cypher queries?

Select slotted, pipelined, or parallel runtime based on query characteristics and execution plan operators to optimize throughput and reduce IO for slow Cypher queries.