Neo4j Design: Real Estate vs "Node & Relationship"

I have a node type that has a string property that will have the same value very often. Etc. Millions of nodes with 5 variants of this string value. I will search for this property.

My question will be the best in terms of performance and memory: a) Implement it as a node property and have many duplicates (and search using WHERE). b) Implement it as 5 additional nodes, where all the source nodes refer to one of them (and search using the additional MATCH).

+7
source share
3 answers

Without knowing further details, it is difficult to give a general answer.

In terms of performance, it's best to limit your search as early as possible. Even more useful if you do not need to look for properties to crawl.

Given that I assume that it is better to move the lookup property to a separate node and use the value as a type of relationship.

+6
source

Use labels ; this blog post is a good introduction to this new Neo4j 2.0 feature:

+4
source

I also thought a little about this problem. In my case, I had to submit a state:

  • TO BEGIN
  • IN_PROGRESS
  • SUBMITTED
  • COMPLETED

In general, the Node + Relationship approach looks more attractive, since only binding to one link should be supported every time, and not a string of properties, and you do not need to scan an additional additional index that should be supported on the property (memory and performance will intuitively favor this approach).

Another advantage is that it easily supports the ability to bind Node to multiple "special nodes." If you anticipate a situation where this is possible in your model, this is better than using an array of properties (and searching using "in").

In practice, I found that the problem then became how you access these special nodes every time. Either you maintain a link to some constants, where you have the Node identifier of these special nodes, where you can jump directly into them in your START statement (this is what we do), or you need to search against the special Node property each times (name, possibly), and then cross his relationship. This does not apply to the most beautiful cypher requests.

+1
source

All Articles