我該如何改進這個查詢? 請點擊這裏告訴我,我所有的選項,我的社交網絡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