Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WHERE IN approach
Message
 
 
To
27/02/2017 16:53:31
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2014
OS:
Windows 8.1
Network:
Windows Server 2012
Miscellaneous
Thread ID:
01648591
Message ID:
01648592
Views:
41
>I compared two approaches in WHERE clause.
>
>The first one was about using a regular syntax such as WHERE Client.NoProvince=1 OR Client.NoProvince=2 while the other one was using the IN approach such as WHERE Client.NoProvince IN (1,2).
>
>When I analyzed the execution plan, I see the first approach used the index seek at 51% with an aggregate at 49%. The second approach used the index seek at 62% with an aggregate at 38%. The second approach, however, uses a parallelism under 1%.
>
>So, here's the question or concerns:
>
>1. While the IN approach is cleaner, is it as optimized (the scenario seems to indicate so but best practices may apply)
>2. Is the IN syntax SQL Ansi standard
>3. Is the usage of the parallelism approach any factor at all
>
>Which one do you prefer? Which one do you use?

I normally use the second approach (e.g. IN) when the number of possibilities is limited (not a very long list)
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform