'news feed' like db structure
Posted: Thu Jan 08, 2009 1:37 pm
Hey
I was just on Facebook website and for some reason i got interested in their "news feed" feature.
It got me thinking on how on earth do they do that. I know that they have HUGE hardware behind it
and use caching, but still.
Come to think about it now, you have other website that offer the same thing..
Let's say that they save actions into one table..
Came up with two options:
Option 1:
- Get a list of my friends
- Get a list of recent activities from actions table, activity matches my friend list
Option 2:
- Each time an action is made, make INSERT for each friend i have
Now, i would say that the second option would be faster, but still.. Imagine having 500
friends. That means 500 INSERTs.
Isn't there any better way of doing this?
I was just on Facebook website and for some reason i got interested in their "news feed" feature.
It got me thinking on how on earth do they do that. I know that they have HUGE hardware behind it
and use caching, but still.
Come to think about it now, you have other website that offer the same thing..
Let's say that they save actions into one table..
Came up with two options:
Option 1:
- Get a list of my friends
- Get a list of recent activities from actions table, activity matches my friend list
Option 2:
- Each time an action is made, make INSERT for each friend i have
Now, i would say that the second option would be faster, but still.. Imagine having 500
friends. That means 500 INSERTs.
Isn't there any better way of doing this?