我在Update語句中有這個子查詢。它在執行計劃中顯示出一個熱點。請建議,如果可以改進一些代碼來獲得性能。SQL子查詢性能需要改進
--Schema of temp table.
CREATE TABLE #tmpInvestorJob (
LogID INT,
[Status] INT,
JobType VARCHAR(20)
)
CREATE CLUSTERED INDEX IX_tmpInv_Status ON #tmpInvestorJob ([Status]);
----#TempTimeline has less than 10 records but has lot of columns.
----#tmpInvestorJob has lots of data inside and is main reason for the slowness.
UPDATE g
SET Completed = ISNULL(a.Completed, 0)
FROM #TempTimeline g
JOIN (
SELECT LogID,
COUNT(1) 'Completed'
FROM #tmpInvestorJob
WHERE [Status] = 3
GROUP BY LogID
) a ON a.LogID = g.LogID
請建議,如果我們可以改善上述Update語句..
Index'LogID'列以及看看會發生什麼.. –
熱點你的意思是高百分比?你有三個陳述,這是緩慢的?假設它是'UPDATE',它的'查詢計劃是什麼樣子?任何索引建議或表掃描? –