Re: Large aggregate query running out of memory in ExecutorState

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Casey Duncan <casey(at)pandora(dot)com>
Cc: PostgreSQL-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Large aggregate query running out of memory in ExecutorState
Date: 2007-03-02 21:34:12
Message-ID: 16761.1172871252@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Casey Duncan <casey(at)pandora(dot)com> writes:
> I have some nightly statisics queries that runs against a view which
> unions several large tables. Recently one of these queries started
> running into out of memory errors. This is on postgresql 8.1.8
> running on 32-bit Debian Linux.

What have you got work_mem set to, and what's the actual process size
limit the kernel is enforcing? It looks to me like your query will
try to eat at least twice work_mem for the two COUNT DISTINCT operations.
Another issue is that the measurement of how much space is really being
used is not necessarily very accurate --- I don't recall exactly how
good 8.1 is about that, but it wouldn't surprise me too much if the
actual net memory demand was about twice as much again.

Anyway the short answer is probably "reduce work_mem".

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2007-03-02 21:39:38 Re: How often do I need to reindex tables?
Previous Message dlivesay 2007-03-02 21:33:35 Re: I'd love to know what the rest of this error message is.