Abfragen mit EXPLAIN und PROFILE profilieren
Lernen Sie, Cypher-Ausführungspläne mit EXPLAIN und PROFILE zu lesen, um langsame Abfragen in Neo4j zu diagnostizieren und zu optimieren.
Abfragen mit EXPLAIN und PROFILE profilieren ist eine kostenlose Neo4j Graph Database Fundamentals-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Neo4j Graph Database Fundamentals-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Neo4j Graph Database Fundamentals-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
You Cannot Tune What You Cannot See
Before optimizing a query, you must understand how Neo4j executes it. The EXPLAIN and PROFILE keywords reveal the execution plan.
EXPLAIN: The Plan Without Running
EXPLAIN shows the planned operators without actually executing the query. Use it to inspect plans safely, even for writes.
EXPLAIN
MATCH (p:Person {name: 'Alice'})-[:FRIEND]->(f)
RETURN f.name;PROFILE: The Plan With Real Numbers
PROFILE runs the query and reports actual db hits and rows per operator. This is your main tuning tool.
PROFILE
MATCH (p:Person {name: 'Alice'})-[:FRIEND]->(f)
RETURN f.name;Reading Operators
Plans are trees of operators such as:
- NodeByLabelScan — scans all nodes with a label
- NodeIndexSeek — uses an index (fast)
- Expand — follows relationships
- Filter — applies a predicate
The Enemy: Full Scans
A NodeByLabelScan on a large label means Neo4j reads every node of that type. Replacing it with a NodeIndexSeek is the most common big win.
Counting db Hits
db hits estimate work done. Fewer is better. Compare db hits before and after a change to confirm improvement.
Adding an Index to Fix a Scan
If PROFILE shows a label scan filtered by a property, add an index on that property and re-profile.
CREATE INDEX person_name IF NOT EXISTS FOR (p:Person) ON (p.name);Watching Row Counts
Each operator shows estimated and actual rows. A big gap between them means the planner's statistics are stale.
Eager Operators
An Eager operator forces Neo4j to materialize all rows before continuing, often inflating memory. Restructuring the query can sometimes remove it.
Cartesian Products
A CartesianProduct warning means two disconnected patterns multiply together. Connect them with a relationship or a WHERE to avoid an explosion.
// Bad: disconnected
MATCH (a:Person), (b:Company)
RETURN a, b;A Tuning Workflow
Profile, find the most expensive operator, address it (index, restructure, anchor the match), then profile again. Iterate until db hits are acceptable.
Quick Check
Test your profiling knowledge.
Recap
You learned to profile Cypher queries:
- EXPLAIN shows the plan; PROFILE adds real metrics
- Replace label scans with index seeks
- Minimize db hits
- Avoid cartesian products and unnecessary eager operators
- Iterate: profile, fix, re-profile
Häufig gestellte Fragen
Ist die Lektion „Abfragen mit EXPLAIN und PROFILE profilieren“ kostenlos?
Ja — der vollständige Text von „Abfragen mit EXPLAIN und PROFILE profilieren“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Neo4j Graph Database Fundamentals-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Neo4j Graph Database Fundamentals-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Abfragen mit EXPLAIN und PROFILE profilieren“?
Lernen Sie, Cypher-Ausführungspläne mit EXPLAIN und PROFILE zu lesen, um langsame Abfragen in Neo4j zu diagnostizieren und zu optimieren. Du übst Neo4j Graph Database Fundamentals mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um Neo4j Graph Database Fundamentals zu starten?
Keine Vorkenntnisse erforderlich. Neo4j Graph Database Fundamentals auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.
Wie lange dauert die Lektion „Abfragen mit EXPLAIN und PROFILE profilieren“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser Neo4j Graph Database Fundamentals-Lektion Code schreiben und ausführen?
Ja. Jede Neo4j Graph Database Fundamentals-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- Cypher-Abfrageleistung optimieren
- Fortgeschrittene Indexierungsstrategien
- Neo4j mit kausalem Clustering skalieren
- Abfragen mit EXPLAIN und PROFILE profilieren