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


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.

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. ?


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

1 Like

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 - Cypher: Write Fast and Furious