chaos_hooi
asked on
SELECT DISTINCT or GROUP BY? Which one is better?
SELECT DISTINCT or GROUP BY all columns? Which one gives a better performance? Or are they the same?
Thanks...
Thanks...
I think GROUP BY is preferable operator than the modifier DISTINCT and in many cases works faster, of course all depends on the query you have ...
I couldn't answer better to your question than this article:
http://technet.oracle.com/products/rdb/pdf/distinct_derivedtables_groupby_sort_tech_article.pdf
Venko
I couldn't answer better to your question than this article:
http://technet.oracle.com/products/rdb/pdf/distinct_derivedtables_groupby_sort_tech_article.pdf
Venko
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you all for your answers and opinions.
SELECT DISTINCT a, b, c FROM mytable;
and
SELECT a, b, c FROM mytable GROUP BY a, b, c;
I think the CBO would generate the same plan for both of these. I don't know why you would use GROUP BY in this way - it is used to get aggregates.
Jeff