Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
WHERE IN approach
Message
De
28/02/2017 15:19:20
 
 
À
28/02/2017 13:24:24
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:
01648640
Vues:
36
>>>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.
>>
>>Thanks
>
>I realize that the original
>
>>>>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).
>
>probably was ONLY example data. But the very first thought (guessing that NoProvince is intX typed) for optimization would be "Between" or the equivalent >= and <= query syntax to skip the problem Fabio mentioned ;-)
>
>BTW &ge and &le were tried first but not translated in preview at least ;-)

the true headache begin when you have this situation:
where condition1 OR condition2
both condition1 condition2 that are optimized
but the engine generates a plan that run across the all table.
I solve with a UNION, which has zero readability,
but it can be thousands of times faster
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform