Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Indexing Neo4j-索引和性能_Indexing_Neo4j_Cypher_Database Indexes - Fatal编程技术网

Indexing Neo4j-索引和性能

Indexing Neo4j-索引和性能,indexing,neo4j,cypher,database-indexes,Indexing,Neo4j,Cypher,Database Indexes,我对Neo4j中的密码查询的性能有疑问。 情况是:图中的每个节点都有一个属性,我想计算具有相同属性的节点数。 所以,我的基本问题是 match (n:NodeLabel) with n.community as community, n.myid as myid match (m) where m.community = community return myid, count(m) as totcommunity 我创建了一个关于财产“社区”的索引 但是性能非常差:对于一个有200.000个

我对Neo4j中的密码查询的性能有疑问。 情况是:图中的每个节点都有一个属性,我想计算具有相同属性的节点数。 所以,我的基本问题是

match (n:NodeLabel)
with n.community as community, n.myid as myid
match (m) where m.community = community
return myid, count(m) as totcommunity
我创建了一个关于财产“社区”的索引

但是性能非常差:对于一个有200.000个节点的图来说,需要很长时间。 我怎样才能获得更好的表现


如果要返回每个不同的社区值以及具有该值的节点数,请提前感谢

MATCH (n:NodeLabel)
RETURN n.community, COUNT(n);
相反,如果您希望获取与特定节点(标识为my
myid
)具有相同
社区
值的节点数,请尝试以下查询:

MATCH (n:NodeLabel {myid: 123})
WITH n.community AS c, n.myid AS myid
MATCH (n:NodeLabel)
WHERE n.community = c
RETURN myid, n.community, COUNT(n);

您忘记为第二个匹配添加标签,因此它无法使用索引: 试试这个:

match (n:NodeLabel)
match (m:NodeLabel) where m.community = n.community
return n.myid as myid, count(*) as totcommunity

您还可以通过在查询前加上
EXPLAIN
来确保它使用索引,并检查查询计划。

谢谢EXPLAIN子句(我不知道)。但是如果我有不同的节点标签,并且我想检查所有节点的community属性,该怎么办?你是说如果我没有为节点指定标签,它就不会为指定的属性使用索引吗?我不知道如何使用EXPLAIN子句。你能举个例子吗?非常感谢你的回答。是的,应该有用。但是对于特定的节点,我想要它们所属社区的大小,而不是所有社区的大小。是的。但问题在于在匹配节点时使用所需的标签。非常感谢你的回答
match (n:NodeLabel)
match (m:NodeLabel) where m.community = n.community
return n.myid as myid, count(*) as totcommunity