I'm running this query:
MATCH (a:TEST:LOC1),(b:TEST_JOIN:LOC1),(c:TEST:LOC1)
WHERE a._out = b._in and b._out = c._in and c._text = 'P'
CREATE (a)-[r:TEST_JOIN]->(c)
It runs very slowly, and the execution plan says: "This query builds a cartesian product between disconnected patterns"
All the properties are indexed and I have tried:
MATCH (c:TEST:LOC1) where c._text='P' with c
MATCH (a:TEST:LOC1),(b:TEST_JOIN:LOC1)
WHERE a._out = b._in and b._out = c._in
CREATE (a)-[r:TEST_JOIN]->(c)
Sorry if this is basic. Does anyone know how to optimise this? Many thanks in advance.
I would try this
MATCH (c:TEST:LOC1) where c._text='P' with c
MATCH (b:TEST_JOIN:LOC1) where b._out = c._in with b, c
Match (a:Test:LOC1) WHERE a._out = b._in with a, c
CREATE (a)-[r:TEST_JOIN]->(c)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With