Hi,
Can any one please let me know which one is better in performance, Joins or sub-queries?
Any other differences between joins and sub-queries plz let me know.
Thanks
Pradeep
pradeepyr:
I would suggest that the best way to answer your question is to take quick benchmarks whenever you have doubt. In general (1) look at the execution plan, (2) query execution time and (3) query IO statistics and judge based on this information. This is all information that is readily obtainable from the Query Analyzer in SQL Server 2000 and SQL Server Management Studio in SQL Server 2005.
|||
Dave
joins and subqueries solve different purposes, and cant/may not be replaced just for the sake of it...
**use a subquery when u may not need the column from the table used the subquery in the result set of outer query.....
join is usually easy to optimize than a subquery... as join joins the whole tables based on a condition, use it when u retrive more data....
all said if u have a confusion, and choice of using both,(both givin same result), check the query plans, and decide, or simply go for joins , excluding the one condition i mentioned**..
No comments:
Post a Comment