Reputation: 500
My query to find the maximum depth of the graph is like this:
match (n)<-[rel:shares|comments*0..]-(m) where id(n)=69 return max(length(rel))
The problem with this is it takes forever to return the depth. Any suggestion to speed this?
Upvotes: 0
Views: 225
Reputation: 20185
How dense is your node ?
MATCH (n) WHERE id(n) = 69
RETURN size((n)--())
The length()
function don't apply on relationships or collections of relationships, you can either use it on a path or use size()
on the collection of relationships
MATCH (n) WHERE id(n) = 69
MATCH p=(n)<-[:shares|:comment*]-(x)
RETURN max(length(p))
or
MATCH (n) WHERE id(n) = 69
MATCH p=(n)<-[rel:shares|:comment*]-(x)
RETURN max(size(rel))
Would be nice also if you could share the query plan profile.
Note, on big graphs this can be a huuuge operation and might require a good machine to compute in a reasonnable time.
Upvotes: 1