Re: Potential "AIO / io workers" inter-worker locking issue in PG18?

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Marco Boeringa <marco(at)boeringa(dot)demon(dot)nl>
Cc: Andres Freund <andres(at)anarazel(dot)de>, pgsql-bugs(at)lists(dot)postgresql(dot)org, Thom Brown <thom(at)linux(dot)com>
Subject: Re: Potential "AIO / io workers" inter-worker locking issue in PG18?
Date: 2025-10-20 21:06:51
Message-ID: CAApHDvr4o1QjDOD0avSB-3=943E7uJJ5EmRmJyGsD5m5aSA+3Q@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Tue, 21 Oct 2025 at 09:02, Marco Boeringa <marco(at)boeringa(dot)demon(dot)nl> wrote:
> https://stackoverflow.com/questions/20718499/does-postgresql-cache-function-calls#comment31095072_20718499
>
> And in relation to that post and thread, and the suggestion of WITH /
> CTE clause, would that be a suitable substitute and avoid the recalling
> of the functions? I assume with the MATERIALIZED option, it should, that
> is what the MATERIALIZED option is for, isn't it?

That article states "this function is invoked multiple times with the
same parameter", so doesn't sound very applicable for your case since
your function parameter changes with every row.

I don't see how WITH MATERIALIZED could help you here as that's not a
parameterized cache. I suppose we could adjust the planner to consider
something similar to Memoize for caching results for expensive stable
functions. We'd have to put a lot of trust into n_distinct estimates
and the function(s) COST setting, however.

I suspect you're trying to optimise for something that's not an actual problem.

David

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Marco Boeringa 2025-10-20 21:57:54 Re: Potential "AIO / io workers" inter-worker locking issue in PG18?
Previous Message Marco Boeringa 2025-10-20 20:02:35 Re: Potential "AIO / io workers" inter-worker locking issue in PG18?