Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best practice: EXISTS vs COL_NAME in
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01464472
Message ID:
01464497
Vues:
43
>Thank you. I am trying to also understand why the EXISTS needs the expression T1.PK_FLD = T2.PK_FLD in subquery and according to Naomi the WHERE IN does not need it. But your use of 1 should make the subquery run faster.
>
>PS. If this is a duplicate post, I apologize. UT just crashed on me.
>

It crashed for me too today a few times.

As I said in my other message, there is absolutely no difference in using EXISTS (select 1 ...)
or EXISTS (select * ...)

In WHERE IN we don't need an expression because IN actually selects all the values. The EXISTS subquery just tests and exits as soon as it finds a value satisfying the condition. So EXISTS may perform faster than IN in addition of possible problems associated with IN which you don't have when using EXISTS.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform