Re: problems with toast.* reloptions

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Sami Imseih <samimseih(at)gmail(dot)com>
Cc: Greg Burd <greg(at)burd(dot)me>, solai v <solai(dot)cdac(at)gmail(dot)com>, Nikita Malakhov <hukutoc(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: problems with toast.* reloptions
Date: 2026-08-12 21:54:04
Message-ID: anzrfLbr_j4Ep52a@nathan
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 12, 2026 at 01:33:20PM -0500, Sami Imseih wrote:
> 1/ 0007 adds merge_toast_reloptions(), and for each option it calls
> find_reloption() to get the type and default. find_reloption() scans the
> entire relOpts[]. The options don't change, so it's just repeating the
> same work every time, which also includes strcmp to match the options by
> name.
>
> find_reloption() already runs initialize_reloptions(), so could
> initialize_reloptions() also build a small table of the options a toast
> table inherits from its main table. merge_toast_reloptions() then just
> iterates that table and no longer needs to call find_reloption() in the
> scan.
>
> This would help most when pg_stat_autovacuum_scores calls
> merge_toast_reloptions() for every toast table in its list, which occurs
> in 0008.

I considered this, but AFAICT that extra work actually pales in comparison
to the sequential scan of pg_class.

> 2/ There are three spots that repeat the work for a toast table,
> extractRelOptions() followed by a table_toast_map lookup and a
> merge_toast_reloptions(). For example, when do_autovacuum() performs the
> pass on the toast tables:
>
> [...]
>
> as well as table_recheck_autovac() and pg_stat_get_autovacuum_scores().
>
> The job here is to find the "effective" toast options, and it might be
> worthwhile to turn this into a single helper for clarity.

Done in v10.

--
nathan

Attachment Content-Type Size
v10-0001-Remove-extract_autovac_opts.patch text/plain 11.5 KB
v10-0002-Make-autovacuum_enabled-a-ternary-reloption.patch text/plain 3.6 KB
v10-0003-Add-an-unset-value-for-vacuum_index_cleanup.patch text/plain 3.5 KB
v10-0004-Simplify-autovacuum-s-TOAST-to-main-relation-rel.patch text/plain 3.8 KB
v10-0005-Give-TOAST-storage-parameters-unsettable-default.patch text/plain 5.0 KB
v10-0006-Move-the-StdRdOptions-parse-table-to-file-scope.patch text/plain 7.8 KB
v10-0007-Fix-VACUUM-s-handling-of-TOAST-storage-parameter.patch text/plain 13.0 KB
v10-0008-Fix-autovacuum-s-handling-of-TOAST-storage-param.patch text/plain 13.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zsolt Parragi 2026-08-12 21:56:59 Re: Fix detection of truncated zstd-compressed backups
Previous Message Bernd Reiß 2026-08-12 21:51:36 Re: missing possibility to use alternative translated month names in to_char function