simple lookup takes several minutes despite using an index

℡╲_俬逩灬. 提交于 2020-01-25 06:46:08

问题


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.

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

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.

What am I doing wrong?


回答1:


Ensure that you have set the index as

CREATE INDEX ON :AUTHOR(normalizedName)

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)


来源:https://stackoverflow.com/questions/58688681/simple-lookup-takes-several-minutes-despite-using-an-index

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!