pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Conway <mail@joeconway.com>
To: Jeff <threshar@torgo.978.org>
Cc: pgsql-performance@postgresql.org
Subject: Re: SETOF performance
Date: Mon, 05 Apr 2004 10:49:37 -0700
Message-ID: <40719C31.5030505@joeconway.com> (raw)
In-Reply-To: <49B1B198-871E-11D8-B8C1-000393D1F76E@torgo.978.org>
References: <49B1B198-871E-11D8-B8C1-000393D1F76E@torgo.978.org>

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




view thread (2+ messages)

Message-ID: <40719C31.5030505@joeconway.com>
Permalink:  ../40719C31.5030505@joeconway.com/
Also on:    postgresql.org/message-id/40719C31.5030505@joeconway.com

 · 

reply

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: mail@joeconway.com, threshar@torgo.978.org
  Subject: Re: SETOF performance
  In-Reply-To: <40719C31.5030505@joeconway.com>

* 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