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

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Nikita Malakhov <hukutoc(at)gmail(dot)com>
Cc: Hannu Krosing <hannuk(at)google(dot)com>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Support for 8-byte TOAST values (aka the TOAST infinite loop problem)
Date: 2025-07-07 23:38:41
Message-ID: aGxagUqel7d6A6Xm@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 07, 2025 at 05:33:11PM +0300, Nikita Malakhov wrote:
> [VARTAG_ONDISK_OID] = {
> .toast_pointer_size = TOAST_POINTER_INT8_SIZE, <--- here
> .maximum_chunk_size = TOAST_MAX_CHUNK_SIZE_OID,
> .to_external_data = ondisk_oid_to_external_data,
> .create_external_data = ondisk_oid_create_external_data,
> },
> };
>
> Shouldn't TOAST_POINTER_INT8_SIZE be replaced with TOAST_POINTER_OID_SIZE?

Yes, thanks for pointing this out. This one has lurked in one of the
rebases (not sure how) and it was impacting the threshold calculation
where we consider if an attribute should be compressed or not. I have
taken this occasion to work a bit more on the patch set. The patch
structure is mostly the same, with two tweaks because I was unhappy
with these in the initial patch set:
- The addition of a new callback able to retrieve a new TOAST value,
to ease the diffs in toast_save_datum().
- Reordering of the patch set, with the TOAST external refactoring
done much earlier in the series, now placed in 0003.

The most interesting piece of the patch is still 0003 "Refactor
external TOAST pointer code for better pluggability". On top of that
stands a 0004 patch named "Introduce new callback to get fresh TOAST
values" where I have added value conflict handling for int8. The
split makes reviews easier, hopefully.

Please note that I still need to look at perf profiles and some flame
graphs with the refactoring done in 0003 with the worst case I've
mentioned upthread with detoasting and values stored uncompressed in
the TOAST relation.

I have also pushed this v2 on this branch, so feel free to grab it if
that makes your life easier:
https://github.com/michaelpq/postgres/tree/toast_64bit_v2
--
Michael

Attachment Content-Type Size
v2-0001-Refactor-some-TOAST-value-ID-code-to-use-uint64-i.patch text/x-diff 16.0 KB
v2-0002-Minimize-footprint-of-TOAST_MAX_CHUNK_SIZE-in-hea.patch text/x-diff 2.9 KB
v2-0003-Refactor-external-TOAST-pointer-code-for-better-p.patch text/x-diff 46.3 KB
v2-0004-Introduce-new-callback-to-get-fresh-TOAST-values.patch text/x-diff 5.2 KB
v2-0005-Add-catcache-support-for-INT8OID.patch text/x-diff 1.3 KB
v2-0006-Add-GUC-default_toast_type.patch text/x-diff 5.4 KB
v2-0007-Introduce-global-64-bit-TOAST-ID-counter-in-contr.patch text/x-diff 20.9 KB
v2-0008-Switch-pg_column_toast_chunk_id-return-value-from.patch text/x-diff 2.2 KB
v2-0009-Add-support-for-bigint-TOAST-values.patch text/x-diff 13.7 KB
v2-0010-Add-tests-for-TOAST-relations-with-bigint-as-valu.patch text/x-diff 19.4 KB
v2-0011-Add-support-for-TOAST-table-types-in-pg_dump-and-.patch text/x-diff 21.3 KB
v2-0012-Add-new-vartag_external-for-8-byte-TOAST-values.patch text/x-diff 16.7 KB
v2-0013-amcheck-Add-test-cases-for-8-byte-TOAST-values.patch text/x-diff 3.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2025-07-07 23:39:59 Re: What is a typical precision of gettimeofday()?
Previous Message Andres Freund 2025-07-07 23:25:35 Re: Adding basic NUMA awareness - Preliminary feedback and outline for an extensible approach