Re: Support for 8-byte TOAST values (aka the TOAST infinite loop problem)

From: Nikita Malakhov <hukutoc(at)gmail(dot)com>
To: Hannu Krosing <hannuk(at)google(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Nikhil Kumar Veldanda <veldanda(dot)nikhilkumar17(at)gmail(dot)com>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Subject: Re: Support for 8-byte TOAST values (aka the TOAST infinite loop problem)
Date: 2025-07-21 11:06:03
Message-ID: CAN-LCVOh9DRWNqoDUx+Q1ZDM_O3VyX6ctRuEX0mzA+_JTkUKvg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!

Michael and Hannu, here's a POC patch with direct TIDs TOAST.
The simplest implementation where we store a chain of TIDs, each
chunk stores the next TID to be fetched. Patch applies on top of
commit 998b0b51d5ea763be081804434f177082ba6772b (origin/toast_64bit_v2)
Author: Michael Paquier <michael(at)paquier(dot)xyz>
Date: Thu Jun 19 13:09:11 2025 +0900

While it is very fast on small data - I see several disadvantages:
- first of all, VACUUM should be revised to work with such tables;
- problematic batch insertion due to necessity to store TID chain.

It is just a POC implementation, so please don't blame me for
questionable decisions.

Any opinions and feedback welcome!

PS: Hannu, just seen your latest message, will check it out now.

On Mon, Jul 21, 2025 at 3:15 AM Hannu Krosing <hannuk(at)google(dot)com> wrote:

> I have been evolving details for Direct TOAST design in
> https://wiki.postgresql.org/wiki/DirectTOAST
>
> The top level goals are
>
> * 8-byte TOAST pointer - just (header:1, tag:1 and TID:6)
> * all other info moved from toast pointer to actual toast record(s),
> so heap rows are smaller and faster.
> * all extra fields are bytea with internal encoding (maybe will create
> full new types for these, or maybe just introspection functions are
> enough)
> the reasons for this are
> - PostgresSQL arrays add 20 byte overhead
> - bytea gives other freedoms in encoding for minimal space usage
>
> No solution yet for va_toastrelid , but hope is
> - to use some kind of mapping and find one or two free bits somewhere
> (tid has one free),
> - or add a 12-byte toast pointer just for this.
> - or to make sure that CLUSTER and VACUUM FULL can be done without
> needing va_toastrelid. I assume it is there for clustering the TOAST
> which will be not possible separately from the main heap with direct
> toast tid pointers anyway.
>
> Please take a look and poke holes in it !
>
>
>

--
Regards,
Nikita Malakhov
Postgres Professional
The Russian Postgres Company
https://postgrespro.ru/

Attachment Content-Type Size
v1-0001-direct-tids-toast.patch application/octet-stream 31.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Nikita Malakhov 2025-07-21 11:20:31 Re: Support for 8-byte TOAST values (aka the TOAST infinite loop problem)
Previous Message shveta malik 2025-07-21 10:52:42 Re: Skipping schema changes in publication