How could I improve this query?
Please tell me all my options here as my social network DB is only getting bigger
This Query took 2.1231 sec
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 # #
#####################################################################################################################################
What are my options when this table is say a million, or even 2 million rows big? This table is used to determine who is a users friends
I know a programmer who is working with 8 million records in his Database, and it really doesn’t change the speed that much. It is just about creating the right indexes and making sure that you are grabbing the data in an efficient way. (Numerical IDs for relationships are really useful)
Also, Your Query is really barebones for the most part. Nothing too fancy. It might just be your server latency.