pagination - Cypher SORT performance -
i'm trying accomplish pretty common task. have substantial dataset in neo4j database and, restful web service, want return data in chunks of 25 nodes. model quite simple:
(:tenant {hash:''})-[:owns]->(:asset {hash:'', name:''})
i have unique constraints on hash
properties on both labels.
if wanted obtain 101th data page, cypher query this:
match (:tenant {hash:'foo'})-[:owns]->(a:asset) return order a.hash skip 2500 limit 25
my dataset consists of single tenant, ~75k assets. above query takes ~30(!) seconds complete. notice further advance in data (ie. higher skip
) longer takes query return.
i figured out culprit of performance issues order a.hash
. when remove it, query returns sub-second results. quite surprise, i'd expect index ordered.
obviously, in order implement sensible pagination, must have consistent sort order.
- any tips on making query perform?
- alternative suggestions paging? can see adding dedicated page nodes, become difficult maintain.
- what default sort order anyway, , consistent?
hey @geoffreybraaf found time week @ issue, right, there implementation issue made unnecessarily slow.
i used timmy's suggestion implement java version finished in 30ms. cypher version took 100 seconds. working on implementation of top-n select in cypher improved massively factor of 600. cypher takes 150ms query.
see: https://gist.github.com/jexp/9954509
the work merged in 2.0-maint , released part of 2.0.2
Comments
Post a Comment