I have a case where using a JOIN or an IN will give me the correct results… Which typically has better performance and why? How much does it depend on what database server you are running? (FYI I am using MSSQL)
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Generally speaking,
INandJOINare different queries that can yield different results.is not the same as
, unless
b.colis unique.However, this is the synonym for the first query:
If the joining column is
UNIQUEand marked as such, both these queries yield the same plan inSQL Server.If it’s not, then
INis faster thanJOINonDISTINCT.See this article in my blog for performance details:
INvs.JOINvs.EXISTS