Users table
user_id
pic_url
name
friends table
auto_id
userid
friendid
status
actions table
auto_id
userid
type
subject
body
datetime
我想进行更新,多数民众赞成的朋友流中显示的更新,可能是一个博客帖子,状态变化,任何事情,但应该只表明是从登录的用户的朋友的人需要帮助与MySQL连接
这是我想出来的,但我的用户基数非常大,所以性能是必须的,有没有更好的方法来做到这一点?请告诉我
SELECT u.user_id, u.pic_url, u.name, a.auto_id, a.userid, a.type, a.subject, a.body, a.datetime
FROM actions AS a
LEFT JOIN users AS u ON u.auto_id=a.userid
LEFT JOIN friends AS f ON f.userid=a.userid
WHERE f.friendid=1 //1 would be my user ID
AND f.status=active
请帮助我不认为这是正确的。
假设有5万个用户,我的用户名为#1,而我是拥有20,000名用户的朋友,它应该返回由用户发布的用户发布的操作表中的所有条目,还需要修改以包含我自己的动作
我听说过一些人使用某种哈希表进行快速查找会有这样的事情吗?
感谢所有帮助
更多有关索引的阅读http://www.alistapart.com/articles/indexing-the -web-its-not-just-googles-business/ – 2009-07-24 00:36:21