是否有人有關於如何提高以下語句的任何建議:執行SELECT語句並插入到同一個表中的最佳方法?
insert into ProductInfo with (rowlock) (orderid, productname)
select 66673, FileInfoId
from ProductInfo with (nolock) where
ProductId = 66671 and
IsEligableForCopy = 1 and
ProductFileInfoId >= 2768395941 and
ProductFileInfoId < 2768405941
您有什麼問題?它失敗了嗎?它運行速度是否太慢?它是否創建了太多的鎖?它報告錯誤嗎? – MJB 2010-06-14 12:32:48
它有時會返回超時查詢。 – RPS 2010-06-14 12:35:50
@Salil - 不確定重新格式化是否必要。我更喜歡馬克的版本! @RPS - 你對'ProductInfo'有什麼索引?那麼Select會返回多少條記錄? – 2010-06-14 12:38:08