X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 470C9D1BAA5 for ; Mon, 5 Apr 2004 17:49:59 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 80197-07 for ; Mon, 5 Apr 2004 14:50:26 -0300 (ADT) Received: from joeconway.com (66-146-172-82.skyriver.net [66.146.172.82]) by svr1.postgresql.org (Postfix) with ESMTP id 1B5BFD1BABD for ; Mon, 5 Apr 2004 14:49:55 -0300 (ADT) Received: from [206.19.64.3] (account jconway HELO joeconway.com) by joeconway.com (CommuniGate Pro SMTP 4.1.8) with ESMTP-TLS id 1259946; Mon, 05 Apr 2004 10:45:08 -0700 Message-ID: <40719C31.5030505@joeconway.com> Date: Mon, 05 Apr 2004 10:49:37 -0700 From: Joe Conway User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jeff Cc: pgsql-performance@postgresql.org Subject: Re: SETOF performance References: <49B1B198-871E-11D8-B8C1-000393D1F76E@torgo.978.org> In-Reply-To: <49B1B198-871E-11D8-B8C1-000393D1F76E@torgo.978.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/43 X-Sequence-Number: 6343 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