Re: memory usage of group by select

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Anthony <osm(at)inbox(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: memory usage of group by select
Date: 2009-12-29 21:09:23
Message-ID: 20091229210923.GJ4569@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Anthony wrote:
> On Tue, Dec 29, 2009 at 3:41 PM, Anthony <osm(at)inbox(dot)org> wrote:
>
> > I'm running a group by query on a table with over a billion rows and my
> > memory usage is seemingly growing without bounds. Eventually the mem usage
> > exceeds my physical memory and everything starts swapping.
> >
>
> I guess I didn't ask my question. Is this expected behavior? Is there any
> way for me to adjust my settings to avoid using so much memory?

It's expecting 85k distinct groups. If that's not accurate, then
HashAggregate would use more memory than expected. See if you can make
it work by setting enable_hashagg = off.

If that works, good -- the real solution is different. Maybe you need
to ANALYZE more, or increase the size of the stats bin for this column.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nick 2009-12-29 21:21:07 Re: Installation of Postgis/postgresql
Previous Message Raymond O'Donnell 2009-12-29 21:05:44 Re: DDL commands take forever