Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 需要mysql连接的帮助吗_Php_Mysql - Fatal编程技术网

Php 需要mysql连接的帮助吗

Php 需要mysql连接的帮助吗,php,mysql,Php,Mysql,我想做一个朋友流的更新,显示更新,可以是一个博客帖子,状态改变,但应该只显示那些来自一个朋友的登录用户 这是我的想法,但是我的用户群非常大,所以性能是必须的,有更好的方法吗?请给我看看 Users table user_id pic_url name friends table auto_id userid friendid status actions table auto_id userid type subject body datetime 请帮忙,我认为

我想做一个朋友流的更新,显示更新,可以是一个博客帖子,状态改变,但应该只显示那些来自一个朋友的登录用户

这是我的想法,但是我的用户群非常大,所以性能是必须的,有更好的方法吗?请给我看看

Users table
 user_id
 pic_url
 name

friends table
 auto_id
 userid
 friendid
 status

actions table
 auto_id
 userid
 type
 subject
 body
 datetime
请帮忙,我认为这不对

假设有50000个用户,我的用户ID为#1,我是20000个用户的朋友,它应该返回由我的朋友发布的操作表中的所有条目,还需要修改以包括我自己的操作

我听说有人说使用某种哈希表可以更快地查找,这样的事情在这里可能吗

谢谢你的帮助

我听到一些人在谈论 使用某种哈希表 更快的查找速度会有点像 这在这里可能吗


它被称为,您应该在计划使用联接的每个列中添加一个(或者匹配一个显式约束,比如
>,>=,=,更多关于索引的阅读我应该提到的是mysql,有没有一种特殊的方法来添加哈希索引,或者一个常规索引是同一件事?请看我添加的注释。我可能不应该深入到那么多细节。BTREE和哈希索引之间的性能差异s可能比BTREE和no索引之间的性能差异小得多。
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
Users.user_id*
Friends.user_id
Friends.friend_id
Friends.active
Actions.user_id