Re: Avoid detoast overhead when possible

From: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
To: zhihuifan1213(at)163(dot)com
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Avoid detoast overhead when possible
Date: 2023-12-04 12:10:36
Message-ID: CAEze2Wj2TFZdddFe5dw6Wgudan3__gBHeTuHnZg9-Kv6tJ_z4g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 4 Dec 2023 at 07:56, <zhihuifan1213(at)163(dot)com> wrote:
> 'SELECT f1(toast_col) FROM t;' will apply this code path, but nothing
> gain and nothing lost. Applying this code path only when the toast
> datum is accessed 1+ times needs some extra run-time effort. I don't
> implement this so far, I'd like to see if I miss some obvious points.
> Any feedback is welcome.

This does add some measurable memory overhead to query execution where
the produced derivative of the large toasted field is small (e.g. 1MB
toast value -> 2x BIGINT), and when the toasted value is deep in the
query tree (e.g. 3 nested loops deep). It would also add overhead when
we write results to disk, such as spilling merge sorts, hash join
spills, or CTE materializations.

Could you find a way to reduce this memory and IO usage when the value
is not going to be used immediately? Using the toast pointer at such
points surely will be cheaper than storing the full value again and
again.

Kind regards,

Matthias van de Meent
Neon (https://neon.tech)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2023-12-04 12:11:34 Re: undetected deadlock in ALTER SUBSCRIPTION ... REFRESH PUBLICATION
Previous Message Tomas Vondra 2023-12-04 12:00:27 Re: undetected deadlock in ALTER SUBSCRIPTION ... REFRESH PUBLICATION