On Mon, 07 Feb 2005 09:32:47 -0800, Joshua D. Drake <jd@xxxxxxxxxxxxxxxxx> 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
begin:vcard fn:Joshua D. Drake n:Drake;Joshua D. org:Command Prompt, Inc. adr:;;PO Box 215;Cascade Locks;Oregon;97014;USA email;internet:jd@xxxxxxxxxxxxxxxxx title:Consultant tel;work:503-667-4564 tel;fax:503-210-0334 note:Command Prompt, Inc. is the largest and oldest US based commercial PostgreSQL support provider. We provide the only commercially viable integrated PostgreSQL replication solution, but also custom programming, and support. We authored the book Practical PostgreSQL, the procedural language plPHP, and adding trigger capability to plPerl. x-mozilla-html:FALSE url:http://www.commandprompt.com/ version:2.1 end:vcard
---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq