All Forums Analytics
anadi.bhalla 5 posts Joined 04/09
26 May 2009
difference between distinct and group by

Hi,

When we fetch unique rows from a table which is better distinct or group by??

naren 4 posts Joined 09/06
26 May 2009

"GROUP BY" improves perfomance compare to DISTINCT CLAUSE.

dnoeth 683 posts Joined 11/04
26 May 2009

It depends.

as a rule of thumb: If you don't know exactly about the data, better use GROUP BY.

DISTINCT is better for columns with a low number of rows per value: #rows < #AMPs
GROUP BY is better for columns with a large number of rows per value: #rows > #AMPs

TD13 will automatically rewrite DISTINCT to GROUP BY and apply some new algorithms to get faster response.

Dieter

You must sign in to leave a comment.