Does Cypher's ORDER BY uses the index?

℡╲_俬逩灬. 提交于 2019-12-07 04:38:12

问题


I have an index on :Label(Uid) and :Label(Name)

However, when I profile (in the shell) the following two queries I get the same codepath for both. The issue is that I have 700,000 items of :Label, and it's starting to be painfully slow to order the items.

Query ordering by a property with index:

MATCH (item:Label) RETURN item.Name ORDER BY item.Name SKIP 1000 LIMIT 50

Query ordering by a property without index:

MATCH (item:Label) RETURN item.Name ORDER BY item.Created SKIP 1000 LIMIT 50

The profiler gets me (almost) the same thing for both, only the parameters are changed:

==> ColumnFilter(symKeys=["item", "item.Name", "  UNNAMEDS885193287"], returnItemNames=["item.Name"], _rows=30, _db_hits=0)
==> Slice(skip="Literal(1000)", _rows=30, _db_hits=0)
==>   Top(orderBy=["SortItem(Cached(  UNNAMEDS885193287 of type Any),true)"], limit="Add(Literal(1000),Literal(50))", _rows=1030, _db_hits=0)
==>     Extract(symKeys=["item"], exprKeys=["item.Name", "  UNNAMEDS885193287"], _rows=768596, _db_hits=1537192)
==>       NodeByLabel(identifier="item", _db_hits=0, _rows=768596, label="Label", identifiers=["item"], producer="NodeByLabel")

回答1:


As of now, neo4j does not take advantage of an existing index to speed up the ORDER BY clause.

You should probably let the neo4j folks know you would like this to be supported :-).

[UPDATE]

There is, as of this update (Jan. 10, 2018), an open feature request for this capability. According to a recent comment, it is supposed to be a "high prioritized feature".



来源:https://stackoverflow.com/questions/23835349/does-cyphers-order-by-uses-the-index

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