On Sun, Oct 4, 2026 at 8:38 AM Dongpo Liu <[email protected]> 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
v2-0001-doc-Note-that-plan-advice-does-not-affect-cached-.patch
Description: Binary data
