Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Performance of nesting queries 1

Status
Not open for further replies.

Luzian

Programmer
Nov 27, 2005
103
US
I don't know how SQL Server does its magic on the inside. I was wondering how much a difference these queries would make:

Code:
SELECT *
FROM
(
[tab]SELECT *
[tab]FROM [SomeTable]
)

and:
Code:
SELECT *
FROM [SomeTable]

Does it optimize the query in some way that it knows what you're trying to do?
 
That perticular query should execute the same on both ways.

Sub queries start to become more usefull if you need to hit parts of the child table from the parent table for performance reasons or data convertion reasons.

When looking into performance the execution plan will be your best friend. It will tell you how SQL plans on getting to the data and what parts of the query will cost you the most time.

Denny
MCSA (2003) / MCDBA (SQL 2000) / MCTS (SQL 2005) / MCITP Database Administrator (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top