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

Difficult to say whether it is better to one or the other, as a logical level are equal.
If one has faith in the sql engine, use IN () because it is more explicit.
The only certainty is that the OR is the sql server nemesis.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform