diff options
author | Robert Haas <rhaas@postgresql.org> | 2025-08-20 15:10:52 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2025-10-07 12:43:45 -0400 |
commit | 64095d157482136ee609586266f8a37467c69bde (patch) | |
tree | af26200c2ee9082146ae5f573ecd744631d37865 /src/include | |
parent | 0132dddab33a6eae2d3d63eda9f053e745fedb06 (diff) |
Remove PlannerInfo's join_search_private method.
Instead, use the new mechanism that allows planner extensions to store
private state inside a PlannerInfo, treating GEQO as an in-core planner
extension. This is a useful test of the new facility, and also buys
back a few bytes of storage.
To make this work, we must remove innerrel_is_unique_ext's hack of
testing whether join_search_private is set as a proxy for whether
the join search might be retried. Add a flag that extensions can
use to explicitly signal their intentions instead.
Reviewed-by: Andrei Lepikhov <lepihov@gmail.com>
Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: http://postgr.es/m/CA+TgmoYWKHU2hKr62Toyzh-kTDEnMDeLw7gkOOnjL-TnOUq0kQ@mail.gmail.com
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/nodes/pathnodes.h | 5 | ||||
-rw-r--r-- | src/include/optimizer/geqo.h | 12 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/include/nodes/pathnodes.h b/src/include/nodes/pathnodes.h index 554d7c3ef67..4e3230ba234 100644 --- a/src/include/nodes/pathnodes.h +++ b/src/include/nodes/pathnodes.h @@ -536,6 +536,8 @@ struct PlannerInfo bool placeholdersFrozen; /* true if planning a recursive WITH item */ bool hasRecursion; + /* true if a planner extension may replan this subquery */ + bool assumeReplanning; /* * The rangetable index for the RTE_GROUP RTE, or 0 if there is no @@ -582,9 +584,6 @@ struct PlannerInfo bool *isAltSubplan pg_node_attr(read_write_ignore); bool *isUsedSubplan pg_node_attr(read_write_ignore); - /* optional private data for join_search_hook, e.g., GEQO */ - void *join_search_private pg_node_attr(read_write_ignore); - /* Does this query modify any partition key columns? */ bool partColsUpdated; diff --git a/src/include/optimizer/geqo.h b/src/include/optimizer/geqo.h index 9f8e0f337aa..b3017dd8ec4 100644 --- a/src/include/optimizer/geqo.h +++ b/src/include/optimizer/geqo.h @@ -24,6 +24,7 @@ #include "common/pg_prng.h" #include "nodes/pathnodes.h" +#include "optimizer/extendplan.h" #include "optimizer/geqo_gene.h" @@ -62,6 +63,8 @@ extern PGDLLIMPORT int Geqo_generations; /* 1 .. inf, or 0 to use default */ extern PGDLLIMPORT double Geqo_selection_bias; +extern PGDLLIMPORT int Geqo_planner_extension_id; + #define DEFAULT_GEQO_SELECTION_BIAS 2.0 #define MIN_GEQO_SELECTION_BIAS 1.5 #define MAX_GEQO_SELECTION_BIAS 2.0 @@ -70,7 +73,7 @@ extern PGDLLIMPORT double Geqo_seed; /* 0 .. 1 */ /* - * Private state for a GEQO run --- accessible via root->join_search_private + * Private state for a GEQO run --- accessible via GetGeqoPrivateData */ typedef struct { @@ -78,6 +81,13 @@ typedef struct pg_prng_state random_state; /* PRNG state */ } GeqoPrivateData; +static inline GeqoPrivateData * +GetGeqoPrivateData(PlannerInfo *root) +{ + /* headers must be C++-compliant, so the cast is required here */ + return (GeqoPrivateData *) + GetPlannerInfoExtensionState(root, Geqo_planner_extension_id); +} /* routines in geqo_main.c */ extern RelOptInfo *geqo(PlannerInfo *root, |