Tuesday, July 28, 2009

distinct or group by, what's more expensive

today I was asking my self about the best approach for a performance critical application.

Distinct or group by '*'

select name from table group by name


select distinct name from table

after all they both return the exact same result.

Some explain statements later it turned out that the group by clause is 18% faster than the distinct statement.

No comments:

Post a Comment