How to solve error messsage about neo4j :This query builds a cartesian product

57 Views Asked by At

When I try to execute the comnand, but appear some waining:

This query builds a cartesian product between disconnected patterns.

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: (r))

MATCH (s1:Station { id: toInteger(csvLine.fromId)}),(r:Route { id: toInteger(csvLine.route_informationId)}),(s2:Station { id: toInteger(csvLine.toId)})

initial input comnand:

LOAD CSV WITH HEADERS FROM "https://lovecandyhsu.neocities.org/relations.csv" AS csvLine
MATCH (s1:Station { id: toInteger(csvLine.fromId)}),(r:Route { id: toInteger(csvLine.route_informationId)}),(s2:Station { id: toInteger(csvLine.toId)})
OPTIONAL MATCH (s1)<-[:FROM]->(r)
OPTIONAL MATCH (r)<-[:TO]->(s2)
RETURN csvLine

How to solve this problems? thank.

0

There are 0 best solutions below