如何优化这个查询
我有个查询,大概是这样的。
主要是这个WHERE里的子查询,如何优化呢
由于业务需要,这个查询,要在一个存储过程里执行7,8次,所以现在速度较慢。。
求大家指点。。谢谢
select xx,cc,vv,bb,nn from table A
join ..... B
join ..... C
join ..... D
where ((A.Sign_Man = @curMan )
or ( A.filed IN
(SELECT Stat_No FROM SystemInfo..Info_HR2Stat
WHERE HR_No = @curMan AND State = 1) and A.Sign_Man <> @curMan )
or ((dbo.aFunc(B.CurYear,B.CurMonth,B.Gs_No)=@curMan ) and A.Sign_Man <> @curMan
and A.filed not IN
(SELECT Stat_No FROM C
WHERE HR_No = @curMan AND State = 1)))