neo4j cypher单标签与多标签性能 [英] neo4j cypher single vs multiple labels performance

查看:112
本文介绍了neo4j cypher单标签与多标签性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请考虑以下示例:基于neo4j的Wiki,其中包含大量文章和更多版本的文章(所有编辑的历史记录).使用多个标签识别每个节点有多大的差异

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

然后使用

MATCH article:Article:Public

相比于类似db

article:ArticlePublic
article:ArticleVersion

然后将查询相关文档,而不必截取这两个组

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

MATCH article:ArticlePublic

谈到性能?

推荐答案

因此,我最终填充了一个小数据库,以测试不同大小的标记组如何影响彼此的性能.结果是,您可以自由使用任意数量的标签,而不会对性能产生任何重大影响,只要在这种情况下,您可以从最小的标签集到最大的标签集进行指定:

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

这篇关于neo4j cypher单标签与多标签性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆