This tutorial should explain how to avoid Cartesian Products

In this tutorial:

There is the query:

MATCH (a:Person), (m:Movie)
WHERE a.name = 'Michael Caine' AND m.title = 'Batman Begins'
CREATE (a)-[:ACTED_IN]->(m)
RETURN a, m

with an explanation that this query will create a cartesian product but it does NOT explain how to avoid that!

Avoiding a cartesian product is explained here:

(I would have made a Pull Request on it, but I don't know where it lives in github.)

2 Likes

Yes that cypher statement does create a Cartesian join but it's a 1x1 Cartesian since each match returns only 1 row given the data model

That's not the point of my suggestion.

I got the warning but I didn't have any idea of how to fix it until today.

It's not immediately obvious how to not do a Cartesian Product.

1 Like