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 1wKXY9-0016mu-2K for pgsql-hackers@arkaria.postgresql.org; Wed, 06 May 2026 08:24:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wKXY8-00FinB-19 for pgsql-hackers@arkaria.postgresql.org; Wed, 06 May 2026 08:24:08 +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.96) (envelope-from ) id 1wKXY7-00Fin3-37 for pgsql-hackers@lists.postgresql.org; Wed, 06 May 2026 08:24:08 +0000 Received: from smtp.outgoing.loopia.se ([93.188.3.37]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wKXY5-00000000myS-2pi7 for pgsql-hackers@lists.postgresql.org; Wed, 06 May 2026 08:24:07 +0000 Received: from s807.loopia.se (localhost [127.0.0.1]) by s807.loopia.se (Postfix) with ESMTP id 609C65C9881 for ; Wed, 06 May 2026 10:24:04 +0200 (CEST) Received: from s981.loopia.se (unknown [172.22.191.6]) by s807.loopia.se (Postfix) with ESMTP id 4C3005C87B3; Wed, 06 May 2026 10:24:04 +0200 (CEST) Received: from localhost (unknown [172.22.191.5]) by s981.loopia.se (Postfix) with ESMTP id 483EC22B173B; Wed, 06 May 2026 10:24:04 +0200 (CEST) X-Virus-Scanned: amavis at amavis.loopia.se X-Spam-Flag: NO X-Spam-Score: -1.2 X-Spam-Level: X-Spam-Status: No, score=-1.2 tagged_above=-999 required=6.2 tests=[ALL_TRUSTED=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1] autolearn=disabled Authentication-Results: s471.loopia.se (amavis); dkim=pass (2048-bit key) header.d=yesql.se Received: from s980.loopia.se ([172.22.191.6]) by localhost (s471.loopia.se [172.22.190.35]) (amavis, port 10024) with UTF8LMTP id 3_ctba_QsPFa; Wed, 6 May 2026 10:24:03 +0200 (CEST) X-Loopia-Auth: user X-Loopia-User: daniel@yesql.se X-Loopia-Originating-IP: 89.255.232.236 Received: from smtpclient.apple (customer-89-255-232-236.stosn.net [89.255.232.236]) (Authenticated sender: daniel@yesql.se) by s980.loopia.se (Postfix) with ESMTPSA id A6EC32201659; Wed, 06 May 2026 10:24:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yesql.se; s=loopiadkim1707475645; t=1778055843; bh=9g9YkjmxpfmUIEDZ0rgyXwGxSVCD+lylFT8KKO/+2eU=; h=Subject:From:In-Reply-To:Date:Cc:References:To; b=J1ZVbtzqSE7f8v7g4An0d06gXyxPb13Tr1zYTyWGSl82tzMhnHtjAzRomi4oiYqTL MyE3FsrqOfANnuR9porEHHK9DmC4QwJtH4rMhNqKaj+9Jo8WIPZtH2+2ej0dn4P6HB XQxfCznIID+thqJHzB3UrhpiWeKaxF0BhpRMtGrTXlINPsjdi0IbWf0ih9jYUkfl40 jb1QJ96rX/2xqZA2oWOMhyEd+RDcjdjsp0lHvW1e0P3oN4QhXFhYfbT9jrrB2ci1Ko 9G/Y82dkogHM5WX+dP/m7j2rdiBd5wJI/tJ9vra+u6JgZfKHowDwA56eq+ybvDmFVK c+snQ08TvbaKQ== Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51.11.2\)) Subject: Re: COPY JSON: use trailing commas in FORCE_ARRAY output From: Daniel Gustafsson In-Reply-To: Date: Wed, 6 May 2026 10:23:53 +0200 Cc: PostgreSQL Hackers Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Chao Li X-Mailer: Apple Mail (2.3776.700.51.11.2) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 6 May 2026, at 08:40, Chao Li wrote: > I was surprised by the comma placement. It is valid JSON, but it looks = quite uncommon. It might look uncommon, but for very wide lines it's IMHO preferrable to = not have to scroll all the way to the end of the line to know that the line = is part of an array. > For comparison, the existing json_agg() places commas at the end of = the line: That's true, but json_agg() and COPY TO in ndjson format have different = use cases. > ..it should not have any performance impact. It does add branches though, and in one branch use a non-inlined = function where previously it would unconditionally use an inline function. ISTM it = would still be valuable to do performance testing given that COPY is commonly = used in performance sensitive settings. -- Daniel Gustafsson