--Requete 40. Performance cost: 3%
UPDATE #temp_arbo_of_3
SET PxAchat=NULL, CuTpsAch=NULL
WHERE IdBE IS NULL;
--Requete 41. Performance cost: 2%
UPDATE #temp_arbo_of_3
SET CuTrait = NULL
WHERE IdBE IS NOT NULL;
--Requete 42. Performance cost: 2%
UPDATE #temp_arbo_of_3
SET NrOF_Source = _ofI
WHERE IdBE IS NOT NULL;
Now if I replace all this by:
--Requete 40. Performance cost: 3%
UPDATE #temp_arbo_of_3
SET PxAchat=CASE WHEN IdBE IS NULL THEN NULL ELSE PxAchat END,
CuTpsAch=CASE WHEN IdBE IS NULL THEN NULL ELSE CuTpsAch END,
CuTrait=CASE WHEN IdBE IS NOT NULL THEN NULL ELSE CuTrait END,
NrOF_Source=CASE WHEN IdBE IS NOT NULL THEN _ofI ELSE NrOF_source END
WHERE IdBE IS NULL;
Performance (as indicated by SQL Server execution plan) is better. 3%+2%+2% > 3%
solved Lots of updates to a large table. How to speed up?