Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Performance switched with parameter
Message
From
23/09/2014 15:22:22
 
 
To
23/09/2014 14:11:33
General information
Forum:
Microsoft SQL Server
Category:
Indexing
Environment versions
SQL Server:
SQL Server 2012
Application:
Web
Miscellaneous
Thread ID:
01607903
Message ID:
01608109
Views:
50
>Kevin mentioned about the design of what the execution plan shows. It is exactly as he says. If it mostly a bunch of Compute Scalar and Constant Scan. Their cost is at 0%. So, I am not sure if this is really a factor.
>
>In both cases, it does take my index. So, I am not sure if it just a question a nanosecond of difference or much significative.

Michel, if you're getting the same performance and the same usage of the index, and the only difference is a paired set of compute scalar/constant scans for each variable in the execution plan, then I can say with confidence that the difference is insignificant.

Again, when you use variables instead of literals in the WHERE clause (and I'm not even talking about parameters, just plain variables), SQL Server has to take an extra tiny step to evaluate the variables and then create an internal "constant row".

The execution plan might really "look wonky" compared to using literals, especially if you have many variables - but because the total cost of all those additional operators is so small relative to the entire query cost, it's nothing to be concerned about. It's simply the way SQL Server works.

This is a different situation than the RECOMPILE option that you and Walter talked about - that's when you have things like parameter sniffing, or when you've done things like:
WHERE CustomerAccount = @CustomerAccount OR CustomerAccount IS NULL.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform