/* *Costingaggregatefunctionexecutionrequiresthesestatisticsabout *theaggregatestobeexecutedbyagivenAggnode.Notethatthecosts *includetheexecutioncostsoftheaggregates'argumentexpressionsas *wellastheaggregatefunctionsthemselves.Also,thefieldsmustbe *definedsothatinitializingthestructtozeroeswithmemsetiscorrect.
*/ typedefstruct AggClauseCosts
{
QualCost transCost; /* total per-input-row execution costs */
QualCost finalCost; /* total per-aggregated-row costs */
Size transitionSpace; /* space for pass-by-ref transition data */
} AggClauseCosts;
/* *Thisenumidentifiesthedifferenttypesof"upper"(post-scan/join) *relationsthatwemightdealwithduringplanning.
*/ typedefenum UpperRelationKind
{
UPPERREL_SETOP, /* result of UNION/INTERSECT/EXCEPT, if any */
UPPERREL_PARTIAL_GROUP_AGG, /* result of partial grouping/aggregation, if
* any */
UPPERREL_GROUP_AGG, /* result of grouping/aggregation, if any */
UPPERREL_WINDOW, /* result of window functions, if any */
UPPERREL_PARTIAL_DISTINCT, /* result of partial "SELECT DISTINCT", if any */
UPPERREL_DISTINCT, /* result of "SELECT DISTINCT", if any */
UPPERREL_ORDERED, /* result of ORDER BY, if any */
UPPERREL_FINAL, /* result of any remaining top-level actions */ /* NB: UPPERREL_FINAL must be last enum entry; it's used to size arrays */
} UpperRelationKind;
/* macro for fetching the Plan associated with a SubPlan node */ #define planner_subplan_get_plan(root, subplan) \
((Plan *) list_nth((root)->glob->subplans, (subplan)->plan_id - 1))
/* global info for current planner run */
PlannerGlobal *glob;
/* 1 at the outermost Query */
Index query_level;
/* NULL at outermost Query */
PlannerInfo *parent_root pg_node_attr(read_write_ignore);
/* *plan_paramscontainstheexpressionsthatthisquerylevelneedsto *makeavailabletoalowerquerylevelthatiscurrentlybeingplanned. *outer_paramscontainstheparamIdsofPARAM_EXECParamsthatouter *querylevelswillmakeavailabletothisquerylevel.
*/ /* list of PlannerParamItems, see below */
List *plan_params;
Bitmapset *outer_params;
/* *simple_rel_arrayholdspointersto"baserels"and"otherrels"(see *commentsforRelOptInfoformoreinfo).Itisindexedbyrangetable *index(soentry0isalwayswasted).EntriescanbeNULLwhenanRTE *doesnotcorrespondtoabaserelation,suchasajoinRTEoran *unreferencedviewRTE;oriftheRelOptInfohasn'tbeenmadeyet.
*/ struct RelOptInfo **simple_rel_array pg_node_attr(array_size(simple_rel_array_size)); /* allocated size of array */ int simple_rel_array_size;
/* *Whendoingadynamic-programming-stylejoinsearch,join_rel_level[k] *isalistofalljoin-relationRelOptInfosoflevelk,and *join_cur_levelisthecurrentlevel.Newjoin-relationRelOptInfosare *automaticallyaddedtothejoin_rel_level[join_cur_level]list. *join_rel_levelisNULLifnotinuse. * *Note:we'vealreadyprintedallbaserelandjoinrelRelOptInfosabove, *sowedon'tdumpjoin_rel_levelorotherlistsofRelOptInfos.
*/ /* lists of join-relation RelOptInfos */
List **join_rel_level pg_node_attr(read_write_ignore); /* index of list being extended */ int join_cur_level;
/* init SubPlans for query */
List *init_plans;
/* *per-CTE-itemlistofsubplanIDs(or-1ifnosubplanwasmadeforthat *CTE)
*/
List *cte_plan_ids;
/* List of Lists of Params for MULTIEXPR subquery outputs */
List *multiexpr_params;
/* list of JoinDomains used in the query (higher ones first) */
List *join_domains;
/* list of active EquivalenceClasses */
List *eq_classes;
/* set true once ECs are canonical */ bool ec_merging_done;
/* list of "canonical" PathKeys */
List *canon_pathkeys;
/* *listofOuterJoinClauseInfosformergejoinableouterjoinclauses *w/nonnullablevaronleft
*/
List *left_join_clauses;
/* *listofOuterJoinClauseInfosformergejoinableouterjoinclauses *w/nonnullablevaronright
*/
List *right_join_clauses;
/* *listofOuterJoinClauseInfosformergejoinablefulljoinclauses
*/
List *full_join_clauses;
/* list of SpecialJoinInfos */
List *join_info_list;
/* counter for assigning RestrictInfo serial numbers */ int last_rinfo_serial;
/* *all_result_relidsisemptyforSELECT,otherwiseitcontainsatleast *parse->resultRelation.ForUPDATE/DELETE/MERGEacrossaninheritance *orpartitioningtree,theresultrel'schildrelidsareadded.When *usingmulti-levelpartitioning,intermediatepartitionedrelsare *included.leaf_result_relidsissimilarexceptthatonlyactualresult *tables,notpartitionedtables,areincludedinit.
*/ /* set of all result relids */
Relids all_result_relids; /* set of all leaf relids */
Relids leaf_result_relids;
/* *listofAppendRelInfos * *Note:forAppendRelInfosdescribingpartitionsofapartitionedtable, *weguaranteethatpartitionsthatcomeearlierinthepartitioned *table'sPartitionDescwillappearearlierinappend_rel_list.
*/
List *append_rel_list;
/* list of RowIdentityVarInfos */
List *row_identity_vars;
/* list of PlanRowMarks */
List *rowMarks;
/* list of PlaceHolderInfos */
List *placeholder_list;
/* array of PlaceHolderInfos indexed by phid */ struct PlaceHolderInfo **placeholder_array pg_node_attr(read_write_ignore, array_size(placeholder_array_size)); /* allocated size of array */ int placeholder_array_size pg_node_attr(read_write_ignore);
/* list of ForeignKeyOptInfos */
List *fkey_list;
/* desired pathkeys for query_planner() */
List *query_pathkeys;
/* groupClause pathkeys, if any */
List *group_pathkeys;
/* *Thenumberofelementsinthegroup_pathkeyslistwhichbelongtothe *GROUPBYclause.AdditionalonesbelongtoORDERBY/DISTINCT *aggregates.
*/ int num_groupby_pathkeys;
/* pathkeys of bottom window, if any */
List *window_pathkeys; /* distinctClause pathkeys, if any */
List *distinct_pathkeys; /* sortClause pathkeys, if any */
List *sort_pathkeys; /* set operator pathkeys, if any */
List *setop_pathkeys;
/* Canonicalised partition schemes used in the query. */
List *part_schemes pg_node_attr(read_write_ignore);
/* RelOptInfos we are now trying to join */
List *initial_rels pg_node_attr(read_write_ignore);
/* *Upper-relRelOptInfos.Usefetch_upper_rel()togetanyparticular *upperrel.
*/
List *upper_rels[UPPERREL_FINAL + 1] pg_node_attr(read_write_ignore);
/* Result tlists chosen by grouping_planner for upper-stage processing */ struct PathTarget *upper_targets[UPPERREL_FINAL + 1] pg_node_attr(read_write_ignore);
/* *ForUPDATE,thislistcontainsthetargettable'sattributenumbersto *whichthefirstNentriesofprocessed_tlistaretobeassigned.(Any *additionalentriesinprocessed_tlistmustberesjunk.)DONOTusethe *resnosinprocessed_tlisttoidentifytheUPDATEtargetcolumns.
*/
List *update_colnos;
/* *Fieldsfilledduringcreate_plan()foruseinsetrefs.c
*/ /* for GroupingFunc fixup (can't print: array length not known here) */
AttrNumber *grouping_map pg_node_attr(read_write_ignore); /* List of MinMaxAggInfos */
List *minmax_aggs;
/* # of pages in all non-dummy tables of query */
Cardinality total_table_pages;
/* tuple_fraction passed to query_planner */
Selectivity tuple_fraction; /* limit_tuples passed to query_planner */
Cardinality limit_tuples;
/* *Minimumsecurity_levelforquals.Note:qual_security_leveliszeroif *therearenosecurityQuals.
*/
Index qual_security_level;
/* true if any RTEs are RTE_JOIN kind */ bool hasJoinRTEs; /* true if any RTEs are marked LATERAL */ bool hasLateralRTEs; /* true if havingQual was non-null */ bool hasHavingQual; /* true if any RestrictInfo has pseudoconstant = true */ bool hasPseudoConstantQuals; /* true if we've made any of those */ bool hasAlternativeSubPlans; /* true once we're no longer allowed to add PlaceHolderInfos */ bool placeholdersFrozen; /* true if planning a recursive WITH item */ bool hasRecursion;
/* *TherangetableindexfortheRTE_GROUPRTE,or0ifthereisno *RTE_GROUPRTE.
*/ int group_rtindex;
/* *Informationaboutaggregates.Filledbypreprocess_aggrefs().
*/ /* AggInfo structs */
List *agginfos; /* AggTransInfo structs */
List *aggtransinfos; /* number of aggs with DISTINCT/ORDER BY/WITHIN GROUP */ int numOrderedAggs; /* does any agg not support partial mode? */ bool hasNonPartialAggs; /* is any partial agg non-serializable? */ bool hasNonSerialAggs;
/* *ThesefieldsareusedonlywhenhasRecursionistrue:
*/ /* PARAM_EXEC ID for the work table */ int wt_param_id; /* a path for non-recursive term */ struct Path *non_recursive_path;
/* *Thesefieldsareworkspaceforcreateplan.c
*/ /* outer rels above current node */
Relids curOuterRels; /* not-yet-assigned NestLoopParams */
List *curOuterParams;
/* Is the given relation a join relation? */ #define IS_JOIN_REL(rel) \
((rel)->reloptkind == RELOPT_JOINREL || \
(rel)->reloptkind == RELOPT_OTHER_JOINREL)
/* Is the given relation an upper relation? */ #define IS_UPPER_REL(rel) \
((rel)->reloptkind == RELOPT_UPPER_REL || \
(rel)->reloptkind == RELOPT_OTHER_UPPER_REL)
/* Is the given relation an "other" relation? */ #define IS_OTHER_REL(rel) \
((rel)->reloptkind == RELOPT_OTHER_MEMBER_REL || \
(rel)->reloptkind == RELOPT_OTHER_JOINREL || \
(rel)->reloptkind == RELOPT_OTHER_UPPER_REL)
/* *Zero-basedsetcontainingattnumsofNOTNULLcolumns.Notpopulated *forrelscorrespondingtonon-partitionedinh==trueRTEs.
*/
Bitmapset *notnullattnums; /* relids of outer joins that can null this baserel */
Relids nulling_relids; /* LATERAL Vars and PHVs referenced by rel */
List *lateral_vars; /* rels that reference this baserel laterally */
Relids lateral_referencers; /* list of IndexOptInfo */
List *indexlist; /* list of StatisticExtInfo */
List *statlist; /* size estimates derived from pg_class */
BlockNumber pages;
Cardinality tuples; double allvisfrac; /* indexes in PlannerInfo's eq_classes list of ECs that mention this rel */
Bitmapset *eclass_indexes;
PlannerInfo *subroot; /* if subquery */
List *subplan_params; /* if subquery */ /* wanted number of parallel workers */ int rel_parallel_workers; /* Bitmask of optional features supported by the table AM */
uint32 amflags;
/* *Informationaboutforeigntablesandforeignjoins
*/ /* identifies server for the table or join */
Oid serverid; /* identifies user to check access as; 0 means to check as current user */
Oid userid; /* join is only valid for current user */ bool useridiscurrent; /* use "struct FdwRoutine" to avoid including fdwapi.h here */ struct FdwRoutine *fdwroutine pg_node_attr(read_write_ignore); void *fdw_private pg_node_attr(read_write_ignore);
/* *cachespaceforrememberingifwehaveproventhisrelationunique
*/ /* known unique for these other relid set(s) given in UniqueRelInfo(s) */
List *unique_for_rels; /* known not unique for these set(s) */
List *non_unique_for_rels;
/* *usedbyvariousscansandjoins:
*/ /* RestrictInfo structures (if base rel) */
List *baserestrictinfo; /* cost of evaluating the above */
QualCost baserestrictcost; /* min security_level found in baserestrictinfo */
Index baserestrict_min_security; /* RestrictInfo structures for join clauses involving this rel */
List *joininfo; /* T means joininfo is incomplete */ bool has_eclass_joins;
/* *inheritancelinks,ifthisisanotherrel(otherwiseNULL):
*/ /* Immediate parent relation (dumping it would be too verbose) */ struct RelOptInfo *parent pg_node_attr(read_write_ignore); /* Topmost parent relation (dumping it would be too verbose) */ struct RelOptInfo *top_parent pg_node_attr(read_write_ignore); /* Relids of topmost parent (redundant, but handy) */
Relids top_parent_relids;
/* *Numberofpartitions;-1ifnotyetset;incaseofajoinrelation0 *meansit'sconsideredunpartitioned
*/ int nparts; /* Partition bounds */ struct PartitionBoundInfoData *boundinfo pg_node_attr(read_write_ignore); /* True if partition bounds were created by partition_bounds_merge() */ bool partbounds_merged; /* Partition constraint, if not the root */
List *partition_qual;
/* OID of the index relation */
Oid indexoid; /* tablespace of index (not table) */
Oid reltablespace; /* back-link to index's table; don't print, else infinite recursion */
RelOptInfo *rel pg_node_attr(read_write_ignore);
/* *index-sizestatistics(frompg_classandelsewhere)
*/ /* number of disk pages in index */
BlockNumber pages; /* number of index tuples in index */
Cardinality tuples; /* index tree height, or -1 if unknown */ int tree_height;
/* *indexdescriptorinformation
*/ /* number of columns in index */ int ncolumns; /* number of key columns in index */ int nkeycolumns;
/* *tablecolumnnumbersofindex'scolumns(bothkeyandincluded *columns),or0forexpressioncolumns
*/ int *indexkeys pg_node_attr(array_size(ncolumns)); /* OIDs of collations of index columns */
Oid *indexcollations pg_node_attr(array_size(nkeycolumns)); /* OIDs of operator families for columns */
Oid *opfamily pg_node_attr(array_size(nkeycolumns)); /* OIDs of opclass declared input data types */
Oid *opcintype pg_node_attr(array_size(nkeycolumns)); /* OIDs of btree opfamilies, if orderable. NULL if partitioned index */
Oid *sortopfamily pg_node_attr(array_size(nkeycolumns)); /* is sort order descending? or NULL if partitioned index */ bool *reverse_sort pg_node_attr(array_size(nkeycolumns)); /* do NULLs come first in the sort order? or NULL if partitioned index */ bool *nulls_first pg_node_attr(array_size(nkeycolumns)); /* opclass-specific options for columns */
bytea **opclassoptions pg_node_attr(read_write_ignore); /* which index cols can be returned in an index-only scan? */ bool *canreturn pg_node_attr(array_size(ncolumns)); /* OID of the access method (in pg_am) */
Oid relam;
/* *expressionsfornon-simpleindexcolumns;redundanttoprintsincewe *printindextlist
*/
List *indexprs pg_node_attr(read_write_ignore); /* predicate if a partial index, else NIL */
List *indpred;
/* targetlist representing index columns */
List *indextlist;
/* *parentrelation'sbaserestrictinfolist,lessanyconditionsimpliedby *theindex'spredicate(unlessit'satargetrel,seecommentsin *check_index_predicates())
*/
List *indrestrictinfo;
/* true if index predicate matches query */ bool predOK; /* true if a unique index */ bool unique; /* true if the index was defined with NULLS NOT DISTINCT */ bool nullsnotdistinct; /* is uniqueness enforced immediately? */ bool immediate; /* true if index doesn't really exist */ bool hypothetical;
/* *RemainingfieldsarecopiedfromtheindexAM'sAPIstruct *(IndexAmRoutine).Thesefieldsarenotsetforpartitionedindexes.
*/ bool amcanorderbyop; bool amoptionalkey; bool amsearcharray; bool amsearchnulls; /* does AM have amgettuple interface? */ bool amhasgettuple; /* does AM have amgetbitmap interface? */ bool amhasgetbitmap; bool amcanparallel; /* does AM have ammarkpos interface? */ bool amcanmarkpos; /* AM's cost estimator */ /* Rather than include amapi.h here, we declare amcostestimate like this */ void (*amcostestimate) (struct PlannerInfo *, struct IndexPath *, double, Cost *, Cost *, Selectivity *, double *, double *) pg_node_attr(read_write_ignore);
};
/* RT index of the referencing table */
Index con_relid; /* RT index of the referenced table */
Index ref_relid; /* number of columns in the foreign key */ int nkeys; /* cols in referencing table */
AttrNumber conkey[INDEX_MAX_KEYS] pg_node_attr(array_size(nkeys)); /* cols in referenced table */
AttrNumber confkey[INDEX_MAX_KEYS] pg_node_attr(array_size(nkeys)); /* PK = FK operator OIDs */
Oid conpfeqop[INDEX_MAX_KEYS] pg_node_attr(array_size(nkeys));
/* # of FK cols matched by ECs */ int nmatched_ec; /* # of these ECs that are ec_has_const */ int nconst_ec; /* # of FK cols matched by non-EC rinfos */ int nmatched_rcols; /* total # of non-EC rinfos matched to FK */ int nmatched_ri; /* Pointer to eclass matching each column's condition, if there is one */ struct EquivalenceClass *eclass[INDEX_MAX_KEYS]; /* Pointer to eclass member for the referencing Var, if there is one */ struct EquivalenceMember *fk_eclass_member[INDEX_MAX_KEYS]; /* List of non-EC RestrictInfos matching each column's condition */
List *rinfos[INDEX_MAX_KEYS];
} ForeignKeyOptInfo;
List *ec_opfamilies; /* btree operator family OIDs */
Oid ec_collation; /* collation, if datatypes are collatable */ int ec_childmembers_size; /* # elements in ec_childmembers */
List *ec_members; /* list of EquivalenceMembers */
List **ec_childmembers; /* array of Lists of child members */
List *ec_sources; /* list of generating RestrictInfos */
List *ec_derives_list; /* list of derived RestrictInfos */ struct derives_hash *ec_derives_hash; /* optional hash table for fast *lookup;containssame
* RestrictInfos as list */
Relids ec_relids; /* all relids appearing in ec_members, except
* for child members (see below) */ bool ec_has_const; /* any pseudoconstants in ec_members? */ bool ec_has_volatile; /* the (sole) member is a volatile expr */ bool ec_broken; /* failed to generate needed clauses? */
Index ec_sortref; /* originating sortclause label, or 0 */
Index ec_min_security; /* minimum security_level in ec_sources */
Index ec_max_security; /* maximum security_level in ec_sources */ struct EquivalenceClass *ec_merged; /* set if merged into another EC */
} EquivalenceClass;
Expr *em_expr; /* the expression represented */
Relids em_relids; /* all relids appearing in em_expr */ bool em_is_const; /* expression is pseudoconstant? */ bool em_is_child; /* derived version for a child relation? */
Oid em_datatype; /* the "nominal type" used by the opfamily */
JoinDomain *em_jdomain; /* join domain containing the source clause */ /* if em_is_child is true, this links to corresponding EM for top parent */ struct EquivalenceMember *em_parent pg_node_attr(read_write_ignore);
} EquivalenceMember;
/* *EquivalenceMemberIterator * *EquivalenceMemberIteratorallowsefficientaccesstosetsof *EquivalenceMembersforcallerswhichrequireaccesstochildmembers. *Becausepartitioningworkloadscanresultinlargenumbersofchild *members,thechildmembersarenotstoredintheEquivalenceClass's *ec_membersList.Instead,thesearestoredintheEquivalenceClass's *ec_childmembersarrayofLists.Thefunctionalityprovidedby *EquivalenceMemberIteratoraimstoprovideefficientaccesstoparent *membersandchildmembersbelongingtospecificchildrelids. * *Currently,thereisonlyonewaytoinitializeanditerateoveran *EquivalenceMemberIteratorandthatisviathesetup_eclass_member_iterator *andeclass_member_iterator_nextfunctions.Theiteratorobjectis *generallyalocalvariablewhichispassedbyaddressto *setup_eclass_member_iterator.Thecallingfunctiondefineswhich *EquivalenceClasstheiteratorshouldbelookingatandwhichchild *relidstoalsoreturnmembersfor.child_relidscanbepassedasNULL,but *thecallermayaswelljustperformaforeachloopoverec_membersasonly *parent-levelmemberswillbereturnedinthatcase. * *WhencallingthenextfunctiononanEquivalenceMemberIterator,all *parent-levelEquivalenceMembersarereturnedfirst,followedbyallchild *membersforthespecified'child_relids'forallchildmemberswhichwere *indexedbyanyofthespecified'child_relids'inadd_child_eq_member(). * *CodeusingtheiteratormethodoffindingEquivalenceMemberswillgenerally *alwayswanttoensurethereturnedmembermatchestheirsearchcriteria *ratherthanrelyingonthefilteringtobedoneforthemasallparent *membersarereturnedandformembersbelongingtoRELOPT_OTHER_JOINREL *rels,themember'sem_relidsmaybeasupersetofthespecified *'child_relids',whichmightnotbewhatthecallerwants. * *Themostcommonwaytousethisiteratorisasfollows: *----- *EquivalenceMemberIteratorit; *EquivalenceMember*em; * *setup_eclass_member_iterator(&it,ec,child_relids); *while((em=eclass_member_iterator_next(&it))!=NULL) *{ *... *} *----- *Itisnotvalidtocalleclass_member_iterator_next()afterithasreturned *NULLforanygivenEquivalenceMemberIterator.Individualfieldswithin *theEquivalenceMemberIteratorstructmustnotbeaccessedbycallers.
*/ typedefstruct
{
EquivalenceClass *ec; /* The EquivalenceClass to iterate over */ int current_relid; /* Current relid position within 'relids'. -1 *whenstillloopingoverec_membersand-2
* at the end of iteration */
Relids child_relids; /* Relids of child relations of interest.
* Non-child rels are ignored */
ListCell *current_cell; /* Next cell to return within current_list */
List *current_list; /* Current list of members being returned */
} EquivalenceMemberIterator;
/* the value that is ordered */
EquivalenceClass *pk_eclass pg_node_attr(copy_as_scalar, equal_as_scalar);
Oid pk_opfamily; /* index opfamily defining the ordering */
CompareType pk_cmptype; /* sort direction (ASC or DESC) */ bool pk_nulls_first; /* do NULLs come before normal values? */
} PathKey;
/* list of expressions to be computed */
List *exprs;
/* corresponding sort/group refnos, or 0 */
Index *sortgrouprefs pg_node_attr(array_size(exprs));
/* cost of evaluating the expressions */
QualCost cost;
/* estimated avg width of result tuples */ int width;
/* indicates if exprs contain any volatile functions */
VolatileFunctionStatus has_volatile_expr;
} PathTarget;
/* Convenience macro to get a sort/group refno from a PathTarget */ #define get_pathtarget_sortgroupref(target, colno) \
((target)->sortgrouprefs ? (target)->sortgrouprefs[colno] : (Index) 0)
Relids ppi_req_outer; /* rels supplying parameters used by path */
Cardinality ppi_rows; /* estimated number of result tuples */
List *ppi_clauses; /* join clauses available from outer rels */
Bitmapset *ppi_serials; /* set of rinfo_serial for enforced quals */
} ParamPathInfo;
/* engage parallel-aware logic? */ bool parallel_aware; /* OK to use as part of parallel plan? */ bool parallel_safe; /* desired # of workers; 0 = not parallel */ int parallel_workers;
/* estimated size/costs for path (see costsize.c for more info) */
Cardinality rows; /* estimated number of result tuples */ int disabled_nodes; /* count of disabled nodes */
Cost startup_cost; /* cost expended before fetching any tuples */
Cost total_cost; /* total cost (assuming all tuples fetched) */
/* sort ordering of path's output; a List of PathKey nodes; see above */
List *pathkeys;
} Path;
NodeTag type; struct RestrictInfo *rinfo; /* original restriction or join clause */
List *indexquals; /* indexqual(s) derived from it */ bool lossy; /* are indexquals a lossy version of clause? */
AttrNumber indexcol; /* index column the clause uses (zero-based) */
List *indexcols; /* multiple index columns, if RowCompare */
} IndexClause;
typedefstruct CustomPath
{
Path path;
uint32 flags; /* mask of CUSTOMPATH_* flags, see
* nodes/extensible.h */
List *custom_paths; /* list of child Path nodes, if any */
List *custom_restrictinfo;
List *custom_private; conststruct CustomPathMethods *methods;
} CustomPath;
/* *AppendPathrepresentsanAppendplan,ie,successiveexecutionof *severalmemberplans. * *ForpartialAppend,'subpaths'containsnon-partialsubpathsfollowedby *partialsubpaths. * *Note:itispossiblefor"subpaths"tocontainonlyone,orevenno, *elements.Thesecasesareoptimizedduringcreate_append_plan. *Inparticular,anAppendPathwithnosubpathsisa"dummy"paththat *iscreatedtorepresentthecasethatarelationisprovablyempty. *(Thisisaconvenientrepresentationbecauseitmeansthatwhenwebuild *anappendrelandfindthatallitschildrenhavebeenexcluded,noextra *actionisneededtorecognizetherelationasdummy.)
*/ typedefstruct AppendPath
{
Path path;
List *subpaths; /* list of component Paths */ /* Index of first partial path in subpaths; list_length(subpaths) if none */ int first_partial_path;
Cardinality limit_tuples; /* hard limit on output tuples, or -1 */
} AppendPath;
/* *MergeAppendPathrepresentsaMergeAppendplan,ie,themergingofsorted *resultsfromseveralmemberplanstoproducesimilarly-sortedoutput.
*/ typedefstruct MergeAppendPath
{
Path path;
List *subpaths; /* list of component Paths */
Cardinality limit_tuples; /* hard limit on output tuples, or -1 */
} MergeAppendPath;
/* *MemoizePathrepresentsaMemoizeplannode,i.e.,acachethatcaches *tuplesfromparameterizedpathstosavetheunderlyingnodefromhavingto *berescannedforparametervalueswhicharealreadycached.
*/ typedefstruct MemoizePath
{
Path path;
Path *subpath; /* outerpath to cache tuples from */
List *hash_operators; /* OIDs of hash equality ops for cache keys */
List *param_exprs; /* expressions that are cache keys */ bool singlerow; /* true if the cache entry is to be marked as
* complete after caching the first record. */ bool binary_mode; /* true when cache key should be compared bit
* by bit, false when using hash equality ops */
Cardinality calls; /* expected number of rescans */
uint32 est_entries; /* The maximum number of entries that the *plannerexpectswillfitinthecache,or0
* if unknown */
} MemoizePath;
/* *UniquePathrepresentseliminationofdistinctrowsfromtheoutputof *itssubpath. * *Thiscanrepresentsignificantlydifferentplans:eitherhash-basedor *sort-basedimplementation,orano-opiftheinputpathcanbeproven *distinctalready.Thedecisionissufficientlylocalizedthatit'snot *worthhavingseparatePathnodetypes.(Note:intheno-opcase,wecould *eliminatetheUniquePathnodeentirelyandjustreturnthesubpath;but *it'sconvenienttohaveaUniquePathinthepathtreetosignalupper-level *routinesthattheinputisknowndistinct.)
*/ typedefenum UniquePathMethod
{
UNIQUE_PATH_NOOP, /* input is known unique already */
UNIQUE_PATH_HASH, /* use hashing */
UNIQUE_PATH_SORT, /* use sorting */
} UniquePathMethod;
typedefstruct UniquePath
{
Path path;
Path *subpath;
UniquePathMethod umethod;
List *in_operators; /* equality operators of the IN clause */
List *uniq_exprs; /* expressions to be made unique */
} UniquePath;
/* *GatherPathrunsseveralcopiesofaplaninparallelandcollectsthe *results.Theparallelleadermayalsoexecutetheplan,unlessthe *single_copyflagisset.
*/ typedefstruct GatherPath
{
Path path;
Path *subpath; /* path for each worker */ bool single_copy; /* don't execute path more than once */ int num_workers; /* number of workers sought to help */
} GatherPath;
/* *GatherMergePathrunsseveralcopiesofaplaninparallelandcollects *theresults,preservingtheircommonsortorder.
*/ typedefstruct GatherMergePath
{
Path path;
Path *subpath; /* path for each worker */ int num_workers; /* number of workers sought to help */
} GatherMergePath;
/* *Alljoin-typepathssharethesefields.
*/
typedefstruct JoinPath
{
pg_node_attr(abstract)
Path path;
JoinType jointype;
bool inner_unique; /* each outer tuple provably matches no more
* than one inner tuple */
Path *outerjoinpath; /* path for the outer side of the join */
Path *innerjoinpath; /* path for the inner side of the join */
List *joinrestrictinfo; /* RestrictInfos to apply to join */
typedefstruct MergePath
{
JoinPath jpath;
List *path_mergeclauses; /* join clauses to be used for merge */
List *outersortkeys; /* keys for explicit sort, if any */
List *innersortkeys; /* keys for explicit sort, if any */ int outer_presorted_keys; /* number of presorted keys of the
* outer path */ bool skip_mark_restore; /* can executor skip mark/restore? */ bool materialize_inner; /* add Materialize to inner? */
} MergePath;
typedefstruct HashPath
{
JoinPath jpath;
List *path_hashclauses; /* join clauses used for hashing */ int num_batches; /* number of batches expected */
Cardinality inner_rows_total; /* total inner rows expected */
} HashPath;
/* *ProjectionPathrepresentsaprojection(thatis,targetlistcomputation) * *Nominally,thispathnoderepresentsusingaResultplannodetodoa *projectionstep.However,iftheinputplannodesupportsprojection, *wecanjustmodifyitsoutputtargetlisttodotherequiredcalculations *directly,andnotneedaResult.Insomeplacesintheplannerwecanjust *jamthedesiredPathTargetintotheinputpathnode(andadjustitscost *accordingly),sowedon'tneedaProjectionPath.Butinotherplaces *it'snecessarytonotmodifytheinputpathnode,soweneedaseparate *ProjectionPathnode,whichismarkeddummytoindicatethatweintendto *assigntheworktotheinputplannode.Theestimatedcostforthe *ProjectionPathnodewillaccountforwhetheraResultwillbeusedornot.
*/ typedefstruct ProjectionPath
{
Path path;
Path *subpath; /* path representing input source */ bool dummypp; /* true if no separate Result is needed */
} ProjectionPath;
/* *IncrementalSortPathrepresentsanincrementalsortstep * *Thisislikearegularsort,exceptsomeleadingkeycolumnsareassumed *tobeorderedalready.
*/ typedefstruct IncrementalSortPath
{
SortPath spath; int nPresortedCols; /* number of presorted columns */
} IncrementalSortPath;
/* *GroupPathrepresentsgrouping(ofpresortedinput) * *groupClauserepresentsthecolumnstobegroupedon;theinputpath *mustbeatleastthatwellsorted. * *Wecanalsoapplyaqualtothegroupedrows(equivalentofHAVING)
*/ typedefstruct GroupPath
{
Path path;
Path *subpath; /* path representing input source */
List *groupClause; /* a list of SortGroupClause's */
List *qual; /* quals (HAVING quals), if any */
} GroupPath;
/* *UpperUniquePathrepresentsadjacent-duplicateremoval(inpresortedinput) * *Thecolumnstobecomparedarethefirstnumkeyscolumnsofthepath's *pathkeys.Theinputispresumedalreadysortedthatway.
*/ typedefstruct UpperUniquePath
{
Path path;
Path *subpath; /* path representing input source */ int numkeys; /* number of pathkey columns to compare */
} UpperUniquePath;
/* *AggPathrepresentsgenericcomputationofaggregatefunctions * *Thismayinvolveplaingrouping(butnotgroupingsets),usingeither *sortedorhashedgrouping;fortheAGG_SORTEDcase,theinputmustbe *appropriatelypresorted.
*/ typedefstruct AggPath
{
Path path;
Path *subpath; /* path representing input source */
AggStrategy aggstrategy; /* basic strategy, see nodes.h */
AggSplit aggsplit; /* agg-splitting mode, see nodes.h */
Cardinality numGroups; /* estimated number of groups in input */
uint64 transitionSpace; /* for pass-by-ref transition data */
List *groupClause; /* a list of SortGroupClause's */
List *qual; /* quals (HAVING quals), if any */
} AggPath;
NodeTag type;
List *groupClause; /* applicable subset of parse->groupClause */
List *gsets; /* lists of integer indexes into groupClause */
List *gsets_data; /* list of GroupingSetData */
Cardinality numGroups; /* est. number of result groups */ bool hashable; /* can be hashed */ bool is_hashed; /* to be implemented as a hashagg */
} RollupData;
typedefstruct GroupingSetsPath
{
Path path;
Path *subpath; /* path representing input source */
AggStrategy aggstrategy; /* basic strategy */
List *rollups; /* list of RollupData */
List *qual; /* quals (HAVING quals), if any */
uint64 transitionSpace; /* for pass-by-ref transition data */
} GroupingSetsPath;
/* *MinMaxAggPathrepresentscomputationofMIN/MAXaggregatesfromindexes
*/ typedefstruct MinMaxAggPath
{
Path path;
List *mmaggregates; /* list of MinMaxAggInfo */
List *quals; /* HAVING quals, if any */
} MinMaxAggPath;
/* *WindowAggPathrepresentsgenericcomputationofwindowfunctions
*/ typedefstruct WindowAggPath
{
Path path;
Path *subpath; /* path representing input source */
WindowClause *winclause; /* WindowClause we'll be using */
List *qual; /* lower-level WindowAgg runconditions */
List *runCondition; /* OpExpr List to short-circuit execution */ bool topwindow; /* false for all apart from the WindowAgg
* that's closest to the root of the plan */
} WindowAggPath;
/* *SetOpPathrepresentsaset-operation,thatisINTERSECTorEXCEPT
*/ typedefstruct SetOpPath
{
Path path;
Path *leftpath; /* paths representing input sources */
Path *rightpath;
SetOpCmd cmd; /* what to do, see nodes.h */
SetOpStrategy strategy; /* how to do it, see nodes.h */
List *groupList; /* SortGroupClauses identifying target cols */
Cardinality numGroups; /* estimated number of groups in left input */
} SetOpPath;
/* *RecursiveUnionPathrepresentsarecursiveUNIONnode
*/ typedefstruct RecursiveUnionPath
{
Path path;
Path *leftpath; /* paths representing input sources */
Path *rightpath;
List *distinctList; /* SortGroupClauses identifying target cols */ int wtParam; /* ID of Param representing work table */
Cardinality numGroups; /* estimated number of groups in input */
} RecursiveUnionPath;
/* *LockRowsPathrepresentsacquiringrowlocksforSELECTFORUPDATE/SHARE
*/ typedefstruct LockRowsPath
{
Path path;
Path *subpath; /* path representing input source */
List *rowMarks; /* a list of PlanRowMark's */ int epqParam; /* ID of Param for EvalPlanQual re-eval */
} LockRowsPath;
/* *ModifyTablePathrepresentsperformingINSERT/UPDATE/DELETE/MERGE * *WerepresentmostthingsthatwillbeintheModifyTableplannode *literally,exceptwehaveachildPathnotPlan.Butanalysisofthe *OnConflictExprisdeferredtocreateplan.c,asiscollectionofFDWdata.
*/ typedefstruct ModifyTablePath
{
Path path;
Path *subpath; /* Path producing source data */
CmdType operation; /* INSERT, UPDATE, DELETE, or MERGE */ bool canSetTag; /* do we set the command tag/es_processed? */
Index nominalRelation; /* Parent RT index for use of EXPLAIN */
Index rootRelation; /* Root RT index, if partitioned/inherited */ bool partColsUpdated; /* some part key in hierarchy updated? */
List *resultRelations; /* integer list of RT indexes */
List *updateColnosLists; /* per-target-table update_colnos lists */
List *withCheckOptionLists; /* per-target-table WCO lists */
List *returningLists; /* per-target-table RETURNING tlists */
List *rowMarks; /* PlanRowMarks (non-locking only) */
OnConflictExpr *onconflict; /* ON CONFLICT clause, or NULL */ int epqParam; /* ID of Param for EvalPlanQual re-eval */
List *mergeActionLists; /* per-target-table lists of actions for
* MERGE */
List *mergeJoinConditions; /* per-target-table join conditions
* for MERGE */
} ModifyTablePath;
/* *LimitPathrepresentsapplyingLIMIT/OFFSETrestrictions
*/ typedefstruct LimitPath
{
Path path;
Path *subpath; /* path representing input source */
Node *limitOffset; /* OFFSET parameter, or NULL if none */
Node *limitCount; /* COUNT parameter, or NULL if none */
LimitOption limitOption; /* FETCH FIRST with ties or exact number */
} LimitPath;
/* eval cost of clause; -1 if not yet set */
QualCost eval_cost pg_node_attr(equal_ignore);
/* selectivity for "normal" (JOIN_INNER) semantics; -1 if not yet set */
Selectivity norm_selec pg_node_attr(equal_ignore); /* selectivity for outer join semantics; -1 if not yet set */
Selectivity outer_selec pg_node_attr(equal_ignore);
/* *opfamiliescontainingclauseoperator;validifclauseis *mergejoinable,elseNIL
*/
List *mergeopfamilies pg_node_attr(equal_ignore);
/* *copyofclauseoperator;validifclauseishashjoinable,else *InvalidOid
*/
Oid hashjoinoperator pg_node_attr(equal_ignore);
/* *cachespaceforhashclauseprocessing;-1ifnotyetset
*/ /* avg bucketsize of left side */
Selectivity left_bucketsize pg_node_attr(equal_ignore); /* avg bucketsize of right side */
Selectivity right_bucketsize pg_node_attr(equal_ignore); /* left side's most common val's freq */
Selectivity left_mcvfreq pg_node_attr(equal_ignore); /* right side's most common val's freq */
Selectivity right_mcvfreq pg_node_attr(equal_ignore);
/* hash equality operators used for memoize nodes, else InvalidOid */
Oid left_hasheqoperator pg_node_attr(equal_ignore);
Oid right_hasheqoperator pg_node_attr(equal_ignore);
} RestrictInfo;
/* *Sincemergejoinscansel()isarelativelyexpensivefunction,andwould *otherwisebeinvokedmanytimeswhileplanningalargejointree, *wegooutofourwaytocacheitsresults.Eachmergejoinable *RestrictInfocarriesalistofthespecificsortorderingsthathave *beenconsideredforusewithit,andtheresultingselectivities.
*/ typedefstruct MergeScanSelCache
{ /* Ordering details (cache lookup key) */
Oid opfamily; /* index opfamily defining the ordering */
Oid collation; /* collation for the ordering */
CompareType cmptype; /* sort direction (ASC or DESC) */ bool nulls_first; /* do NULLs come before normal values? */ /* Results */
Selectivity leftstartsel; /* first-join fraction for clause left side */
Selectivity leftendsel; /* last-join fraction for clause left side */
Selectivity rightstartsel; /* first-join fraction for clause right side */
Selectivity rightendsel; /* last-join fraction for clause right side */
} MergeScanSelCache;
NodeTag type;
Relids min_lefthand; /* base+OJ relids in minimum LHS for join */
Relids min_righthand; /* base+OJ relids in minimum RHS for join */
Relids syn_lefthand; /* base+OJ relids syntactically within LHS */
Relids syn_righthand; /* base+OJ relids syntactically within RHS */
JoinType jointype; /* always INNER, LEFT, FULL, SEMI, or ANTI */
Index ojrelid; /* outer join's RT index; 0 if none */
Relids commute_above_l; /* commuting OJs above this one, if LHS */
Relids commute_above_r; /* commuting OJs above this one, if RHS */
Relids commute_below_l; /* commuting OJs in this one's LHS */
Relids commute_below_r; /* commuting OJs in this one's RHS */ bool lhs_strict; /* joinclause is strict for some LHS rel */ /* Remaining fields are set only for JOIN_SEMI jointype: */ bool semi_can_btree; /* true if semi_operators are all btree */ bool semi_can_hash; /* true if semi_operators are all hash */
List *semi_operators; /* OIDs of equality join operators */
List *semi_rhs_exprs; /* righthand-side expressions of these ops */
};
/* *Thesefieldsuniquelyidentifythisappendrelationship.Therecanbe *(infact,alwaysshouldbe)multipleAppendRelInfosforthesame *parent_relid,butnevermorethanoneperchild_relid,sinceagiven *RTEcannotbeachildofmorethanoneappendparent.
*/
Index parent_relid; /* RT index of append parent rel */
Index child_relid; /* RT index of append child rel */
/* *Foraninheritanceappendrel,theparentandchildarebothregular *relations,andwestoretheirrowtypeOIDshereforuseintranslating *whole-rowVars.ForaUNION-ALLappendrel,theparentandchildare *bothsubquerieswithnonamedrowtype,andwestoreInvalidOidhere.
*/
Oid parent_reltype; /* OID of parent's composite type */
Oid child_reltype; /* OID of child's composite type */
/* *TheN'thelementofthislistisaVarorexpressionrepresentingthe *childcolumncorrespondingtotheN'thcolumnoftheparent.Thisis *usedtotranslateVarsreferencingtheparentrelintoreferencesto *thechild.AlistelementisNULLifitcorrespondstoadropped *columnoftheparent(thisisonlypossibleforinheritancecases,not *UNIONALL).ThelistelementsarealwayssimpleVarsforinheritance *cases,butcanbearbitraryexpressionsinUNIONALLcases. * *Noticeweonlystoreentriesforusercolumns(attno>0).Whole-row *Varsarespecial-cased,andsystemcolumns(attno<0)neednospecial *translationsincetheirattnosarethesameforalltables. * *Caution:theVarshavevarlevelsup=0.Becarefultoadjustasneeded *whencopyingintoasubquery.
*/
List *translated_vars; /* Expressions in the child's Vars */
/* *Thisarraysimplifiestranslationsinthereversedirection,from *child'scolumnnumberstoparent's.Theentryat[ccolno-1]isthe *1-basedparentcolumnnumberforchildcolumnccolno,orzeroifthat *childcolumnisdroppedordoesn'texistintheparent.
*/ int num_child_cols; /* length of array */
AttrNumber *parent_colnos pg_node_attr(array_size(num_child_cols));
/* *Westoretheparenttable'sOIDhereforinheritance,orInvalidOidfor *UNIONALL.Thisisonlyneededtohelpingeneratingerrormessagesif *anattemptismadetoreferenceadroppedparentcolumn.
*/
Oid parent_reloid; /* OID of parent relation */
} AppendRelInfo;
Var *rowidvar; /* Var to be evaluated (but varno=ROWID_VAR) */
int32 rowidwidth; /* estimated average width */ char *rowidname; /* name of the resjunk column */
Relids rowidrels; /* RTE indexes of target rels using this */
} RowIdentityVarInfo;
/* *Structforextrainformationpassedtosubroutinesofcreate_grouping_paths * *flagsindicatingwhatkindsofgroupingarepossible. *partial_costs_setistrueiftheagg_partial_costsandagg_final_costs *havebeeninitialized. *agg_partial_costsgivespartialaggregationcosts. *agg_final_costsgivesfinalizationcosts. *target_parallel_safeistrueiftargetisparallelsafe. *havingQualgiveslistofqualstobeappliedafteraggregation. *targetListgiveslistofcolumnstobeprojected. *patypeisthetypeofpartitionwiseaggregationthatisbeingperformed.
*/ typedefstruct
{ /* Data which remains constant once set. */ int flags; bool partial_costs_set;
AggClauseCosts agg_partial_costs;
AggClauseCosts agg_final_costs;
/* Data which may differ across partitions. */ bool target_parallel_safe;
Node *havingQual;
List *targetList;
PartitionwiseAggregateType patype;
} GroupPathExtraData;
/* *Forspeedreasons,costestimationforjoinpathsisperformedintwo *phases:thefirstphasetriestoquicklyderivealowerboundforthe *joincost,andthenwecheckifthat'ssufficienttorejectthepath. *Ifnot,wecomebackforamorerefinedcostestimate.Thefirstphase *fillsaJoinCostWorkspacestructwithitspreliminarycostestimates *andpossiblyadditionalintermediatevalues.Thesecondphasetakes *thesevaluesasinputstoavoidrepeatingwork. * *(Ideallywe'ddeclarethisincost.h,butit'salsoneededinpathnode.h, *soseemsbesttoputithere.)
*/ typedefstruct JoinCostWorkspace
{ /* Preliminary cost estimates --- must not be larger than final ones! */ int disabled_nodes;
Cost startup_cost; /* cost expended before fetching any tuples */
Cost total_cost; /* total cost (assuming all tuples fetched) */
/* Fields below here should be treated as private to costsize.c */
Cost run_cost; /* non-startup cost components */
/* private for cost_nestloop code */
Cost inner_run_cost; /* also used by cost_mergejoin code */
Cost inner_rescan_run_cost;
/* *Additionalclausesfromabaserestrictinfolistthatwereusedtoprove *theuniqueness.Wecacheitfortheself-joincheckingprocedure:a *self-joincanberemovediftheouterrelationcontainsstrictlythe *samesetofclauses.
*/
List *extra_clauses;
} UniqueRelInfo;
#endif/* PATHNODES_H */
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.225Bemerkung:
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.