Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-10-2020 09:29 PM
Hi all,
Just checking whether my solution for exercise 5.12 would be considered equivalent to the solution the course provided?
My solution:
MATCH (m:Movie)<-[:DIRECTED]-(d:Person)
WITH count(d) AS numDirectors, m
WHERE numDirectors >= 2
OPTIONAL MATCH (m)<-[:REVIEWED]-(r:Person)
RETURN m.title, r.name
Provided solution:
MATCH (m:Movie)
WITH m, size((:Person)-[:DIRECTED]->(m)) AS directors
WHERE directors >= 2
OPTIONAL MATCH (p:Person)-[:REVIEWED]->(m)
RETURN m.title, p.name
The returned data was the same:
04-11-2020 12:28 PM
Yes. They get the same results. I'd argue that your solution is more optimal. Looking at PROFILE and checking the performance, it's about twice as fast, albeit for a small database, and the PROFILE seems to points at the reasons for that - the initial query optimizes the path for a more constrained request. I found in various examples, the goal of their solutions were often to show neat ideas to keep in mind rather than "best practice". Keep it up!
04-11-2020 07:05 PM
Thanks for the feedback! Yeah, I think I've noticed it's not all supposed to be best practice although I wasn't aiming for better performance with this - just what came to mind first.
All the sessions of the conference are now available online