diff options
| author | Tom Lane | 2016-03-14 20:59:59 +0000 |
|---|---|---|
| committer | Tom Lane | 2016-03-14 20:59:59 +0000 |
| commit | 307c78852f516042cebacaed411a0391bfeb2129 (patch) | |
| tree | afa2959e11e171e93411164a7e5b0adfa3609700 /src/include | |
| parent | 07341a2980a37ccbb3a51af2bd2f3c87953d8ea4 (diff) | |
Rethink representation of PathTargets.
In commit 19a541143a09c067 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.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/nodes/nodes.h | 1 | ||||
| -rw-r--r-- | src/include/nodes/relation.h | 65 |
2 files changed, 36 insertions, 30 deletions
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index fad9988119f..42c958258b6 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -259,6 +259,7 @@ typedef enum NodeTag T_EquivalenceClass, T_EquivalenceMember, T_PathKey, + T_PathTarget, T_RestrictInfo, T_PlaceHolderVar, T_SpecialJoinInfo, diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index bdea72c3f47..b48a6183dc2 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -62,34 +62,6 @@ typedef struct AggClauseCosts } AggClauseCosts; /* - * This struct contains what we need to know during planning about the - * targetlist (output columns) that a Path will compute. Each RelOptInfo - * includes a default PathTarget, which its individual Paths may merely point - * to. However, in some cases a Path may compute outputs different from other - * Paths, and in that case we make a custom PathTarget struct for it. For - * example, an indexscan might return index expressions that would otherwise - * need to be explicitly calculated. - * - * exprs contains bare expressions; they do not have TargetEntry nodes on top, - * though those will appear in finished Plans. - * - * sortgrouprefs[] is an array of the same length as exprs, containing the - * corresponding sort/group refnos, or zeroes for expressions not referenced - * by sort/group clauses. If sortgrouprefs is NULL (which it always is in - * RelOptInfo.reltarget structs; only upper-level Paths contain this info), we - * have not identified sort/group columns in this tlist. This allows us to - * deal with sort/group refnos when needed with less expense than including - * TargetEntry nodes in the exprs list. - */ -typedef struct PathTarget -{ - List *exprs; /* list of expressions to be computed */ - Index *sortgrouprefs; /* corresponding sort/group refnos, or 0 */ - QualCost cost; /* cost of evaluating the expressions */ - int width; /* estimated avg width of result tuples */ -} PathTarget; - -/* * This enum identifies the different types of "upper" (post-scan/join) * relations that we might deal with during planning. */ @@ -514,7 +486,7 @@ typedef struct RelOptInfo bool consider_parallel; /* consider parallel paths? */ /* default result targetlist for Paths scanning this relation */ - PathTarget reltarget; /* list of Vars/Exprs, cost, width */ + struct PathTarget *reltarget; /* list of Vars/Exprs, cost, width */ /* materialization information */ List *pathlist; /* Path structures */ @@ -766,6 +738,39 @@ typedef struct PathKey /* + * PathTarget + * + * This struct contains what we need to know during planning about the + * targetlist (output columns) that a Path will compute. Each RelOptInfo + * includes a default PathTarget, which its individual Paths may simply + * reference. However, in some cases a Path may compute outputs different + * from other Paths, and in that case we make a custom PathTarget for it. + * For example, an indexscan might return index expressions that would + * otherwise need to be explicitly calculated. (Note also that "upper" + * relations generally don't have useful default PathTargets.) + * + * exprs contains bare expressions; they do not have TargetEntry nodes on top, + * though those will appear in finished Plans. + * + * sortgrouprefs[] is an array of the same length as exprs, containing the + * corresponding sort/group refnos, or zeroes for expressions not referenced + * by sort/group clauses. If sortgrouprefs is NULL (which it generally is in + * RelOptInfo.reltarget targets; only upper-level Paths contain this info), + * we have not identified sort/group columns in this tlist. This allows us to + * deal with sort/group refnos when needed with less expense than including + * TargetEntry nodes in the exprs list. + */ +typedef struct PathTarget +{ + NodeTag type; + List *exprs; /* list of expressions to be computed */ + Index *sortgrouprefs; /* corresponding sort/group refnos, or 0 */ + QualCost cost; /* cost of evaluating the expressions */ + int width; /* estimated avg width of result tuples */ +} PathTarget; + + +/* * ParamPathInfo * * All parameterized paths for a given relation with given required outer rels @@ -802,7 +807,7 @@ typedef struct ParamPathInfo * "parent" identifies the relation this Path scans, and "pathtarget" * describes the precise set of output columns the Path would compute. * In simple cases all Paths for a given rel share the same targetlist, - * which we represent by having path->pathtarget point to parent->reltarget. + * which we represent by having path->pathtarget equal to parent->reltarget. * * "param_info", if not NULL, links to a ParamPathInfo that identifies outer * relation(s) that provide parameter values to each scan of this path. |
