Re: Odd out of memory problem.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Odd out of memory problem.
Date: 2012-03-26 15:18:26
Message-ID: 25811.1332775106@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> I'm really perplexed as to why this fairly simple query should cause an
> out of memory error:
> select loid, max(pageno) from ldata group by loid order by 2 desc
> limit 10;

Looks like the group by/aggregate step is eating lots of memory:

> AggContext: 864018432 total in 127 blocks; 3400 free (110
> chunks); 864015032 used
> TupleHashTable: 619175960 total in 95 blocks; 821528 free
> (331 chunks); 618354432 used

A guess is that there are a huge number of distinct values of "loid" but
the planner fails to realize that and tries to use a hash aggregation.
Could we see EXPLAIN output for this query?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2012-03-26 15:48:18 Re: Odd out of memory problem.
Previous Message Hans-Jürgen Schönig 2012-03-26 15:16:42 Re: Odd out of memory problem.