Re: out of memory for query result

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Allen <dba(at)girders(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: out of memory for query result
Date: 2005-10-22 20:10:15
Message-ID: 20051022201015.GG16589@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Oct 22, 2005 at 03:46:18PM -0400, Allen wrote:
> I am trying to select a result set from a 2-table join, which should be
> returning 5,045,358 rows. I receive this error:
>
> DBD::Pg::st execute failed: out of memory for query result

AFAIK, DBD:Pg never uses a cursor unless you ask it to. So you probably
want to code a loop like:

DECLARE CURSOR blah AS ...
while( FETCH 1000 )
{
process rows...
}

If you don't use a cursor in the backend, then DBI will try to pull the
*entire* result and store it in memory, which is why you don't have
enough...

Hope this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve V 2005-10-22 20:30:32 Transaction IDs not the same in same transaction?
Previous Message Zlatko Matić 2005-10-22 20:05:41 pg_autovacuum (8.0.4) as Windows service ?