Also, I forgot to mention that SuggestedFriends must not be friends with 
#11:5 yet. That why is have "(@rid NOT IN $friends)" in my query.

On Friday, September 25, 2015 at 2:34:43 AM UTC+9, Jihoon Park wrote:
>
> Hey, guys. I was just wondering if there is a faster query for getting a 
> list of friends of friends for a particular user, sorted in the descending 
> order of the number of mutual friends.
>
> Right now, I have 11,118 "User" vertices connected by 47,965 
> "isFriendsWith" edges. (If A is a friend of B, both an edge from A to B and 
> an edge from B to A exist.)
>
> The following is the fastest query I have so far, but I'm not satisfied 
> with its performance):
>
>> SELECT @rid AS SuggestedFriends, count(*) AS NumberOfMutualFriends
>> FROM ( SELECT expand(out('isFriendsWith').out('isFriendsWith')) FROM #11:5
>> LET $friends = (SELECT out('isFriendsWith').@rid FROM #11:5) )
>> WHERE (@rid <> #11:5) AND (@rid NOT IN $friends)
>> GROUP BY @rid
>> ORDER BY NumberOfMutualFriends DESC
>
>
> Does anyone have any idea how I can improve this query?
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" 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