Re: Large data sets and FOR LOOP's

From: Jan Wieck <janwieck(at)yahoo(dot)com>
To: Bo Lorentsen <bl(at)netgroup(dot)dk>
Cc: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Large data sets and FOR LOOP's
Date: 2002-03-13 16:29:26
Message-ID: 200203131629.g2DGTRp31887@saturn.janwieck.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(at)Yahoo(dot)com #

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Gaetano Mendola 2002-03-13 16:58:19 Re: subquery involving 'now'
Previous Message Stephan Szabo 2002-03-13 16:04:47 Re: subquery involving 'now'