我在相对较小的表(~5000 行)之间运行一个简单的左连接查询:
select *
from table1
left join table2
force index (index_table2_on_name) for join
on table1.name = table2.name
index_table2_on_name存在,但Mysql拒绝使用。对查询运行解释返回:两个表的 select_type = SIMPLE,type = ALL 和 possible_keys = NULL。
有什么想法吗?
最佳答案
发现问题。 看起来 table1.name 和 table2.name 定义了不同的字符集。 奇怪的是Mysql忽略索引而不是使用转换。
关于MySQL 强制索引不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4860113/