尽管使用了索引,但简单的查找仍需要几分钟的时间 [英] simple lookup takes several minutes despite using an index

查看:53
本文介绍了尽管使用了索引,但简单的查找仍需要几分钟的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当大的图形(大约6亿个节点,35亿条边)导入了neo4j.该图也非常密集(边缘中位数大约为10).尽管我不确定这是否会影响性能.

I have a decently sized graph (~600 million nodes, 3.5 billion edges) that I imported into neo4j. The graph is also quite dense (median edge count around 10); though I'm not sure if that affects performance.

对于一种类型的节点(:Authors)-大约有2亿这种类型的节点-我想查询一个特定名称的查询,该名称存储在属性 normalizedName .这是(非常简单的)查询:

For one type of node (:Authors) - there are roughly 200 million nodes of this type - I would like to run a query for a specific name, which is stored in the property normalizedName. Here is the (very simple) query:

MATCH (a:AUTHOR)
WHERE a.normalizedName = "jonathan smith"
RETURN a

正如人们期望的那样,此查询需要很长(几分钟)的时间才能执行.尽管我没有明确保证此属性的唯一性,但我仍然尝试在该属性上创建索引,也没有来自neo4j的投诉.之后,由于索引中的O(1)复杂性,我希望上面的查询将以ms为单位执行.不幸的是,查询仍然需要几分钟.

As one might expect, this query takes a LONG (several minutes) time to execute. Although I have no explicit guarantee of uniqueness on this property, I still tried to create an index on it, and I got no complaints from neo4j. Afterwards, I would have expected that above query would execute in ms, due to the O(1) complexity for lookups in an index. Unfortunately, the query still takes several minutes.

我在做什么错了?

推荐答案

确保已将索引设置为

CREATE INDEX ON :AUTHOR(normalizedName)

请注意,您将需要在希望使用索引查找的每个属性上设置索引.这也按节点标签过滤,即如果您在一个节点上使用多个标签并需要查找索引,则需要为每个标签设置一个标签,例如如果您有:Person:Author,则还需要设置:

Be aware that you will need to set an index on each property you wish to use an index look-up on. This is also filtered by node label, i.e. if you're using multiple labels on a node and need an index look up, you would need to set one per label, e.g. if you had :Person:Author, you'd also need to set:

CREATE INDEX ON :Person(normalizedName)

这篇关于尽管使用了索引,但简单的查找仍需要几分钟的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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