I have a query that is executed several hundred thousand times a day. Due to legacy support, the incoming variables on this SP cannot change. Currently it looks like this:
Select id,
name,
otherdata
FROM Table1 t1
--<Various joins with aliases>--
INNER JOIN Culture c on c.id = t1.ID_Culture
WHERE
c.CultureTag = @CultureTag -- Usually 'en-US'
My question is: Would it be more efficient to remove the join to the culture table, and instead, SELECT the value of the primary key on the culture table and use THAT in the where clause? Would it be negligible?
EDIT: To clarify, would changing the code to this be more efficient?
DECLARE @CultureIdLocal int = (Select id from Culture where CultureTag = @CultureTag)
Select id,
name,
otherdata
FROM Table1 t1
--<Various joins with aliases>--
--INNER JOIN Culture c on c.id = t1.ID_Culture
WHERE t1.ID_Culture = @CultureIdLocal
Aucun commentaire:
Enregistrer un commentaire