Re: problems with toast.* reloptions

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Nathan Bossart <nathandbossart(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 18:33:20
Message-ID: CAA5RZ0ucMmKhCmJM-yiTuzt-cCbxs6AC9fKEsDC1QkPTbRsdYw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> After sleeping on this, I realized that we can simplify things a bit by
> using merge_toast_reloptions() for manual VACUUM, too. I've added a new
> 0007 for that. The autovacuum fix now lives in 0008.

Makes sense to me. A few comments:

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.

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:

```
/*
- * fetch reloptions -- if this toast table does not
have them, try the
- * main rel
+ * fetch reloptions -- merge any unset options from the main rel
*/
relopts = (StdRdOptions *) extractRelOptions(tuple,
pg_class_desc, NULL);
if (relopts)
free_relopts = true;
- else
- {
- av_relation *hentry;
- bool found;
-
- hentry = hash_search(table_toast_map, &relid,
HASH_FIND, &found);
- if (found)
- relopts = &hentry->ar_reloptions;
- }
+ hentry = hash_search(table_toast_map, &relid,
HASH_FIND, &found);
+ if (found)
+ relopts = merge_toast_reloptions(relopts,
&hentry->ar_reloptions);
```

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.

--
Sami Imseih
Amazon Web Services (AWS)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-08-12 19:07:57 Re: Handle MAXSTRLEN consistently
Previous Message Fujii Masao 2026-08-12 18:03:05 Re: Fix small psql slash option leaks