From: Michael Fuhr <mike@fuhr.org>
To: RĂ¼diger Herrmann <ruediger.herrmann@gmx.de>
Cc: pgsql-performance@postgresql.org
Subject: Re: refcurosr vs. setof
Date: Mon, 18 Apr 2005 21:10:01 -0600
Message-ID: <20050419031001.GA75716@winnie.fuhr.org> (raw)
In-Reply-To: <d3ugoo$2oq8$1@news.hub.org>
References: <d3ugoo$2oq8$1@news.hub.org>
On Sun, Apr 17, 2005 at 10:05:29PM +0200, RĂ¼diger Herrmann wrote:
>
> I need to write several PL/pgSQL functions all returning a "result set" wich
> can be obtained by a single SELECT statement.
> For now the functions are called by a Java application.
> Both REFCURSOR and SETOF serve my purpose, but I was wondering if there is a
> perfonance difference between the two. The result set can become quite
> large.
Here's an excerpt from the "Control Structures" section of the
PL/pgSQL documentation:
The current implementation of RETURN NEXT for PL/pgSQL stores
the entire result set before returning from the function, as
discussed above. That means that if a PL/pgSQL function produces
a very large result set, performance may be poor: data will be
written to disk to avoid memory exhaustion, but the function
itself will not return until the entire result set has been
generated....Currently, the point at which data begins being
written to disk is controlled by the work_mem configuration
variable.
You might want to test both ways in typical and worst-case scenarios
and see how each performs.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
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-performance@postgresql.org
Cc: mike@fuhr.org, ruediger.herrmann@gmx.de
Subject: Re: refcurosr vs. setof
In-Reply-To: <20050419031001.GA75716@winnie.fuhr.org>
* 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