How does Facebook calculate mutual friends?
Does it cache all mutual friends for each user? Does it use MySQL to calculate mutual friends with a query?
According to Facebook,
So, the set of mutual friends is the intersection of the set of your friends and the set of friends of the person you are viewing. If we assume that Facebook maintains an active cache of your friends, then when you view a person's page, another list containing that person's friends is retrieved, and the intersection of these two lists is the list of mutual friends.