3 ms·
Keep a counter of friends for each user. Most users will have zero friends, no need to look them up. Also, if that's such a bottleneck, create a separate webse
by olegkikin 16y ago
Keep a counter of friends for each user. Most users will have zero friends, no need to look them up.
Also, if that's such a bottleneck, create a separate webserver in C++ and keep friend relationships in RAM in some sort of an efficient data structure, something like Map [UID]->[set of friend UIDs]. Queries should be lightning fast (even if you pass a thousand UIDs in one query).
- gridspy 16y agoThat is essentially what memcached should be doing now.