Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
WHERE IN approach
Message
De
28/02/2017 02:28:38
 
 
À
27/02/2017 16:53:31
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2014
OS:
Windows 8.1
Network:
Windows Server 2012
Divers
Thread ID:
01648591
Message ID:
01648604
Vues:
40
>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform