Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ofRGI-00060T-IU for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Oct 2022 19:37:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ofRGH-0006ar-1E for pgsql-hackers@arkaria.postgresql.org; Mon, 03 Oct 2022 19:37:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ofRGG-0006VO-NO for pgsql-hackers@lists.postgresql.org; Mon, 03 Oct 2022 19:37:56 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ofRGE-0005O1-I7 for pgsql-hackers@lists.postgresql.org; Mon, 03 Oct 2022 19:37:55 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 293Jbo8G1693075; Mon, 3 Oct 2022 15:37:50 -0400 From: Tom Lane To: David Rowley cc: Andres Freund , Julien Rouhaud , Robert Haas , Yura Sokolov , PostgreSQL Developers Subject: Re: Reducing the chunk header sizes on all memory context types In-reply-to: References: <3021143.1662432194@sss.pgh.pa.us> <20220907130552.sfjri7jublfxyyi4@jrouhaud> <3666758.1662563307@sss.pgh.pa.us> <20220908164409.ptv66iogw2kvnwj5@awork3.anarazel.de> <4098200.1662660636@sss.pgh.pa.us> <20220908221523.c2nsmn7cvsdqvxvn@awork3.anarazel.de> <4159947.1662677609@sss.pgh.pa.us> <555399.1663636988@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Mon, 03 Oct 2022 12:43:58 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1693073.1664825870.1@sss.pgh.pa.us> Date: Mon, 03 Oct 2022 15:37:50 -0400 Message-ID: <1693074.1664825870@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > Andres did mention to me off-list about perhaps adding a boolean field > to FunctionCallInfoBaseData to indicate if the return value can be > assumed to be in CurrentMemoryContext. I feel like that might be > quite a bit of work to go and change all functions to ensure that > that's properly populated. That seems like the right basic answer, but wrong in detail. We have only a tiny number of places that care about this --- aggregates and window functions basically --- and those already have a bunch of special calling conventions. So changing the generic fmgr APIs has side-effects far beyond what's justified. I think what we should look at is extending the aggregate/window function APIs so that such functions can report where they put their output, and then we can nuke MemoryContextContains(), with the code code set up to assume that it has to copy if the called function didn't report anything. The existing FunctionCallInfo.resultinfo mechanism (cf. ReturnSetInfo for SRFs) is probably the right thing to pass the flag through. I can take a look at this once the release dust settles a little. regards, tom lane