Re: count function alternative in postgres - Mailing list pgsql-hackers

From Kevin Grittner
Subject Re: count function alternative in postgres
Date
Msg-id 4BB9C9B00200002500030463@gw.wicourts.gov
Whole thread Raw
In response to Re: count function alternative in postgres  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: count function alternative in postgres  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
Robert Haas <robertmhaas@gmail.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


pgsql-hackers by date:

Previous
From: Jaime Casanova
Date:
Subject: Re: Autonomous transaction
Next
From: Greg Sabino Mullane
Date:
Subject: Show schema name on REINDEX DATABASE