Why does "toast_tuple_target" allow values below TOAST_TUPLE_TARGET?

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Why does "toast_tuple_target" allow values below TOAST_TUPLE_TARGET?
Date: 2019-04-05 05:09:35
Message-ID: CAKJS1f9vrJ55oYe7un+rakTzwaGh3my5MA0RBfyNngAXu7eVeQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Or rather, why does the reloption allow values below the compile-time constant?

It looks like we currently allow values as low as 128. The problem
there is that heap_update() and heap_prepare_insert() both only bother
calling toast_insert_or_update() when the tuple's length is above
TOAST_TUPLE_TARGET, so it seems to have no effect when set to a lower
value.

I don't think we can change heap_update() and heap_prepare_insert() to
do "tup->t_len > RelationGetToastTupleTarget(relation,
TOAST_TUPLE_TARGET)" instead as such a table might not even have a
TOAST relation since needs_toast_table() will return false if it
thinks the tuple length can't be above TOAST_TUPLE_TARGET.

It does not seem possible to add/remote the toast table when the
reloption is changed either as we're only obtaining a
ShareUpdateExclusiveLock to set it. We'd likely need to upgrade that
to an AccessExclusiveLock to do that.

I understand from reading [1] that Simon was mostly interested in
keeping values inline for longer. I saw no mention of moving them out
of line sooner.

[1] https://postgr.es/m/CANP8+jKsVmw6CX6YP9z7zqkTzcKV1+Uzr3XjKcZW=2Ya00OyQQ@mail.gmail.com

--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey Borodin 2019-04-05 05:14:31 Re: [GSoC] application ideas
Previous Message Masahiko Sawada 2019-04-05 04:59:36 Re: [HACKERS] Block level parallel vacuum