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 1uXrRa-00FWLl-GU for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Jul 2025 01:11:54 +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 1uXrRX-002tGq-9s for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Jul 2025 01:11:51 +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.94.2) (envelope-from ) id 1uXrRW-002tGY-Hk for pgsql-hackers@lists.postgresql.org; Sat, 05 Jul 2025 01:11:51 +0000 Received: from fout-b1-smtp.messagingengine.com ([202.12.124.144]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1uXrRU-005dPp-2s for pgsql-hackers@lists.postgresql.org; Sat, 05 Jul 2025 01:11:50 +0000 Received: from phl-compute-01.internal (phl-compute-01.phl.internal [10.202.2.41]) by mailfout.stl.internal (Postfix) with ESMTP id 150C21D000F6; Fri, 4 Jul 2025 21:11:47 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Fri, 04 Jul 2025 21:11:47 -0400 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=fm2; t=1751677906; x=1751764306; bh=8ZNqzCmkPI wnPfRVT9Lp8wkZ/MzZLtZURLAwCjxPGb8=; b=F3RvaepaBe63BALeJcbFmgQOwt pSrBSgpDlSZC0AYkbXGATM5ZIAqZGTMf0Hd2u5S4Z6QHHkfwE4+8f7w7Ln2J9nZX C+OVkAmNHRxWPfdLGDqD9PbqqtFjkf/RpJs6EYCrqUtF2fORrzubUVl/aRD6zvOo GJPkVO++XZ83SPb5EMKjaKthDZw8q8GmPG6mWC+O9UfIrvOYk3AhZWtCvZGLm0aX nV3paYJiwusZM7NIsaBqxHRld+/MKrXMYLXojQ8qRUDx3d7efsdTM+JB6/1V+eIu lpQKa/1RlxHvtDCnzczk5OnadXAgi06fP7l4o10lwBtNi8iw+uIsu0invjdg== 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=fm2; t= 1751677906; x=1751764306; bh=8ZNqzCmkPIwnPfRVT9Lp8wkZ/MzZLtZURLA wCjxPGb8=; b=nZZmdeGnjL7DFYBr5SsuyD0YU1N3jNF4s6nByEOSmGKD7rQXRWF fKU+4vpS1HV1EHkJQXVPge8CgSTGC1VW3Z7YMhjZ96vsTPCctGaUbpLSQ7kwtBl7 4+veKuRxJik7LrpuQXrvtdNKjEt8MNrhqACuJiEx2sTDeV4WInN+FBDLL5ijbTvu 6kfiOcWLXMlZs7eSZbvfR+/7pAhInUa6x543t0sfhKcInN1XO2aciSEfjZAdp0YH WCedWQmbTMnGdg/43B9jvwUtdNhhaiu9oEU4kTHDYHHJCLRmWvzoq6XjTdrpmiP2 CUebE5wUxSg5REEGt23Fjl9/7OT6U1HYZqg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddvgeeikecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdefhedmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeejjedtleelgeegleffudfhjedtuedv keektefhhfeuvddvueduueegfeduvedtieenucffohhmrghinhepghhithhhuhgsrdgtoh hmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhi tghhrggvlhesphgrqhhuihgvrhdrgiihiidpnhgspghrtghpthhtohepfedpmhhouggvpe hsmhhtphhouhhtpdhrtghpthhtohephhhukhhuthhotgesghhmrghilhdrtghomhdprhgt phhtthhopehhrghnnhhukhesghhoohhglhgvrdgtohhmpdhrtghpthhtohepphhgshhqlh dqhhgrtghkvghrsheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 4 Jul 2025 21:11:45 -0400 (EDT) Date: Sat, 5 Jul 2025 10:11:32 +0900 From: Michael Paquier To: Nikita Malakhov Cc: Hannu Krosing , Postgres hackers Subject: Re: Support for 8-byte TOAST values (aka the TOAST infinite loop problem) Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="goDe/9YiYu8rYpdA" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --goDe/9YiYu8rYpdA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Jul 04, 2025 at 02:38:34PM +0300, Nikita Malakhov wrote: > Hannu, we'd already made an attempt to extract the TOAST functionality as > API and make it extensible and usable by other AMs in [1], the patch > set was met calmly but we still have some hopes on it. Yeah, it's one of these I have studied, and just found that overcomplicated, preventing us from moving on with a simpler proposal, because I care about two things first: - More compression methods, with more meta-data, but let's just add more vartag_external for that once/if they're really required. - Enlarge optionally to 8-byte values. So I really want to stress about these two points, nothing else for now, echoing from the feedback from 2022 and the fact that all proposals done after that lacked a simple approach. IMO, we would live fine enough, *if* being able to plug in a pluggable TOAST engine makes sense, if we just limit ourselves with an external interface. We could allow backends to load their own vartag_external with their own set of callbacks like the ones I am proposing here, so as we can translate from/to a Datum in heap (or a different table AM) to an external source, with the backend able to understand what this external source should be. The key is to define a structure good enough for the backend (toast_external_data in the patch). So to answer your and Hannu's question: I had the case of different table AMs in mind with an interface able to plug into it, yes. And yes, I have designed the patch set with this in scope. Now there's also a data type component to that, so that's assuming that a table AM would want to rely on a varlena to store this data externally, somewhere else that may not be exactly TOAST, still we want an OID and a value to be able to retrieve this external value, and we want to store this external OID and this value (+extra like a compression method and sizes) in a Datum of the main relation file. FYI, the patch set posted on this thread is not the latest one. I have a v2, posted on this branch, where I have reordered things: https://github.com/michaelpq/postgres/tree/toast_64bit_v2 The refactoring to the new toast_external_data with its callbacks is done first, and the new vartag_external with 8-byte value support is added on top of that. There were still two things I wanted to do, and could not get down to it because I've spent my last week or so working on other's stuff so I lacked room: - Evaluate the cost of the transfer layer to toast_external_data. The worst case I was planning to work with is a non-compressed data stored in TOAST, then check profiles with the the detoasting path by grabbing slices of the data with pgbench and a read-only query. The write/insert path is not going to matter, the detoast is. The reordering is actually for this reason: I want to see the effect of the new interface first, and this needs to happen before we even consider the option of adding 8-byte values. - Add a callback for the value ID assignment. I was hesitating to add that when I first backed on the patch but I think that's the correct design moving forward, with an extra logic to be able to check if an 8-byte value is already in use in a relation, as we do for OID assignment, but applied to the Toast generator added to the patch. The backend should decide if a new value is required, we should not decide the rewrite cases in the callback. There is a second branch that I use for development, force-pushing to it periodically, as well: https://github.com/michaelpq/postgres/tree/toast_64bit That's much dirtier, always WIP, just one of my playgrounds. -- Michael --goDe/9YiYu8rYpdA Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmhoe8QACgkQnvQgOdby QH35KRAAonb3ygwc8HVwP7GoCitW+znrRdHKr9/jU1jr1w9LRnhJPGYbnxuc2vM1 7lyLKuJ4s1ee/Y7dz0cyYcO350G6Exs/QEKX8g1sbQmW8L4t3/JiVlYNEn07PwLN 9EUFFwWX0Il49QG84qwnwbFpVSwPjVVypq8QywR9WgRO8mzJflrwihgk+CqNBp8c UKxID2pB1NL+8OLbK4zkgRYLSOiQMHye/2EC24w4f5cKX2rUc0BVoJQxbVbe2r29 eep7P/RJX5tLBD5U2H9JQ7KeqtcVEyKQReXT8Ibwmzna3SM4sgDhPREwGqCEn/02 WuAcNhNVLoA01yvMB8TNBjG02GB9NgXBRUYJ1ioohUm6Fr5CCAKYjnE+Uk9btEjB /ZArPaXQbvGGIJH1toReqrbGspcYQOdFV9Jh8Hl2NUgOzMv6sNEonQeewqQXdoU+ y/42RiBMg7TRGBrxRHOlZJmBNG+pUc9fnDEuG4R6h/UEVrGtYfTpImTvenZFqUu7 cWmuY/NQznyvthPncejAiqNuu1r5AAn7hJAuDUyRy2hoZ7S//IWE7MUvO8IMBwl6 9IMY1HmI8LmLeYS/IHhRyhAI4cY6BxbefmA42fE792xqKcDQjdvjMEIk1Ntsq5y/ l7uY0sp+2jSi64GP1yLJEQwa55Ys4LmpqfqJY4Rl4Pe+0nQfxzk= =xhRu -----END PGP SIGNATURE----- --goDe/9YiYu8rYpdA--