SQL Server stored procedure parameters decrease performance

When we use parametrs directly in query's WHERE parts,
performance of query decrease dramatically.

So we can use local values to copy these parametrs.

1 ALTER PROCEDURE [dbo].[CalculateSomething]
2 @myID INT
3 AS
4 BEGIN
5 DECLARE @myIDLocal INT
6
7 SET @myIDLocal = @myID -- If you this performance of query
8 -- will inctrease!
9 SELECT * FROM myTable WHERE ID = @myIDLocal

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.