cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Difference in specifying the properties inside node and in the where clause

skmami
Node Clone

Greetings,

What exactly is the difference between these statements in terms of performance ?

MATCH (m:Movie) WHERE m.released = 2003 RETURN m;

MATCH (m:Movie {released: 2003}) RETURN m;

Thank you.

4 REPLIES 4

If you run EXPLAIN... on both versions, you would probably see identical execution plans.

Any difference in execution time would probably be down to cache state, which probably shouldn't factor into your query design from what I understand.

Thank you @terryfranklin82. I ran EXPLAIN and they looked identical.

I was under the impression match with the where clause got all of the nodes of type Movie and then filtered them with where clause and I was thinking second match MATCH (m:Movie {released: 2003}) with inline property value went to straight to the node.

Is it safe to understand they are syntactically different but they do the same thing under the hood. ?

Thanks

Yes I would assume that, early versions of Cypher only had the {prop:value} notation, later the WHERE syntax was added if I remember correctly

That's my understanding. Using parameters does allow for reuse / caching of execution plans, which can speed things up when repeating the same query multiple times - https://neo4j.com/blog/cypher-write-fast-furious/#parameters