views:

31

answers:

1

Does

SELECT TOP 1000 * FROM TABLE

return the same data execution plan as

SELECT * FROM TABLE?

Please also let me know if this should be moved to ServerFault.

Thanks.

A: 

You can check for yourself. In SSMS, go to Query -> Include Actual Execution Plan

Then run your queries.

e.g. when I run:

SELECT TOP 10 * FROM sys.tables
SELECT * FROM sys.tables

They return different execution plans.

AdaTheDev
For a single table though (rather than view) I can't imagine it would ever be the case.
Martin Smith
I am on a time crunch and the queries could run upwards of 8 hours. So I was looking for a way to sort of get around it.
Jim
@Jim - You can look at estimated query plans as well.
Martin Smith
@Martin - technically, the execution plan is different for a single table (try it) as it will include a "TOP" operator in the plan. But my main point is, "try it and see with your specific query"
AdaTheDev
@Ada Good point - Well made!
Martin Smith
@MartinSmith - I have been doing that as well. I didn't know if there was significant differences between estimated and actual. Thanks.
Jim