Click here to Skip to main content
15,178,605 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

Could you please tell me the disadvantages of subqueries in sql server?

I have gone through google.

But, I got only one answer that subqueries execution is slow than joins because of query optimizer process in sql server.

Please tell me if there are other disadvantages also...
Posted

The best way to see whats going on is to use SQL to give you an execution plan. Here are the basics though.

1)JOIN:

SQL looks at the query, and basically creates a new table of the joined tables and then gets the results from there. So ultimately, its just one call!

2) Sub query:

SQL now has to run multiple queries to get your result, which, although might be instant because SQL is made by magical fairies, is still going to be a lot more resource intensive.

The best way for you to see the disadvantages is to run a query with an execution plan and see the results! That way, you can see for yourself!
   
Comments
walterhevedeich 21-Jul-11 21:16pm
   
Totally agree. Earns a 5.
In addition to the previous solution, you can use database performance monitoring tools such as SQL Profiler[^], if you are concerned with number figures in terms of their difference in execution.
   
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900