标签:min gen student weight pre generate arch rate where
x
主表:Base(BaseID Int,BaseName Nvarchar(200)) 关系表:BaseForUser(BaseForUserID Int,BaseID Int)
要删除BaseID为1数据,当然BaseForUser中BaseID为1的数据也要删除...
(并且要删除的数据还不多,Base表一条数据,BaseForUser表中10条数据左右)
But BaseForUser中数据比较多(客户比较多,你懂得),一亿多...
Declare @BaseID Int = 1 Delete From BaseForUser Where BaseID = @BaseID Delete From Base Where BaseID = @BaseID --耗时 1分钟多...Pass
第二个版本: Delete Base From (Select BaseID From BaseForUser Where BaseID = @BaseID) U Where Base.BaseID = U.BaseID --耗时50s...Pass
--确定范围 Declare @User Table(BaseForUserID Int Primary Key) Insert Into @User Select T.ClassTableGenerateForStudentID From BaseForUser U With(NoLock) Where U.BaseID = @BaseID Delete From BaseForUser Where BaseForUserID Between ( Select Min(BaseForUserID) From @User ) And ( Select Max(BaseForUserID) From @User ) And BaseID = @BaseID
--耗时10s,好吧,先这样吧...-_-||
x
标签:min gen student weight pre generate arch rate where
原文地址:https://www.cnblogs.com/love-zf/p/9180682.html