From 640247c6f3e56faa3876c81b8b2a144121a03517 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Fri, 4 Sep 2026 09:13:00 -0400 Subject: [PATCH v3 3/5] pg_plan_advice: Document interaction with GEQO. The general nature of this interaction has been understood (at least by me) since before the original commit, but I failed to explicitly document it. I also left behind an XXX in the README which I intended to remove before commit. Fix those things. Reported-by: Noah Misch --- contrib/pg_plan_advice/README | 2 -- doc/src/sgml/pgplanadvice.sgml | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/contrib/pg_plan_advice/README b/contrib/pg_plan_advice/README index 2ea61e9bc41..2be40f0eba6 100644 --- a/contrib/pg_plan_advice/README +++ b/contrib/pg_plan_advice/README @@ -263,5 +263,3 @@ good idea to incorporate that ability at some future point, as pg_hint_plan does. However, since the primary goal of the initial development work is to be able to induce the planner to recreate a desired plan that worked well in the past, this has not been included in the initial development effort. - -XXX Need to investigate whether and how well supplying advice works with GEQO diff --git a/doc/src/sgml/pgplanadvice.sgml b/doc/src/sgml/pgplanadvice.sgml index b1395ec951e..0116b0d88f7 100644 --- a/doc/src/sgml/pgplanadvice.sgml +++ b/doc/src/sgml/pgplanadvice.sgml @@ -812,6 +812,22 @@ EXPLAIN (COSTS OFF) force the choice of a plan which the planner refused to consider in the first place. + + + One consequence of the limitation described in the previous paragraph is + that plan advice works only probabilistically when + GEQO is used. Even if plans + compatible with the supplied advice exist, there is no guarantee that any + of them will be a part of the randomly generated pool of candidates. If + not, the planner will generate a plan that does not comply with the + supplied advice, with some parts of that plan marked disabled. If you + supply advice that only mildly constrains join planning, + GEQO will usually manage to find a plan that conforms + with it; but if you wish to constrain it more substantially, you may need + to disable GEQO in order to obtain satisfactory results. + Note that scan advice is not affected by this limitation because it does + not constrain the join order. + -- 2.51.0