OK I have a social network, around 50,000 users so far and there is a friend table that show who is your friend on the site, this table is over a million rows
Not the tricky part, I show user posted bulletin, status posts, stuff like that that is only visible to people on your friend list. Keep in mind the size of the tables, user table around 50,000 so far and friend table around 1 million
1 method of getting the friends list to know what status posts to show to a user is to run this query below and put the results into an array
select friendid from friend_friend where userid=1 and status=1
I would then turn this array into a comma seperated list and use it in an IN clause on the mysql query that fetches the posts that this user is allowed to view
Hope that makes sense so far.
Now what if I were to save this friend array to a session variable since this query is ran very frequently? One of the drawbacks I see is if a user adds that person as a friend while they are logged in, they would show up as there friend until that session was reset but other then that, would this be bad performance for memory or whatever sessions use?
Also note there is sometimes up to 500 users logged in and some have a friend list of 10,000 friend ID's and this is a PHP/MySQL setup
Another question about session data, it is stored in file and not sytem memory correct? If it is on disk instead of memory then memory shouldn't be to much of a problem?