我需要优化以下查询,有人可以帮忙吗?我知道是 Not Exists 部分导致了问题,因为它正在进行大规模的表扫描,但我对此并不陌生,任何人都可以提供任何建议吗?
select count(*)
from Job j
where company = 'A'
and branch = 'Branch123'
and engineerNumber = '000123'
and ID > 60473
and not exists(
select JobNumber, Company, Branch
from OutboundEvents o
where o.JobNumber = j.JobNumber
and o.branch = j.branch
and o.company = j.company
and o.Formtype = 'CompleteJob')