我该如何改进这个查询? 请点击这里告诉我,我所有的选项,我的社交网络DB只挺大随着我的mysql数据库增长,我有什么选择
这个查询花费2.1231秒
SELECT friend_friend.friendid, friend_reg_user.disp_name, friend_reg_user.pic_url, friend_reg_user.online
FROM friend_friend
INNER JOIN friend_reg_user ON friend_friend.friendid = friend_reg_user.auto_id
WHERE userid =1
AND friend_friend.status =1
ORDER BY autoid DESC
LIMIT 59535 , 15
#####################################################################################################################################
# id # select_type # table # type # possible_keys # key # key_len # ref # rows # Extra #
#####################################################################################################################################
# 1 # SIMPLE # friend_friend # ref # userid # userid # 5 # const # 59843 # Using where#
# 1 # SIMPLE # friend_reg_user # eq_ref # PRIMARY # PRIMARY # 4 # friend_friend.friendid # 1 # #
#####################################################################################################################################
我有哪些选项时,此表是说一百万,或甚至2万行大?此表是用来确定谁是用户的朋友
是的,我认为它已尽可能优化,所有正确的索引和东西,但超过2秒是缓慢的。这是从本地运行的,也许这可能是为什么它很慢? – JasonDavis 2009-07-24 11:45:35
800万条记录并不是那么多......试着看看当你达到10亿时会发生什么。 – MarkR 2009-07-26 21:43:16
我可以证明,拥有超过1亿5千万行myisam表的quieries在处理可以高效使用索引的查询时仍然很快。 – nos 2009-07-26 21:46:18