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.96) (envelope-from ) id 1vRxWZ-00C7Lo-0e for pgsql-hackers@arkaria.postgresql.org; Sat, 06 Dec 2025 19:00:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vRxWW-00CHYu-1o for pgsql-hackers@arkaria.postgresql.org; Sat, 06 Dec 2025 19:00:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vRxWW-00CHYm-0n for pgsql-hackers@lists.postgresql.org; Sat, 06 Dec 2025 19:00:52 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vRxWT-003U29-2K for pgsql-hackers@lists.postgresql.org; Sat, 06 Dec 2025 19:00:51 +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 5B6J0mw02329960; Sat, 6 Dec 2025 14:00:48 -0500 From: Tom Lane To: Chao Li cc: jian he , pgsql-hackers@lists.postgresql.org Subject: Re: Making jsonb_agg() faster In-reply-to: References: <1060917.1753202222@sss.pgh.pa.us> <617666.1755277022@sss.pgh.pa.us> <654628.1755297629@sss.pgh.pa.us> <2129790.1755889894@sss.pgh.pa.us> <68A1061C-81A5-46AA-AFA9-48294908254C@gmail.com> <2613D418-67E0-4DD8-BDA6-AB1BB04DB1A2@gmail.com> <2466173.1756498180@sss.pgh.pa.us> <163563.1762117009@sss.pgh.pa.us> <354608.1762195230@sss.pgh.pa.us> <2052300.1763664997@sss.pgh.pa.us> <1985954.1764976473@sss.pgh.pa.us> Comments: In-reply-to Chao Li message dated "Sat, 06 Dec 2025 09:35:51 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2329958.1765047648.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 06 Dec 2025 14:00:48 -0500 Message-ID: <2329959.1765047648@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Chao Li writes: > On Dec 6, 2025, at 07:14, Tom Lane wrote: >> I'd kind of like to get this pushed soon, because it keeps getting >> sideswiped ... does anyone have further comments? > My only nit commit is still about the hard-coded 12: > I commented this before and you explained. But I still think it may dese= rve a comment for why 12 is here, otherwise future reader may also get the= same confusion as when I first time read this code. I've been thinking of that as an independent issue. But what I'm inclined to do is add a symbol to date.h, say like diff --git a/src/include/utils/date.h b/src/include/utils/date.h index 7316ac0ff17..2aca785b65d 100644 --- a/src/include/utils/date.h +++ b/src/include/utils/date.h @@ -30,6 +30,14 @@ typedef struct int32 zone; /* numeric time zone, in seconds */ } TimeTzADT; = +/* + * sizeof(TimeTzADT) will be 16 on most platforms due to alignment paddin= g. + * However, timetz's typlen is 12 according to pg_type. In most places + * we can get away with using sizeof(TimeTzADT), but where it's important + * to match the declared typlen, use TIMETZ_TYPLEN. + */ +#define TIMETZ_TYPLEN 12 + /* * Infinity and minus infinity must be the max and min values of DateADT. */ and then use that. (I poked around in other code using TimeTzADT, and could not find any other places where we have hard-wired "12", which seems a bit surprising perhaps. But pretty much all the references to sizeof(TimeTzADT) are in palloc's, where it's fine.) regards, tom lane