Re: GROUP BY on a large table -- an idea - Mailing list pgsql-hackers

From Martijn van Oosterhout
Subject Re: GROUP BY on a large table -- an idea
Date
Msg-id 20061012095726.GC11723@svana.org
Whole thread Raw
In response to GROUP BY on a large table -- an idea  ("Dawid Kuroczko" <qnex42@gmail.com>)
List pgsql-hackers
On Thu, Oct 12, 2006 at 09:52:11AM +0200, Dawid Kuroczko wrote:
> Recently I've been playing with quite a big table (over 50mln rows),
> and did some SELECT ... sum(...) WHERE ... GROUP BY ... queries.
>
> The usual plan for these is to sort the entries according to GROUP BY
> specification, then to run aggregates one by one.  If the data to be
> sorted is large enough, PostgreSQL has no other option than to spill
> to disk, which well, Isn't the fastest...

<snip>

Sounds an awful lot like the HashAggregate nodetype which has existed
since at least 7.4. It has a hashtable of "keys" with attached
"states".

Hope this helps,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Hints WAS: Index Tuning Features
Next
From: Teodor Sigaev
Date:
Subject: Re: Patch for Win32 blocking problem