简体   繁体   中英

SORT QUERY Too Slow in Neo4j Cypher

I have a simple dataset with following node structure id : int, txt : string

and have 400 000 nodes and I have created an index on id property. When I am running simple query

profile MATCH (n:LABEL) RETURN n.id LIMIT 25

This is using index and running fast but when I am running this query

profile MATCH (n:LABEL) RETURN n.id order by n.id desc limit 25

This query is not using index and returning result in around 1200ms on every time basis.

What am I missing and why the indexes are not getting used in this query?

This is an achilles heel of Neo4j, as ORDER BY indexed properties still doesn't utilize the indexes .

APOC Procedures has some support for obtaining an ordered range utilizing the index , though I've encountered some issues with that previously. Haven't rechecked functionality lately, so it may be worth trying it out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM