Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WHERE IN approach
Message
From
28/02/2017 04:35:14
 
 
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:
01648608
Views:
31
>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?

If the Performance in practice is not different I would prefer IN(1,2) for two reasons:
- It is more readable (WHERE MyField IN (1,3,5,7,9,11,13,15)
- It does not need additional parentheses if there are other expressions in the where clause
Christian Isberner
Software Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform