I apologize for the naive question as I am relatively new to graph databases and currently working with Neptune OpenCypher for my use case. I am experiencing different outcomes for two similar queries and would like to understand the reasons behind it.
My dataset consists of hundreds of millions of nodes. Here are the details of the queries:
Query 1: Timeout Error
MATCH p=(n:Person)-[:RELATIONSHIP*..5]->(m:Person {condition: True})
WHERE
ID(n) = <id_Value>
AND size([node IN nodes(p) WHERE node.event_date > n.event_date]) = 0
RETURN p
LIMIT 1
Query 2: Successful Response
MATCH p=(n:Person)-[:RELATIONSHIP*..5]->(m:Person {condition: True})
WHERE
ID(n) = <id_Value>
AND size([node IN nodes(p) WHERE node.event_date > n.event_date]) = 0
WITH p
ORDER BY n.event_date ASC
LIMIT 1
RETURN p
I'm curious about the reasons behind the timeout error in Query 1 and the successful response in Query 2. Both queries have a similar structure, but Query 1 times out while Query 2 executes successfully. Can someone explain why this might be happening?
I ran both queries mentioned earlier, and Query 1 resulted in a timeout while Query 2 executed successfully. However, I'm encountering unexpected results with Query 2, and I want to ensure that I'm not misunderstanding or misusing it.