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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is faster? 1

Status
Not open for further replies.

grande

Programmer
Feb 14, 2005
657
CA
This is more theoretical than practical, but which of these two statements would execute faster?

SELECT dye_method
FROM SC_CUSTOM_STYLE_SPEC
WHERE (dye_method IS NOT NULL) AND (dye_method != '')
GROUP BY dye_method

or

SELECT DISTINCT dye_method
FROM SC_CUSTOM_STYLE_SPEC
WHERE (dye_method IS NOT NULL) AND (dye_method != '')

-------------------------
Call me barely Impressive Captain.
 
When I run a similar query on one of my tables, the execution plan is identical. So, in theory, they are the same.

You can easily try it for yourself. Load both queries in to a single query window in Query Analyzer. Press CTRL-K, and then run it (press F5).

At the bottom of the screen, you will see an execution plan tab. Click it and you will see that the cost of each query (relative to the batch) is 50%, and the execution plan itself will be the same.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Oh great! Thanks for that!

-------------------------
Call me barely Impressive Captain.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top