arr
arr

Reputation: 139

"This query builds a cartesian product between disconnected patterns" warning

Load csv with headers from "file:///flights.csv" as flights Match (a: Flight {number: flights.flight}), (b: Airport {label: flights.arrive})

Create (a) - [r:Arrives] -> (b)

If a part of a query contains multiple disconnected patterns, this will build a cartesian product between all those parts. This may produce a large amount of data and slow down query processing. While occasionally intended, it may often be possible to reformulate the query that avoids the use of this cross product, perhaps by adding a relationship between the different parts or by using OPTIONAL MATCH (identifier is: (b)) Match (a: Flight {number: flights.flight}), (b: Airport {label: flights.arrive}) ^

How can I correct this query?

Upvotes: 0

Views: 1047

Answers (1)

InverseFalcon
InverseFalcon

Reputation: 30407

It may not necessarily be incorrect. The point of your query is to create connected patterns between the two nodes. The only way to do that is to first match to those two nodes, which are currently not connected by a pattern.

Keep in mind that this warning is only to draw attention to what's going on in case you weren't expecting to create a cartesian product. In this case, that's exactly what you want to do, so disregard the warning.

Upvotes: 0

Related Questions