mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Rethink representation of PathTargets.
In commit 19a541143a
I did not make PathTarget a subtype of Node,
and embedded a RelOptInfo's reltarget directly into it rather than having
a separately-allocated Node. In hindsight that was misguided
micro-optimization, enabled by the fact that at that point we didn't have
any Paths with custom PathTargets. Now that PathTarget processing has
been fleshed out some more, it's easier to see that it's better to have
PathTarget as an indepedent Node type, even if it does cost us one more
palloc to create a RelOptInfo. So change it while we still can.
This commit just changes the representation, without doing anything more
interesting than that.
This commit is contained in:
@ -24,6 +24,7 @@
|
||||
#include "optimizer/placeholder.h"
|
||||
#include "optimizer/plancat.h"
|
||||
#include "optimizer/restrictinfo.h"
|
||||
#include "optimizer/tlist.h"
|
||||
#include "utils/hsearch.h"
|
||||
|
||||
|
||||
@ -106,11 +107,7 @@ build_simple_rel(PlannerInfo *root, int relid, RelOptKind reloptkind)
|
||||
rel->consider_startup = (root->tuple_fraction > 0);
|
||||
rel->consider_param_startup = false; /* might get changed later */
|
||||
rel->consider_parallel = false; /* might get changed later */
|
||||
rel->reltarget.exprs = NIL;
|
||||
rel->reltarget.sortgrouprefs = NULL;
|
||||
rel->reltarget.cost.startup = 0;
|
||||
rel->reltarget.cost.per_tuple = 0;
|
||||
rel->reltarget.width = 0;
|
||||
rel->reltarget = create_empty_pathtarget();
|
||||
rel->pathlist = NIL;
|
||||
rel->ppilist = NIL;
|
||||
rel->partial_pathlist = NIL;
|
||||
@ -393,11 +390,7 @@ build_join_rel(PlannerInfo *root,
|
||||
joinrel->consider_startup = (root->tuple_fraction > 0);
|
||||
joinrel->consider_param_startup = false;
|
||||
joinrel->consider_parallel = false;
|
||||
joinrel->reltarget.exprs = NIL;
|
||||
joinrel->reltarget.sortgrouprefs = NULL;
|
||||
joinrel->reltarget.cost.startup = 0;
|
||||
joinrel->reltarget.cost.per_tuple = 0;
|
||||
joinrel->reltarget.width = 0;
|
||||
joinrel->reltarget = create_empty_pathtarget();
|
||||
joinrel->pathlist = NIL;
|
||||
joinrel->ppilist = NIL;
|
||||
joinrel->partial_pathlist = NIL;
|
||||
@ -613,7 +606,7 @@ build_joinrel_tlist(PlannerInfo *root, RelOptInfo *joinrel,
|
||||
Relids relids = joinrel->relids;
|
||||
ListCell *vars;
|
||||
|
||||
foreach(vars, input_rel->reltarget.exprs)
|
||||
foreach(vars, input_rel->reltarget->exprs)
|
||||
{
|
||||
Var *var = (Var *) lfirst(vars);
|
||||
RelOptInfo *baserel;
|
||||
@ -643,9 +636,9 @@ build_joinrel_tlist(PlannerInfo *root, RelOptInfo *joinrel,
|
||||
if (bms_nonempty_difference(baserel->attr_needed[ndx], relids))
|
||||
{
|
||||
/* Yup, add it to the output */
|
||||
joinrel->reltarget.exprs = lappend(joinrel->reltarget.exprs, var);
|
||||
/* Vars have cost zero, so no need to adjust reltarget.cost */
|
||||
joinrel->reltarget.width += baserel->attr_widths[ndx];
|
||||
joinrel->reltarget->exprs = lappend(joinrel->reltarget->exprs, var);
|
||||
/* Vars have cost zero, so no need to adjust reltarget->cost */
|
||||
joinrel->reltarget->width += baserel->attr_widths[ndx];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -832,6 +825,7 @@ build_empty_join_rel(PlannerInfo *root)
|
||||
joinrel->relids = NULL; /* empty set */
|
||||
joinrel->rows = 1; /* we produce one row for such cases */
|
||||
joinrel->rtekind = RTE_JOIN;
|
||||
joinrel->reltarget = create_empty_pathtarget();
|
||||
|
||||
root->join_rel_list = lappend(root->join_rel_list, joinrel);
|
||||
|
||||
@ -882,6 +876,7 @@ fetch_upper_rel(PlannerInfo *root, UpperRelationKind kind, Relids relids)
|
||||
upperrel->consider_startup = (root->tuple_fraction > 0);
|
||||
upperrel->consider_param_startup = false;
|
||||
upperrel->consider_parallel = false; /* might get changed later */
|
||||
upperrel->reltarget = create_empty_pathtarget();
|
||||
upperrel->pathlist = NIL;
|
||||
upperrel->cheapest_startup_path = NULL;
|
||||
upperrel->cheapest_total_path = NULL;
|
||||
|
Reference in New Issue
Block a user