Neo4j cypher Command line match
1 answer
The 2 Cypher statements are NOT identical. We can show this with the PROFILE command , which shows how the Cypher engine will execute the request.
In the following examples, all requests end with RETURN a, c
, as you cannot have a nude proposal MATCH
.
As you can see, the first request has a filter NOT(r == r2)
that the second request does not. This is because Cypher ensures that the result of one sentence MATCH
does not contain duplicate relationships.
-
First request
profile match (a)-[r]->(b),b-[r2]->c return a,c; ==> +-----------------------------------------------+ ==> | a | c | ==> +-----------------------------------------------+ ==> | Node[1]{name:"World"} | Node[0]{name:"World"} | ==> +-----------------------------------------------+ ==> 1 row ==> 2 ms ==> ==> Compiler CYPHER 2.3 ==> ==> Planner COST ==> ==> Runtime INTERPRETED ==> ==> Projection ==> | ==> +Filter ==> | ==> +Expand(All)(0) ==> | ==> +Expand(All)(1) ==> | ==> +AllNodesScan ==> ==> +----------------+---------------+------+--------+----------------+----------------+ ==> | Operator | EstimatedRows | Rows | DbHits | Identifiers | Other | ==> +----------------+---------------+------+--------+----------------+----------------+ ==> | Projection | 1 | 1 | 0 | a, b, c, r, r2 | a; c | ==> | Filter | 1 | 1 | 0 | a, b, c, r, r2 | NOT(r == r2) | ==> | Expand(All)(0) | 1 | 2 | 4 | a, b, c, r, r2 | (b)-[r2:]->(c) | ==> | Expand(All)(1) | 2 | 2 | 8 | a, b, r | (b)<-[r:]-(a) | ==> | AllNodesScan | 6 | 6 | 7 | b | | ==> +----------------+---------------+------+--------+----------------+----------------+ ==>
-
Second request
profile match (a)-[r]->(b) match b-[r2]->c return a,c; ==> +-----------------------------------------------+ ==> | a | c | ==> +-----------------------------------------------+ ==> | Node[1]{name:"World"} | Node[1]{name:"World"} | ==> | Node[1]{name:"World"} | Node[0]{name:"World"} | ==> +-----------------------------------------------+ ==> 2 rows ==> 2 ms ==> ==> Compiler CYPHER 2.3 ==> ==> Planner COST ==> ==> Runtime INTERPRETED ==> ==> Projection ==> | ==> +Expand(All)(0) ==> | ==> +Expand(All)(1) ==> | ==> +AllNodesScan ==> ==> +----------------+---------------+------+--------+----------------+----------------+ ==> | Operator | EstimatedRows | Rows | DbHits | Identifiers | Other | ==> +----------------+---------------+------+--------+----------------+----------------+ ==> | Projection | 1 | 2 | 0 | a, b, c, r, r2 | a; c | ==> | Expand(All)(0) | 1 | 2 | 4 | a, b, c, r, r2 | (b)-[r2:]->(c) | ==> | Expand(All)(1) | 2 | 2 | 8 | a, b, r | (b)<-[r:]-(a) | ==> | AllNodesScan | 6 | 6 | 7 | b | | ==> +----------------+---------------+------+--------+----------------+----------------+
+5
source to share