我有这样的查询..
select slno
from `invoice_master`
where slno NOT IN (SELECT DISTINCT Inv_slno from `invoice_refresh`)
我在两个表中都有超过 1,40,000 条记录(invoice_master
,invoice_refresh
)
这个查询占用了执行时间。:(
这是我的解释查询的链接
帮我找出替代查询..
尝试删除NOT IS CLAUSE
已将其删除,并使用了LEFT JOIN
select
slno
from invoice_master
LEFT JOIN invoice_refresh on (Inv_slno = slno )
where Inv_slno is null
我建议你使用LEFT OUTER JOIN
:
SELECT m.slno
FROM `invoice_master` m
LEFT OUTER JOIN `invoice_refresh` r ON m.slno = r.Inv_slno
WHERE r.Inv_slno IS NULL