当我试图检查不同测试之间的结果是否存在差异时,我遇到了一个问题。内部select语句返回大约5000行,但是连接不会在一分钟内完成。我预计输出大约为10行。连接速度如此之慢有什么原因吗?
select * from(
select *
from R inner join C
on R.i = C.j
where C.j in (2343,3423,4222,1124,2344)
) AS A,(
select *
from R inner join C
on R.i = C.j
where C.j in (2343,3423,4222,1124,2344)
) AS B
where A.x = B.x and
A.y = B.y and
A.result <> B.result发布于 2016-06-14 02:43:51
我认为你可以使用聚合来做你想做的事情:
select x, y, group_concat(distinct result) as results
from R inner join
C
on R.i = C.j
where C.j in (2343, 3423, 4222, 1124, 2344)
group by x, y
having count(distinct result) > 1;对于此查询,C(j)和R(i)上的索引将非常有用。我也会将x和y添加到适当的索引中,但我不知道它们是从哪个表中梳理出来的。
https://stackoverflow.com/questions/37793456
复制相似问题