Profiling a query
This query returns the movies that "Clint Eastwood" acted in but did not direct:
MATCH (p:Person)-[:ACTED_IN]->(m:Movie)
WHERE p.name = 'Clint Eastwood'
AND NOT exists {(p)-[:DIRECTED]->(m)}
RETURN m.title
You can profile the query to see the performance of the query by adding PROFILE
to the beginning of the query.
PROFILE MATCH (p:Person)-[:ACTED_IN]->(m:Movie)
WHERE p.name = 'Clint Eastwood'
AND NOT exists {(p)-[:DIRECTED]->(m)}
RETURN m.title
The results breakdown the performance of the query into the components of the query.
Review the results.
Based on the db hits
, which part of the query do you think is the most expensive?
-
❏ (p)-[:ACTED_IN]→(m)
-
❏ p.name = 'Clint Eastwood'
-
✓ (p)-[:DIRECTED]→(m)
Hint
Identify each part of the query using the description in the profile results.
The part with the highest dh hits
is the most expensive.
Solution
The correct answer is (p)-[:DIRECTED]→(m)
.
This step has the highest number of db hits.
![Profile step showing (p)-[anon_1:DIRECTED]→(m) with 364 db hits.](images/clint_db_hits.png)
Summary
In this challenge, you profiled a query.
In the next lesson, you will learn about using multiple MATCH
clauses.