Re: pg_*_advice: tsv load failure, etc. - Mailing list pgsql-hackers

From Robert Haas
Subject Re: pg_*_advice: tsv load failure, etc.
Date
Msg-id CA+TgmoZMJFPY=JmebQsqp2wkHaFnHgM5UDEEugKrePJb8n_ucw@mail.gmail.com
Whole thread
In response to Re: pg_*_advice: tsv load failure, etc.  (Dongpo Liu <poe.liu@pm.me>)
Responses Re: pg_*_advice: tsv load failure, etc.
List pgsql-hackers
On Sun, Oct 4, 2026 at 8:38 AM Dongpo Liu <poe.liu@pm.me> wrote:
> The patch adds a paragraph to the Limitations section of pg_plan_advice
> and a short pointer in pg_stash_advice.  It says that advice is consulted
> only at plan time, mentions DISCARD PLANS for the current session, and
> refers to PREPARE for when other sessions re-plan.

I think it's a good idea to add something to the documentation about
this issue, but I'm not entirely convinced by this wording. In
particular:

"The new advice is used the next time the statement is planned" => To
me, this sort of makes it seem like you could just leave
pg_plan_advice.advice set the whole time, which is not a realistic
approach. Or else as though it will remember the advice that it didn't
use this time and use it next time re-planning actually happens, which
it won't.

"Plans cached by other sessions are re-planned only when something
else invalidates them; see <xref linkend="sql-prepare"/>." => I feel
like there are two ways to read this. One possible reading is that
replanning doesn't happen on every use of the cache, but only when
there is a reason to replan. That's just the definition of a cache.
The other possible reading is that invalidation is the only thing that
can trigger replanning, which isn't true;
for example, the other session could have a custom plan, or it could
execute DISCARD PLANS itself.

Here's my rewrite. (Also, I committed my latest round of bug-fix patches.)

--
Robert Haas
Databricks

Attachment

pgsql-hackers by date:

Previous
From: Kacper Kuras
Date:
Subject: Re: Proposal: SELECT * EXCLUDE (...) command
Next
From: Robert Haas
Date:
Subject: Re: Bypassing cursors in postgres_fdw to enable parallel plans