Hi,

for what you do shortest Path is not the right solution, as you don't wan
the path between two nodes but the neighborhood of one node.

Also having that many connections when you don't have the CPUs to process
it doesn't make sense, scale it out on a scluster.

Why do you string-concatinate the dist property?

I presume you have an index / constraint on :User(userId) ?

Try this instead:


MATCH (user:User{userId:<someUser>})
 MATCH
p=(user)-[r:relation_type1|relation_type2|relation_3*1..3]-(friend:User)
        WHERE friend <> user
        RETURN friend.userId as userId, reduce(base = '', rel in r | base +
' ' + rel.dist) as dist

But you also know that this can potentially return a lot of data? e.g. of
you have 100 friends on average this returns 100^3 aka 1M results !

Michael


On Sat, Jun 25, 2016 at 10:36 AM, idor <[email protected]> wrote:

> I have in my graph ~1M nodes and ~1M relations.
>
> My motivation for query is to retrieve all related nodes(by 3 hops) of
> specific source node + aggregate properties within the response.
>
> I understood the shortestPath taking your sourceNode and query all other
> nodes(not necessarily related ones) in the graph to match the relevant
> results.
> My latency is around 2-4 seconds when I have load (~4000 concurrent
> connections). it's too high.
>
> Any idea how could I optimize my query for better performances?
>
>
>  MATCH
> p=shortestPath((user:User{userId:<someUser>})-[r:relation_type1|relation_type2|relation_3*1..3]-(user:User))
>         WHERE f <> user
>         RETURN (f.userId) as userId,
>         reduce(base = '', rel in r | base + ' ' + rel.dist) as dist
>
>
> * notes: userId and relation_type1/2/3 are auto indexed
>
> * I am using the rest client and recently thought to upgrade into the new
> BOLT driver(not sure it will helps)
>
> Thank you.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to