It's not possible to retrieve data from RDBMS for user friends data for data which cross more than half a billion at a constant timeso Facebook implemented this using a hash database (no SQL) and they opensourced the database called Cassandra.
So every user has its own key and the friends details in a queue; to know how cassandra works look at this: