Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Group by V/S Distinct

Author  Topic 

danasegarane76
Posting Yak Master

242 Posts

Posted - 2007-06-05 : 04:47:33
Hi all,
I was told by my boss that , you should not use distinct ,use group by.Because distinct will take some resources

Thnks in Advance
Dana

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-06-05 : 04:51:04
Run two queries, onw with DISTINCT and one with GROUP BY.
Compare the two execution/query plans.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

danasegarane76
Posting Yak Master

242 Posts

Posted - 2007-06-05 : 04:57:14
Dear Perter,
Thanks for your reply. I run the same qry. It have the same result as
Select Cost = 0%
Sort distinct Sort=23%
Table cost = 77%

No difference .Then why did he say like that ?
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-06-05 : 05:10:18
Read this: [url]http://msmvps.com/blogs/robfarley/archive/2007/03/24/group-by-v-distinct-group-by-wins.aspx[/url]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

danasegarane76
Posting Yak Master

242 Posts

Posted - 2007-06-05 : 05:36:07
Thanks Harsh
Go to Top of Page
   

- Advertisement -