mysql - "using join buffer"在 MySQL 查询的解释表中意味着什么?

标签 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

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

最佳答案

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

关于mysql - "using join buffer"在 MySQL 查询的解释表中意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21546450/

相关文章:

mysql - 使用 Limit 从 a 到 z 排序

mongodb - Mongo - 选择具有最大子文档数的父文档,更快的方法?

mysql - 优化正则表达式查询

mysql - where 子句匹配同一个表中的 2 行来获取结果

php - 通过ajax(html)将Html文本发送到php脚本以存储在数据库中。它只保存到

mysql - sql语句中mysql session 变量值的优先级

mysql - 如何在 mySQL 表中计算 10 个不同的 IP

c# - 如何修复 SqlError :failed when converting date and/or time from character string. EF 二进制表达式?

sql - 每行查询最后 N 个相关行

database - 查询冗余和优化的地方