Re: Out of memory error - Mailing list pgsql-general

From Joshua D. Drake
Subject Re: Out of memory error
Date
Msg-id 4207E2F2.5090302@commandprompt.com
Whole thread Raw
In response to Re: Out of memory error  (Clodoaldo Pinto <clodoaldo.pinto@gmail.com>)
Responses Re: Out of memory error
List pgsql-general
Clodoaldo Pinto wrote:
> On Mon, 07 Feb 2005 09:32:47 -0800, Joshua D. Drake
> <jd@commandprompt.com> wrote:
>
>>>Any advice on how to avoid it?
>>
>>Use a cursor.
>>
>
> Same thing using a cursor:

Well your first email didn't explain that you were doing the below :)
The cursor will help you with large data pulls from a select.
However you aren't doing a simple select. You are doing an insert into
with a select as your data source.

>
> declare
>     rdata record;
> begin
> truncate table usuarios2;
> for rdata in
> select distinct on (data) data
> from usuarios
> loop
> insert into usuarios2
>     (
>     data,
>     usuario,
>     pontos,
>     wus
>     )
> select
>     data,
>     usuario,
>     sum(pontos),
>     sum(wus)
> from usuarios
> where data = rdata.data
> group by data, usuario
> ;
> end loop;
> return;
> end;

Is this the entire function?

Sincerely,

Joshua D. Drake





--
Command Prompt, Inc., your source for PostgreSQL replication,
professional support, programming, managed services, shared
and dedicated hosting. Home of the Open Source Projects plPHP,
plPerlNG, pgManage,  and pgPHPtoolkit.
Contact us now at: +1-503-667-4564 - http://www.commandprompt.com


Attachment

pgsql-general by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: Sorting when "*" is the initial character
Next
From: "Joshua D. Drake"
Date:
Subject: PHP/PDO Database Abstraction Layer