我有以下复杂的查询,我注意到它使我的网站变得如此缓慢,我想找到一种方法来优化它:
SELECT tahminler.result,
tahminler.tahmin,
tahminler.match_id,
tahminler.timestamp,
tahminler.tahmin_text,
users.username,
matches_of_comments.tournament_id,
matches_of_comments.match_status,
matches_of_comments.match_date,
matches_of_comments.localteam_name,
matches_of_comments.visitorteam_name,
matches_of_comments.localteam_id,
matches_of_comments.visitorteam_id,
matches_of_comments.localteam_goals,
matches_of_comments.visitorteam_goals,
new_iddaa.iddaa_code,
tahminler_results.ms1,
tahminler_results.ms2,
tahminler_results.ms0,
tahminler_results.alt,
tahminler_results.ust,
tahminler_results.tg_0_1,
tahminler_results.tg_2_3,
tahminler_results.tg_4_6,
tahminler_results.tg_7,
tahminler_results.kg_var,
tahminler_results.kg_yok,
tahmins.tahmin as text_tahmin
FROM tahminler
INNER JOIN users on users.id = tahminler.user_id
INNER JOIN matches_of_comments on tahminler.match_id = matches_of_comments.match_id
Left JOIN new_iddaa on new_iddaa.match_id = matches_of_comments.match_id
INNER JOIN tahmins on tahminler.tahmin = tahmins.id
LEFT JOIN tahminler_results on tahminler.match_id = tahminler_results.match_id
Where tahminler.user_id = $user_id
order by tahminler.timestamp DESC
我在数据库或优化方面没有太多经验,因此我对此查询进行了解释,并得到了此表:
我认为该行中的问题告诉“使用连接缓冲区”,但这是什么意思? 你能帮助我理解这一点并优化查询吗?
最佳答案
我建议检查索引,尤其是您想要加入的列。您有 matches_of_comments.match_id 索引吗?此外,tahmins.id 上的索引似乎丢失了。
关于mysql - "using join buffer"在 MySQL 查询的解释表中意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21546450/