4

Consider the following example: a neo4j based wiki with lots of articles and much, much more article versions (the history of all edits). How much of a difference does using multiple labels to identify each node

article:Article:Public
article:Article:Version

and querying then the db with

MATCH article:Article:Public

compared to a db organized like

article:ArticlePublic
article:ArticleVersion

that will then query the relevant documents without having to do an interception of the two groups

MATCH article:ArticlePublic

speaking about performance?

Sovos
  • 3,330
  • 7
  • 25
  • 36

2 Answers2

4

So I ended up populating a small db to test how very different size of labeled groups can affect each others performance. The result is that you can freely make use of any number of labels without any significant impact on performance provided that in this scenario you specify them from the smallest set to the largest:

neo4j-sh (?)$ match n:Test return count(n);
==> +----------+
==> | count(n) |
==> +----------+
==> | 189222   |
==> +----------+
==> 1 row
==> 1571 ms

neo4j-sh (?)$ match n:Test:One return count(n);
==> +----------+
==> | count(n) |
==> +----------+
==> | 170216   |
==> +----------+
==> 1 row
==> 1534 ms

neo4j-sh (?)$ match n:Test:Two return count(n);
==> +----------+
==> | count(n) |
==> +----------+
==> | 19006    |
==> +----------+
==> 1 row
==> 526 ms

neo4j-sh (?)$ match n:TestTwo return count(n);
==> +----------+
==> | count(n) |
==> +----------+
==> | 19082    |
==> +----------+
==> 1 row
==> 329 ms

neo4j-sh (?)$ match n:Two:Test return count(n);
==> +----------+
==> | count(n) |
==> +----------+
==> | 19006    |
==> +----------+
==> 1 row
==> 306 ms
Sovos
  • 3,330
  • 7
  • 25
  • 36
0

I would say avoiding a lot of index lookups will give you better read performance (ArticlePublic) but, will take more space since you are using a lot of indexes.

What about indexing :Article.Version in the Article index?

Peter Neubauer
  • 6,311
  • 1
  • 21
  • 24