Re: out of memory for query result - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: out of memory for query result
Date
Msg-id 20051022201015.GG16589@svana.org
Whole thread Raw
In response to out of memory for query result  (Allen <dba@girders.org>)
Responses Re: out of memory for query result  (Allen Fair <allen@cyberdesk.com>)
List 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@svana.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.

Attachment

pgsql-general by date:

Previous
From: Franck Coppola
Date:
Subject: Re: How to cluster Postgresql
Next
From: Steve V
Date:
Subject: Transaction IDs not the same in same transaction?