Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1umxjm-000Uc1-Iq for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Aug 2025 16:57:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1umxjl-0014jI-Su for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Aug 2025 16:57:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1umxjl-0014jA-JV for pgsql-hackers@lists.postgresql.org; Fri, 15 Aug 2025 16:57:06 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1umxjk-00021E-09 for pgsql-hackers@lists.postgresql.org; Fri, 15 Aug 2025 16:57:05 +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 57FGv27N617667; Fri, 15 Aug 2025 12:57:02 -0400 From: Tom Lane To: jian he cc: pgsql-hackers@lists.postgresql.org Subject: Re: Making jsonb_agg() faster In-reply-to: References: <1060917.1753202222@sss.pgh.pa.us> Comments: In-reply-to jian he message dated "Thu, 14 Aug 2025 16:59:56 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <617665.1755277022.1@sss.pgh.pa.us> Date: Fri, 15 Aug 2025 12:57:02 -0400 Message-ID: <617666.1755277022@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk jian he writes: > outcontext will always be NULL in 0001. > that means copyScalarSubstructure is never really called. > it also means that JsonbInState->MemoryContext was always as NULL in 00001 > maybe we don't need JsonbInState->MemoryContext in 0001 > So 0001 refactoring change would be less invasive. I think you're missing the point: per the commit message for 0001, The real reason for doing it is to provide a mechanism whereby pushJsonbValue() can be told to construct the JsonbValue tree in a context that is not CurrentMemoryContext. That happens when a non-null "outcontext" is specified in the JsonbInState. No callers exercise that option in this patch, but the next patch in the series will make use of it. If we didn't add the outcontext option in this step, we'd just have to do so in the next one. regards, tom lane