From: Jan Wieck <janwieck@yahoo.com>
To: Bo Lorentsen <bl@netgroup.dk>
Cc: pgsql-sql <pgsql-sql@postgresql.org>
Subject: Re: Large data sets and FOR LOOP's
Date: Wed, 13 Mar 2002 11:29:26 -0500 (EST)
Message-ID: <200203131629.g2DGTRp31887@saturn.janwieck.net> (raw)
In-Reply-To: <1016012241.1094.90.camel@netgroup>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: janwieck@yahoo.com, bl@netgroup.dk
Subject: Re: Large data sets and FOR LOOP's
In-Reply-To: <200203131629.g2DGTRp31887@saturn.janwieck.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox