From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Rüdiger Herrmann <ruediger(dot)herrmann(at)gmx(dot)de> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: refcurosr vs. setof |
Date: | 2005-04-19 03:10:01 |
Message-ID: | 20050419031001.GA75716@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
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/
From | Date | Subject | |
---|---|---|---|
Next Message | PriceComparison.com | 2005-04-19 05:21:06 | Re: postgresql faster in Linux than FreeBSD? |
Previous Message | Joshua D. Drake | 2005-04-19 02:20:25 | Re: Foreign key slows down copy/insert |