Reputation: 45
I work on sql server, and I want to optimize this request, it takes a lot of time!
Update T_Stock
SET
Flag_Delete = T_Delta.Flag_Delete,
Date_Chgt = T_Delta.Date_Chgt,
Date_Maj = ?
FROM Delta.JDonneesComplementaires_RattPop T_Delta
INNER JOIN stock.JDonneesComplementaires_RattPop T_Stock ON T_Delta.Concat_JDonneesComplementaires_RattPop = T_Stock.Concat_JDonneesComplementaires_RattPop
WHERE Mode_Alim='S'
Upvotes: 1
Views: 58
Reputation: 520948
The following index may speed up the join and WHERE
filter:
CREATE INDEX idx ON Delta.JDonneesComplementaires_RattPop
(Concat_JDonneesComplementaires_RattPop, Mode_Alim);
The first component of the index RattPop
would target the ON
clause of the join, while the second component Mode_Alim
would cover the WHERE
clause.
Upvotes: 2