Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
WHERE IN approach
Message
 
 
À
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:
01648608
Vues:
30
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform