Re: "group by" is quite expensive - Mailing list pgsql-general

From Tom Lane
Subject Re: "group by" is quite expensive
Date
Msg-id 17438.988843870@sss.pgh.pa.us
Whole thread Raw
In response to "group by" is quite expensive  ("Albertson, Chris" <CAlbertson@primeadvantage.com>)
List pgsql-general
"Albertson, Chris" <CAlbertson@primeadvantage.com> writes:
> What can I do to speed up queries like the following

>    select count(*) from ttt group by xxx;

Not much at the user level, I'm afraid.  Currently GROUP BY requires
a sort on the grouping column, and that's expensive for a big table.

There has been talk of reimplementing GROUP BY to avoid sorting
(instead maintaining a hash table with one entry for each distinct
value of the grouping column), and it might get done for 7.2 or so.

            regards, tom lane

pgsql-general by date:

Previous
From: Joel Burton
Date:
Subject: Re: multiple INSERT
Next
From: Joel Burton
Date:
Subject: Re: Security and performance