Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> You can do:
>
> SELECT COUNT(*) FROM (SELECT DISTINCT profile.id, profile.name,
> profile.age FROM ...) x;
Ah, I see what they wanted now. In older versions of PostgreSQL,
they might get better performance in some cases by using GROUP BY:
SELECT COUNT(*) FROM
(SELECT id, name, age FROM profile GROUP BY id, name, age) x;
I don't remember offhand what version started considering a hash for
DISTINCT.
-Kevin