Re: Distinct or Group by which is faster
Those queries are not logically equivalent.
The first will return exactly one row for each combination of id,name,age values found.
The second will return exactly one row for each value of id found, along with name and age values selected arbitrarily from those found for each id.
The logical equivalent to select distinct id,name,age from ... would be select id,name,age from ... group by id,name,age.
Which is faster depends on what else is in the query. In some cases, MySQL might use execute select Distinct a,b,c as Group By a,b,c.
Subject
Views
Written By
Posted
1815
February 22, 2016 08:50AM
Re: Distinct or Group by which is faster
966
February 22, 2016 12:33PM
884
February 23, 2016 12:51PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.