mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +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:
@ -936,7 +936,7 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
|
||||
/*
|
||||
* CE failed, so finish copying/modifying targetlist and join quals.
|
||||
*
|
||||
* Note: the resulting childrel->reltarget.exprs may contain arbitrary
|
||||
* NB: the resulting childrel->reltarget->exprs may contain arbitrary
|
||||
* expressions, which otherwise would not occur in a rel's targetlist.
|
||||
* Code that might be looking at an appendrel child must cope with
|
||||
* such. (Normally, a rel's targetlist would only include Vars and
|
||||
@ -947,9 +947,9 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
|
||||
adjust_appendrel_attrs(root,
|
||||
(Node *) rel->joininfo,
|
||||
appinfo);
|
||||
childrel->reltarget.exprs = (List *)
|
||||
childrel->reltarget->exprs = (List *)
|
||||
adjust_appendrel_attrs(root,
|
||||
(Node *) rel->reltarget.exprs,
|
||||
(Node *) rel->reltarget->exprs,
|
||||
appinfo);
|
||||
|
||||
/*
|
||||
@ -994,7 +994,7 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
|
||||
Assert(childrel->rows > 0);
|
||||
|
||||
parent_rows += childrel->rows;
|
||||
parent_size += childrel->reltarget.width * childrel->rows;
|
||||
parent_size += childrel->reltarget->width * childrel->rows;
|
||||
|
||||
/*
|
||||
* Accumulate per-column estimates too. We need not do anything for
|
||||
@ -1004,8 +1004,8 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
|
||||
*
|
||||
* By construction, child's targetlist is 1-to-1 with parent's.
|
||||
*/
|
||||
forboth(parentvars, rel->reltarget.exprs,
|
||||
childvars, childrel->reltarget.exprs)
|
||||
forboth(parentvars, rel->reltarget->exprs,
|
||||
childvars, childrel->reltarget->exprs)
|
||||
{
|
||||
Var *parentvar = (Var *) lfirst(parentvars);
|
||||
Node *childvar = (Node *) lfirst(childvars);
|
||||
@ -1040,7 +1040,7 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
|
||||
|
||||
Assert(parent_rows > 0);
|
||||
rel->rows = parent_rows;
|
||||
rel->reltarget.width = rint(parent_size / parent_rows);
|
||||
rel->reltarget->width = rint(parent_size / parent_rows);
|
||||
for (i = 0; i < nattrs; i++)
|
||||
rel->attr_widths[i] = rint(parent_attrsizes[i] / parent_rows);
|
||||
|
||||
@ -1515,7 +1515,7 @@ set_dummy_rel_pathlist(RelOptInfo *rel)
|
||||
{
|
||||
/* Set dummy size estimates --- we leave attr_widths[] as zeroes */
|
||||
rel->rows = 0;
|
||||
rel->reltarget.width = 0;
|
||||
rel->reltarget->width = 0;
|
||||
|
||||
/* Discard any pre-existing paths; no further need for them */
|
||||
rel->pathlist = NIL;
|
||||
@ -1771,7 +1771,7 @@ set_function_pathlist(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte)
|
||||
* not reference the ordinality column, or at least not in any way
|
||||
* that would be interesting for sorting.
|
||||
*/
|
||||
foreach(lc, rel->reltarget.exprs)
|
||||
foreach(lc, rel->reltarget->exprs)
|
||||
{
|
||||
Var *node = (Var *) lfirst(lc);
|
||||
|
||||
@ -2717,7 +2717,7 @@ remove_unused_subquery_outputs(Query *subquery, RelOptInfo *rel)
|
||||
* isn't computed for inheritance child rels, cf set_append_rel_size().
|
||||
* (XXX might be worth changing that sometime.)
|
||||
*/
|
||||
pull_varattnos((Node *) rel->reltarget.exprs, rel->relid, &attrs_used);
|
||||
pull_varattnos((Node *) rel->reltarget->exprs, rel->relid, &attrs_used);
|
||||
|
||||
/* Add all the attributes used by un-pushed-down restriction clauses. */
|
||||
foreach(lc, rel->baserestrictinfo)
|
||||
@ -3028,7 +3028,7 @@ debug_print_rel(PlannerInfo *root, RelOptInfo *rel)
|
||||
|
||||
printf("RELOPTINFO (");
|
||||
print_relids(rel->relids);
|
||||
printf("): rows=%.0f width=%d\n", rel->rows, rel->reltarget.width);
|
||||
printf("): rows=%.0f width=%d\n", rel->rows, rel->reltarget->width);
|
||||
|
||||
if (rel->baserestrictinfo)
|
||||
{
|
||||
|
Reference in New Issue
Block a user