 <p>I would guess they outer join their <code>friends</code> table with their <code>likes</code> table to count both regular likes and friend likes at the same time.</p> <p>With the proper indexes, it wouldn't be a slow query at all. Huge databases aren't necessarily slow, so there's really no reason to not store all of this information in a database. The trick is to make sure the indexes and partitions (if any) are set up well.</p>