在MySQL查询的Explain表中,“使用连接缓冲区”是什么意思?

时间:2014-02-04 07:29:51

标签: mysql sql query-optimization

我有以下复杂查询,我注意到它使我的网站变得如此之慢,我想找到一种方法来优化它:

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

我在数据库或优化方面没有太多经验,所以我为这个查询做了一个解释,我得到了这个表:

explain table

我认为行中的问题告诉“使用连接缓冲区”,但这是什么意思? 你能帮我理解这一点并优化查询吗?

1 个答案:

答案 0 :(得分:1)

我建议检查索引,尤其是要加入的列。你有match_of_comments.match_id的索引吗?此外,tahmins.id上的索引似乎缺失了。