Unix Technical Forum

refcurosr vs. setof

This is a discussion on refcurosr vs. setof within the Pgsql Performance forums, part of the PostgreSQL category; --> Hello, I need to write several PL/pgSQL functions all returning a "result set" wich can be obtained by a ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Performance

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-18-2008, 11:32 AM
Rüdiger Herrmann
 
Posts: n/a
Default refcurosr vs. setof

Hello,

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.

I hope not to ask this question the 1001 time, though I couldn't find
anything on the net.. Any hints are welcome.

Regards
Rüdiger


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-18-2008, 11:33 AM
Michael Fuhr
 
Posts: n/a
Default Re: refcurosr vs. setof

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/

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:13 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com