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 1vW7c5-00DY76-2N for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Dec 2025 06:35:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vW7c4-000V8W-27 for pgsql-hackers@arkaria.postgresql.org; Thu, 18 Dec 2025 06:35:49 +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 1vW7c3-000V8N-2X for pgsql-hackers@lists.postgresql.org; Thu, 18 Dec 2025 06:35:49 +0000 Received: from fout-b6-smtp.messagingengine.com ([202.12.124.149]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vW7c1-001MbN-2B for pgsql-hackers@lists.postgresql.org; Thu, 18 Dec 2025 06:35:48 +0000 Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfout.stl.internal (Postfix) with ESMTP id 5E24D1D000AF; Thu, 18 Dec 2025 01:35:43 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Thu, 18 Dec 2025 01:35:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1766039743; x=1766126143; bh=lb1gXOxLil WCGkVooYCGBGpQ7XQ/EiKQNDkO4oPfVxk=; b=Y2EEIZ+CxQmDCm7a4QA7vPXipb y+uBVCseVDPfWplfeLMBtwjKcZtIV3WsVkeolr3fdcVZY5V9IaYKLTe4m1VYRaDP N93GsM7ecQ8NiZS2m5yEqGnfBwICkJDejDwLh0CpkhbIs8+Re09SyImcP8rOY4xx 3E5k1inMazuvJ330fhL4e/9X/Pk+zDkVJO63r0FIGCWI00Y4Y+E7DvXwdCtnCihi 6A403dvMKG5dPAZfmIDwTAx072bi8nJkje/VtgMiEPmez++ysRersBD5rLo1CxFF fmCb9J7jvMnQmHoLuwVcss1ewfTJ6t4/e81JoB5qNYHic4UyDhTbgmNJr6LQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1766039743; x=1766126143; bh=lb1gXOxLilWCGkVooYCGBGpQ7XQ/EiKQNDk O4oPfVxk=; b=BrG6d78j1eQXpCZ+HXXmFi9X0FgR6UbbjHqxxysvULkQ7qKsUP0 z+nLIeOQE/fm8iCTOM0yziQcRQ2kmrTbZi3mYUKjtj3olIMSzOmeQuqQll2971sc YnRMZGzMD5H44QTcfH3rL0Sy+xE9FmsLc66oRbotm1+JmAIwvO0OeW1efiAl8Xf3 yYr7itfs/MeEeJoE9MOFsoVeTMCFV+1xjDBHXjYE4WgAWLaFPv4U78z4q++YWM3E opN/4ymQK7nQmnrpZ1FzZaEDjvn7KP6Gf5pRYWIyDGLlrZwNobNljE96AeHp2Uk2 IiWrjGcZbfE+mzc2K3DTIvF84UWqi7KDyfQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdeggeejudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeggeff hfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhn sggprhgtphhtthhopeefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehpvghtvg hrsegvihhsvghnthhrrghuthdrohhrghdprhgtphhtthhopeguhhgrrhhinhhshhgrhhel heesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlih hsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 18 Dec 2025 01:35:40 -0500 (EST) Date: Thu, 18 Dec 2025 15:35:07 +0900 From: Michael Paquier To: Peter Eisentraut Cc: Dharin Shah , pgsql-hackers@lists.postgresql.org Subject: Re: Fwd: [PATCH] Add zstd compression for TOAST using extended header format Message-ID: References: <4c70b0f6-5aba-464c-b145-464a620c1222@eisentraut.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="poFDZ5OKkNBF+pHp" Content-Disposition: inline In-Reply-To: <4c70b0f6-5aba-464c-b145-464a620c1222@eisentraut.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --poFDZ5OKkNBF+pHp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Dec 17, 2025 at 04:11:38PM +0100, Peter Eisentraut wrote: > On 16.12.25 11:51, Dharin Shah wrote: > > - Zstd only applies to external TOAST, not inline compression. The 2-bit > > limit in va_tcinfo stays as-is for inline data, where pglz/lz4 work fine > > anyway. Zstd's wins show up on larger values. >=20 > This is a very complicated patch. To motivate it, you should show some > detailed performance measurements that show these wins. Yes, this is expected for any patch posted. Zstd is an improved version of lz4, acting as a sort of industry standard these days, and any byte sequences I have looked at points that zstd leads kind of always to a better compression ratio for less or equivalent CPU cost compared to LZ4. Not saying that numbers are not required, they are. But I strongly suspect numbers among these lines. FWIW, it's not a complicated patch, it is a large mechanical patch that enforces a bunch of TOAST code paths to do what it wants. If we are going to do something about that and agree on something, I think that we should just use a new vartag_external for this matter (spoiler: I think we should use a new vartag_external value), but keep the toast structure at 16 bytes all the time, leaving alone the extra bit in the existing varatt_external structure so as there is no impact for heap relations if zstd is used, as long as the TOAST value is 32 bits. The patch introduces a new vartag_external with VARTAG_ONDISK_EXTENDED, so while it leads to a better compatibility, it also means that all zstd entries have to pay an extra amount of space in the main relation as an effect of a different default_toast_compression. The difficulty is not in the implementation, it would be on agreeing on what folks would be OK with in terms if vartag and varatt structures, and that's one of the oldest areas of the PG code, that has complications and assumptions of its own. The test implementation looks wrong to me. Why is there any need for an extra test module test_toast_ext? You could just reuse the same structure as compression_lz4.sql, but adapted to zstd. That's why a split with compression.sql has been done in 74a3fc36f314, FYI. You should also aim at splitting the patch more to make it easier to review: one of the sticky point of this area of the code is to untie completely DefaultCompressionId, its GUC and the TOAST code. The GUC default_toast_compression accepts by design only 4 values. This needs to go further, and should be refactored as a piece of its own. And also, I would prefer if the 32-bit value issue is tackled first, but that's a digression here, for a different thread. :)=20 -- Michael --poFDZ5OKkNBF+pHp Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmlDoJsACgkQnvQgOdby QH1zdA//S3P5T02bCetbVjjpat0THm29qesi5TgTuwAvufR18XymrUIGHc4EWlEJ mdnk6FDLwb7jSmhOHVRZXqBn2Q2veQH/nJMyrxYQjYJ3e1wR5DWHqilUQQ4h+0hb nUqW1ZfPV0WzaV7lefhK6bUG0+HCs3i0yhjMVXEVgMZMFxt87MfN6qQ+F1SqHTef sZsBVsq9U9u74Me2WBWG4sEGgkWDWXOcVBUs9kAaAUV/5JhBPz50Kv5rm35Ne6hT ycvYs//RqhCZ9zIXqAQB0UCfUGb0Zd5ahndNNW6ewcP0liEfWXRgYxNPAJTBC75r b/4s/jZSw6Z3vBc/G0WNtMaXy4DO0/0qBOEwUsENoX+Fr0RLMGhub3To5WH3clXK Q0MUbrRTpheRo4/oVXC/oIzjAXqbKXsfB9BZCEQW2dQmK1qpBPA1D83Pgnsu8w7W bY6/zf/l2cyAwl1OkGxOZXphy2HE0lTnwfcqyfha6PlLLuBhlah4UMii3Wk7IWsV f/1Z0N0iZLpj3pfJpWYoFfR90F4UFYc8/PxRq0W9BQ2HJ2EtyyunHM8lqO3loVdv LbddC73mOLjB8l9yC8f1uuD8jeyTKFy3Td0YYw81mLqgCDuTzTEN/1dbrYuLs+p3 IOsVjtjbr/LrHmoRussAvyfcm3hGPR/zzYL+GvEhUUbcrDe06qo= =b7Z3 -----END PGP SIGNATURE----- --poFDZ5OKkNBF+pHp--