I'm Just using the table which having more than 200 thousand records each.I need to Fetch Unique
records by joining those tables .Which keyword would work faster in this case using Distinct
or Group by
?.It should be looked from performance wise better and faster one.Kindly suggest me.
Asked
Active
Viewed 101 times
-3

Hell Boy
- 971
- 2
- 12
- 28
-
3Write both and compare. What do you want us to do? – Giorgi Nakeuri Jun 08 '15 at 10:03
-
Need to know which keyword should be used to get unique values in faster way and effective.? – Hell Boy Jun 08 '15 at 10:04
-
check it:http://stackoverflow.com/questions/581521/whats-faster-select-distinct-or-group-by-in-mysql – Tirma Jun 08 '15 at 10:09
-
I seriously doubt that the guys at Microsoft would have made DISTINCT slower, what would be the point of it if they had? As for which is better from a readability point of view I would say DISTINCT is better if you have no need for aggregates as better expresses the intent. – Martin Brown Jun 08 '15 at 10:12
-
I'm voting to close this question as off-topic because you already have everything you need in order to test it yourself. – Zohar Peled Jun 08 '15 at 10:13
-
But i have mentioned specific scenario here about which keyword should be used @Zohar peled – Hell Boy Jun 08 '15 at 10:15
-
The person asking the question tends to be in the best position to answer ["Which is faster?"](http://ericlippert.com/2012/12/17/performance-rant/) questions. As has been said, run the two queries and check the execution plans, as well as the IO statistics. Then if you different execution plans, or significantly different execution times (that are repeatable, not just down to a one off high server load for example), then it might be a better question to ask why there is a difference in a new question, and including the execution plans and IO statistics in the new question. – GarethD Jun 08 '15 at 10:17
-
As Trima wrote in his/her answer, both queries have the same execution plan. you could have and should have tested that yourself before asking. – Zohar Peled Jun 08 '15 at 10:17
1 Answers
3
Both queries has the exactly same execution plan.
select distinct a,b,c from bigTable
select a,b,c from bigTable
group by a,b,c
works with the same process, so you can choose the sintax you prefer. For being a best Query tunning user, just use "Show execution plan" button from the SQL Server Management Studio. It is really usefull.

Tirma
- 664
- 5
- 16