Received: from smtp016.mail.yahoo.com (smtp016.mail.yahoo.com [216.136.174.113]) by postgresql.org (Postfix) with SMTP id 7EB11475CA0 for ; Wed, 13 Mar 2002 12:38:42 -0500 (EST) Received: from janwieck (AUTH login) at psc.progress.com (HELO saturn.janwieck.net) (janwieck@192.233.92.200) by smtp.mail.vip.sc5.yahoo.com with SMTP; 13 Mar 2002 17:38:47 -0000 Received: (from wieck@localhost) by saturn.janwieck.net (8.11.2/8.11.2) id g2DGTRp31887; Wed, 13 Mar 2002 11:29:27 -0500 From: Jan Wieck Message-Id: <200203131629.g2DGTRp31887@saturn.janwieck.net> Subject: Re: Large data sets and FOR LOOP's In-Reply-To: <1016012241.1094.90.camel@netgroup> from Bo Lorentsen at "Mar 13, 2002 10:37:21 am" To: Bo Lorentsen Date: Wed, 13 Mar 2002 11:29:26 -0500 (EST) Cc: pgsql-sql X-Mailer: ELM [version 2.4ME+ PL68 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archive-Number: 200203/162 X-Sequence-Number: 7042 Bo Lorentsen wrote: > Hi ... > > I have been working on some server side scripts in Plpgsql and I'm quite > happy about them (nice and fast way to work with large data sets) :-) > > But, if I, in my code, make "for loop" on a huge select result (about > 1.7 mil. rows), my function begin to consume alot of memory. The code > looks like this : > > FOR trec IN SELECT f1,f2 FROM large_tabel LOOP > ... > END LOOP; You probably want to upgrade to 7.2, because 7.2's PL/pgSQL uses the newly available SPI cursors silently in FOR loops. Releases before 7.2 loaded the entire result set into memory (ahem, swap space) before entering the FOR loop. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com # _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com