Re: "group by" is quite expensive

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Albertson, Chris" <CAlbertson(at)primeadvantage(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: "group by" is quite expensive
Date: 2001-05-02 22:51:10
Message-ID: 17438.988843870@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Albertson, Chris" <CAlbertson(at)primeadvantage(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Eliel Mamousette 2001-05-02 22:57:14 RE: SQL Server -> Postgres migration: Stored Procedure replacement?
Previous Message David Scholes 2001-05-02 22:48:41 Re: Tuple Max Size on 7.1