我有以下select语句几乎立即完成.
declare @weekending varchar(6) set @weekending = 100103 select InvoicesCharges.orderaccnumber,Accountnumbersorders.accountnumber from Accountnumbersorders,storeinformation,routeselecttable,InvoicesCharges,invoice where InvoicesCharges.pubid = Accountnumbersorders.publication and Accountnumbersorders.actype = 0 and Accountnumbersorders.valuezone = 'none' and storeinformation.storeroutename = routeselecttable.istoreroutenumber and storeinformation.storenumber = invoice.store_number and InvoicesCharges.invoice_number = invoice.invoice_number and convert(varchar(6),Invoice.bill_to,12) = @weekending
但是,等效的更新语句需要1分40秒
declare @weekending varchar(6) set @weekending = 100103 update InvoicesCharges set InvoicesCharges.orderaccnumber = Accountnumbersorders.accountnumber from Accountnumbersorders,invoice where InvoicesCharges.pubid = Accountnumbersorders.publication and Accountnumbersorders.actype = 0 and dbo.Accountnumbersorders.valuezone = 'none' and storeinformation.storeroutename = routeselecttable.istoreroutenumber and storeinformation.storenumber = invoice.store_number and InvoicesCharges.invoice_number = invoice.invoice_number and convert(varchar(6),12) = @weekending
即使我添加:
and InvoicesCharges.orderaccnumber <> Accountnumbersorders.accountnumber
在更新语句结束时将写入次数减少到零,需要相同的时间.
我在这里做错了吗?为什么会有这么大的差异?