语名如下:
select top 300 * from kq_source where tt>='1' and tt<='100'
and empid in (select id from zlemployee where Dept='zx' and state<>'9')
执行速度在1分钟左右~如IN后面直接用值却很快。
请高手帮我优化!
select top 300 * from kq_source where tt>='1' and tt<='100'
and empid in (select id from zlemployee where Dept='zx' and state<>'9')
执行速度在1分钟左右~如IN后面直接用值却很快。
请高手帮我优化!
top 300 t.*
from
kq_source t
where
t.tt>='1' and t.tt<='100'
and
exists(select 1 from zlemployee where Dept='zx' and state<>'9' and id=t.empid)
kq_source 表中大约有100万条记录
zlemployee 表中大约2000条记录麻烦再帮我看看
select id from zlemployee where Dept='zx' and state<>'9'
((select id from zlemployee where Dept='zx' and state<>'9')) t
where tt>='1' and tt<='100' and kq_source.empid = t.id
((select id from zlemployee where Dept='zx' and state<>'9')) t
where tt>='1' and tt<='100' and kq_source.empid = t.id