Re: SETOF performance

From: Joe Conway <mail(at)joeconway(dot)com>
To: Jeff <threshar(at)torgo(dot)978(dot)org>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: SETOF performance
Date: 2004-04-05 17:49:37
Message-ID: 40719C31.5030505@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Jeff wrote:
> I think it was on this list - someone posted a message about SETOF
> being slower. Tom replied saying it was because it needed to create an
> on-disk tuplestore.
>
> I was just looking for some clarification - a SETOF function will always
> write the reslting tuples to disk (Not buffering in say a sort_mem sized
> buffer)?

I think at least part of what you're seeing is normal function call
overhead. As far as tuplestores writing to disk, here's what the source
says:

In src/backend/utils/sort/tuplestore.c
8<---------------------------------------
* maxKBytes: how much data to store in memory (any data beyond this
* amount is paged to disk). When in doubt, use work_mem.
*/
Tuplestorestate *
tuplestore_begin_heap(bool randomAccess, bool interXact, int maxKBytes)
8<---------------------------------------

In src/backend/executor/execQual.c:ExecMakeTableFunctionResult():
8<---------------------------------------
tupstore = tuplestore_begin_heap(true, false, work_mem);
8<---------------------------------------

So up to work_mem (sort_mem in 7.4 and earlier) should be stored in memory.

Joe

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Kevin Barnard 2004-04-05 18:04:52 Re: atrocious update performance
Previous Message Rosser Schwarz 2004-04-05 17:05:37 Re: atrocious update performance