我尝试做如下选择:一个简单的索引连接两个表以年龄
select `table1`.`index2`
from `table1`, `table2`
where `table1`.`index1` = `table2`.`index1`
and `table1`.`index2` != `table2`.`index2`
index1
和index2
是varchar(255)
和编制索引。两个表都包含大约50k行。
这个查询花了10分钟,我杀了它,因为它太长了。
为什么需要这么长时间?
都是四个'table1'.'index1','table2'.'index1','table1'.'index2'和'table2'.index2'索引?只是为了确保... – Jacob
为什么不使用左连接或内连接? –
@cularis,是的,他们被索引 – Dani