关于如何优化MySQL查询中的连接的任何输入?例如,考虑以下查询如何优化多个连接的MySQL查询?
SELECT E.name, A.id1, B.id2, C.id3, D.id4, E.string_comment
FROM E
JOIN A ON E.name = A.name AND E.string_comment = A.string_comment
JOIN B ON E.name = B.name AND E.string_comment = B.string_comment
JOIN C ON E.name = C.name AND E.string_comment = C.string_comment
JOIN D ON E.name = D.name AND E.string_comment = D.string_comment
表A,B,C,d是临时表,并含有1096行和表E(也临时表)包含426行。在不创建任何索引的情况下,MySQL EXPLAIN向我显示了从所有表中搜索的所有行。现在,我在所有表A,B,C,B和E上为名称创建了名为name_idx和string_comment的FULLTEXT索引作为string_idx。EXPLAIN命令仍然给出了如下所示的相同结果。 另外,请注意, 名称和string_comment VARCHAR类型和IDX的都是int类型(15)
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE A ALL name_idx,string_idx 1096
1 SIMPLE B ALL name_idx,string_idx 1096 Using where
1 SIMPLE C ALL name_idx,string_idx 1096 Using where
1 SIMPLE D ALL name_idx,string_idx 1096 Using where
1 SIMPLE E ALL name_idx,string_idx 426 Using where
我如何能调整任何评论此查询?
谢谢。
您还应该调用ANALYZE TABLE这将进一步帮助调整查询。 –