Sorting and filtering with hops

  • neo4j version -4.0.11 browser version

I am looking here at how to apply sorting and filtering on traversed graph data faster.
using hops based on the page number increases for managing the performance.
But if I want to apply sorting that has to be done at full * level, But this is impacting the performance.
There any way to achieve sorting without hops with less response time, with pagination .?

match p=(coach)-[:SPONSORS*..6]->(child)

Hi @ganeshbdas1 !

I should admit that I don't follow you explanation that much. Can you add more complete queries that you executing with poor perfomance? It can also be good having the Profile/Explain of those queries.



match (coach:Customer{MID:"200"}) with coach,coach.gen as coachHier
match p=(coach)-[:SPONSORS*..6]->(child)
where all (x IN nodes(p) WHERE x.gen >= coachHier and x.gen <= (coachHier + rankID))
with coachHier,plusOne, collect(distinct child) as c1
with coachHier, c1 + collect(distinct child2) as allChildren unwind allChildren as child
with coachHier, child order by child.createddate desc
return child.MID

match p=(coach)-[:SPONSORS*..6]->(child)
need to traverse till 15 hops some time. so one customer may return max 1 M records in his full set downlines. taking more than 30 sec. latest we need to bring back to 10 sec for the first 10 records.

@Bennu . Please let me know if you need any further input.

Hi @ganeshbdas1 ,

Looks like a pretty interesting problem. Can you share the entire profile and query executed?


i am not sure if its part of GDS libraries, but it has shortest path algorithms.
Can these algorithms short top n shortest path? (with restriction of number of hops using [*5]