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