1/*-------------------------------------------------------------------------
4 * External API for the Postgres planner.
6 * This header is meant to define everything that the core planner
7 * exposes for use by non-planner modules.
9 * Note that there are files outside src/backend/optimizer/ that are
10 * considered planner modules, because they're too much in bed with
11 * planner operations to be treated otherwise. FDW planning code is an
12 * example. For the most part, however, code outside the core planner
13 * should not need to include any optimizer/ header except this one.
15 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
16 * Portions Copyright (c) 1994, Regents of the University of California
18 * src/include/optimizer/optimizer.h
20 *-------------------------------------------------------------------------
28 * We don't want to include nodes/pathnodes.h here, because non-planner
29 * code should generally treat PlannerInfo as an opaque typedef.
30 * But we'd like such code to use that typedef name, so define the
31 * typedef both here and in pathnodes.h.
37/* It also seems best not to include plannodes.h, params.h, or htup.h here */
43/* in path/clausesel.c: */
55 bool use_extended_stats);
66 bool use_extended_stats);
68/* in path/costsize.c: */
70/* widely used cost parameters */
85/* in path/indxpath.c: */
90/* in plan/planner.c: */
92/* possible values for debug_parallel_query */
117/* in plan/setrefs.c: */
122 bool *hasRowSecurity);
124/* in prep/prepqual.c: */
129/* in util/clauses.c: */
144 Oid result_collation);
153 Oid coltype,
Oid arraycollid,
157/* in util/predtest.c: */
164/* in util/tlist.c: */
182/* Bits that can be OR'd into the flags argument of pull_var_clause() */
183 #define PVC_INCLUDE_AGGREGATES 0x0001 /* include Aggrefs in output list */
184 #define PVC_RECURSE_AGGREGATES 0x0002 /* recurse into Aggref arguments */
185 #define PVC_INCLUDE_WINDOWFUNCS 0x0004 /* include WindowFuncs in output list */
186 #define PVC_RECURSE_WINDOWFUNCS 0x0008 /* recurse into WindowFunc arguments */
187 #define PVC_INCLUDE_PLACEHOLDERS 0x0010 /* include PlaceHolderVars in
189 #define PVC_RECURSE_PLACEHOLDERS 0x0020 /* recurse into PlaceHolderVar
191#define PVC_INCLUDE_CONVERTROWTYPES 0x0040 /* include ConvertRowtypeExprs in
206#endif /* OPTIMIZER_H */
PGDLLIMPORT double cpu_operator_cost
bool contain_volatile_functions_not_nextval(Node *clause)
PGDLLIMPORT bool parallel_leader_participation
Expr * canonicalize_qual(Expr *qual, bool is_check)
Expr * expression_planner_with_deps(Expr *expr, List **relationOids, List **invalItems)
struct HeapTupleData * HeapTuple
Selectivity clause_selectivity_ext(PlannerInfo *root, Node *clause, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo, bool use_extended_stats)
bool predicate_refuted_by(List *predicate_list, List *clause_list, bool weak)
Bitmapset * pull_varnos(PlannerInfo *root, Node *node)
PlannedStmt * planner(Query *parse, const char *query_string, int cursorOptions, ParamListInfo boundParams)
bool contain_vars_of_level(Node *node, int levelsup)
Node * flatten_group_exprs(PlannerInfo *root, Query *query, Node *node)
PGDLLIMPORT bool enable_distinct_reordering
bool contain_var_clause(Node *node)
SortGroupClause * get_sortgroupref_clause_noerr(Index sortref, List *clauses)
bool is_pseudo_constant_for_index(PlannerInfo *root, Node *expr, IndexOptInfo *index)
bool plan_cluster_use_sort(Oid tableOid, Oid indexOid)
PGDLLIMPORT double parallel_tuple_cost
bool contain_mutable_functions(Node *clause)
SortGroupClause * get_sortgroupref_clause(Index sortref, List *clauses)
Node * estimate_expression_value(PlannerInfo *root, Node *node)
int plan_create_index_workers(Oid tableOid, Oid indexOid)
PGDLLIMPORT double parallel_setup_cost
Selectivity clauselist_selectivity(PlannerInfo *root, List *clauses, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
List * pull_vars_of_level(Node *node, int levelsup)
List * pull_var_clause(Node *node, int flags)
Node * eval_const_expressions(PlannerInfo *root, Node *node)
bool contain_volatile_functions_after_planning(Expr *expr)
Bitmapset * pull_varnos_of_level(PlannerInfo *root, Node *node, int levelsup)
PGDLLIMPORT int debug_parallel_query
bool contain_mutable_functions_after_planning(Expr *expr)
TargetEntry * get_sortgroupclause_tle(SortGroupClause *sgClause, List *targetList)
Selectivity clauselist_selectivity_ext(PlannerInfo *root, List *clauses, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo, bool use_extended_stats)
Node * flatten_join_alias_vars(PlannerInfo *root, Query *query, Node *node)
struct ParamListInfoData * ParamListInfo
Node * negate_clause(Node *node)
void convert_saop_to_hashed_saop(Node *node)
PGDLLIMPORT double cpu_tuple_cost
List * get_sortgrouplist_exprs(List *sgClauses, List *targetList)
bool predicate_implied_by(List *predicate_list, List *clause_list, bool weak)
List * expand_function_arguments(List *args, bool include_out_arguments, Oid result_type, HeapTuple func_tuple)
PGDLLIMPORT double recursive_worktable_factor
TargetEntry * get_sortgroupref_tle(Index sortref, List *targetList)
void extract_query_dependencies(Node *query, List **relationOids, List **invalItems, bool *hasRowSecurity)
Expr * expression_planner(Expr *expr)
PGDLLIMPORT double cpu_index_tuple_cost
int count_nonjunk_tlist_entries(List *tlist)
void pull_varattnos(Node *node, Index varno, Bitmapset **varattnos)
PGDLLIMPORT double seq_page_cost
int locate_var_of_level(Node *node, int levelsup)
double clamp_row_est(double nrows)
PGDLLIMPORT int effective_cache_size
long clamp_cardinality_to_long(Cardinality x)
PGDLLIMPORT double random_page_cost
ScalarArrayOpExpr * make_SAOP_expr(Oid oper, Node *leftexpr, Oid coltype, Oid arraycollid, Oid inputcollid, List *exprs, bool haveNonConst)
bool contain_vars_returning_old_or_new(Node *node)
int32 clamp_width_est(int64 tuple_width)
Expr * evaluate_expr(Expr *expr, Oid result_type, int32 result_typmod, Oid result_collation)
bool contain_volatile_functions(Node *clause)
bool var_is_nonnullable(PlannerInfo *root, Var *var, bool use_rel_info)
Node * get_sortgroupclause_expr(SortGroupClause *sgClause, List *targetList)
Selectivity clause_selectivity(PlannerInfo *root, Node *clause, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
Operator oper(ParseState *pstate, List *opname, Oid ltypeId, Oid rtypeId, bool noError, int location)
static struct subre * parse(struct vars *v, int stopper, int type, struct state *init, struct state *final)