我有三个应该连接的表,查询如下所示:
select distinct a.job
from a
join b on a.job=b.id
join c on c.id =a.path
where c.path like '//depot/a/b/c/d/MARSR_CL286896_297899/%';
此查询将始终超时。但是,如果我将路径比较更改为其他条件,则查询将完美运行,例如:
select distinct a.job
from a
join b on a.job=b.id
join c on c.id =a.path
where c.path like '//depot/a/b/c/d/%';
考虑到路径参数的不同,数字和下划线会不会是减慢语句的罪魁祸首?我为“路径”字段创建了索引
“解释”命令的结果
1 SIMPLE b index PRIMARY job 62 73580 Using index; Using temporary
1 SIMPLE a ref path,job job 8 b.id 153
1 SIMPLE c eq_ref PRIMARY,path PRIMARY 8 a.path 1 Using where