Thank you for taking the time to post that. I am trying to give it a try, I just manually inserted a few friedn ID's to test so it looks like this
SELECT b.user_id AS user_id, b.subject AS subject, r.auto_id AS auto_id, r.disp_name AS disp_name, r.pic_url AS pic_url
FROM friend_bulletin b, friend_reg_user r, friend_updates u,
WHERE b.auto_id = r.auto_id
AND b.auto_id = u.typeid
AND (
u.uid = "1"
OR uid
IN ( 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 34, 54, 675, 3243 )
)
I am getting this error though can you help
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Where b.auto_id = r.auto_id and b.auto_id = u.typeid and (u.uid ="1" or u' at line 3
1 more thing, my friend_friend table which keeps track of who is who's friend on the network currently has around 600,000 rows so this Query has to go through all of them, and the string of friedn ID's which I have posted above only has 16 friedn ID's, in reality this string can consist with up to 10,000 user ID's if the user has 10,000 friends on the site. So you can see improving performance is a must to make this site work. Now that I have told you about the friend table, do you think that using the
uid
IN ( 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 34, 54, 675, 3243, up to 10,000 numbers here
Is this still a good method?
Thank you so much for the help this site has been an amazing learning experience while trying to keep performance up to par with the large userbase of the site
Weedpacket;10920375 wrote:If you're making queries solely for the sake of getting values to use in other queries then it is almost certain that you can do the job with a single query. And it is almost certain that if you're using a query inside a loop then you can do it with one query without the loop.
Select b.subject as subject, r.auto_id as auto_id, r.disp_name as disp_name, r.pic_url as pic_url
From friend_bulletin b, friend_reg_user r, friend_updates u,
Where
b.auto_id = r.auto_id
and b.auto_id = u.typeid
and (u.uid = $userid or u.uid in ($str_friend_ids))
Order by u.date desc
Limit 20
Something vaguely along those lines anyway. Suffice it to say that you can use more than one table at a time in a query.