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.

Trying to see if querying by property value will be faster that relationship value

Hello,

I'm trying to see which cypher query will be faster.
For a case where I have several user nodes and I want to filter for users of a particular gender.

Will it be better/faster to have "gender" as a separate node and have different values as relationship-properties or to have the gender property on the "user" node.

3 REPLIES 3

accounts
Node Clone

Loading properties is expensive, traversing is cheap. The faster option will be the relationship

Thank you very much.

clem
Graph Steward

One trick a lot of people don't know about, is that Nodes can have multiple Labels.

So, you can do:

CREATE(p:Person:Male {name:"Adam"});
CREATE(p:Person:Female {name:"Eve"})

If you want to match for all Women:

MATCH(women:Female) WHERE ....

The performance advantage of this, is all nodes with the label Female (or Male) is a set, so accessing all the Female nodes is very quick.