Fix obsolete comment regarding FSM truncation.
[PostgreSQL.git] / src / include / optimizer / cost.h
blobda11d5822e86ab436ce989d0c1fac82c617058a9
1 /*-------------------------------------------------------------------------
3 * cost.h
4 * prototypes for costsize.c and clausesel.c.
7 * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * $PostgreSQL$
12 *-------------------------------------------------------------------------
14 #ifndef COST_H
15 #define COST_H
17 #include "nodes/plannodes.h"
18 #include "nodes/relation.h"
21 /* defaults for costsize.c's Cost parameters */
22 /* NB: cost-estimation code should use the variables, not these constants! */
23 /* If you change these, update backend/utils/misc/postgresql.sample.conf */
24 #define DEFAULT_SEQ_PAGE_COST 1.0
25 #define DEFAULT_RANDOM_PAGE_COST 4.0
26 #define DEFAULT_CPU_TUPLE_COST 0.01
27 #define DEFAULT_CPU_INDEX_TUPLE_COST 0.005
28 #define DEFAULT_CPU_OPERATOR_COST 0.0025
30 #define DEFAULT_EFFECTIVE_CACHE_SIZE 16384 /* measured in pages */
34 * prototypes for costsize.c
35 * routines to compute costs and sizes
38 /* parameter variables and flags */
39 extern PGDLLIMPORT double seq_page_cost;
40 extern PGDLLIMPORT double random_page_cost;
41 extern PGDLLIMPORT double cpu_tuple_cost;
42 extern PGDLLIMPORT double cpu_index_tuple_cost;
43 extern PGDLLIMPORT double cpu_operator_cost;
44 extern PGDLLIMPORT int effective_cache_size;
45 extern Cost disable_cost;
46 extern bool enable_seqscan;
47 extern bool enable_indexscan;
48 extern bool enable_bitmapscan;
49 extern bool enable_tidscan;
50 extern bool enable_sort;
51 extern bool enable_hashagg;
52 extern bool enable_nestloop;
53 extern bool enable_mergejoin;
54 extern bool enable_hashjoin;
55 extern bool constraint_exclusion;
57 extern double clamp_row_est(double nrows);
58 extern double index_pages_fetched(double tuples_fetched, BlockNumber pages,
59 double index_pages, PlannerInfo *root);
60 extern void cost_seqscan(Path *path, PlannerInfo *root, RelOptInfo *baserel);
61 extern void cost_index(IndexPath *path, PlannerInfo *root, IndexOptInfo *index,
62 List *indexQuals, RelOptInfo *outer_rel);
63 extern void cost_bitmap_heap_scan(Path *path, PlannerInfo *root, RelOptInfo *baserel,
64 Path *bitmapqual, RelOptInfo *outer_rel);
65 extern void cost_bitmap_and_node(BitmapAndPath *path, PlannerInfo *root);
66 extern void cost_bitmap_or_node(BitmapOrPath *path, PlannerInfo *root);
67 extern void cost_bitmap_tree_node(Path *path, Cost *cost, Selectivity *selec);
68 extern void cost_tidscan(Path *path, PlannerInfo *root,
69 RelOptInfo *baserel, List *tidquals);
70 extern void cost_subqueryscan(Path *path, RelOptInfo *baserel);
71 extern void cost_functionscan(Path *path, PlannerInfo *root,
72 RelOptInfo *baserel);
73 extern void cost_valuesscan(Path *path, PlannerInfo *root,
74 RelOptInfo *baserel);
75 extern void cost_ctescan(Path *path, PlannerInfo *root, RelOptInfo *baserel);
76 extern void cost_recursive_union(Plan *runion, Plan *nrterm, Plan *rterm);
77 extern void cost_sort(Path *path, PlannerInfo *root,
78 List *pathkeys, Cost input_cost, double tuples, int width,
79 double limit_tuples);
80 extern bool sort_exceeds_work_mem(Sort *sort);
81 extern void cost_material(Path *path,
82 Cost input_cost, double tuples, int width);
83 extern void cost_agg(Path *path, PlannerInfo *root,
84 AggStrategy aggstrategy, int numAggs,
85 int numGroupCols, double numGroups,
86 Cost input_startup_cost, Cost input_total_cost,
87 double input_tuples);
88 extern void cost_group(Path *path, PlannerInfo *root,
89 int numGroupCols, double numGroups,
90 Cost input_startup_cost, Cost input_total_cost,
91 double input_tuples);
92 extern void cost_nestloop(NestPath *path, PlannerInfo *root,
93 SpecialJoinInfo *sjinfo);
94 extern void cost_mergejoin(MergePath *path, PlannerInfo *root,
95 SpecialJoinInfo *sjinfo);
96 extern void cost_hashjoin(HashPath *path, PlannerInfo *root,
97 SpecialJoinInfo *sjinfo);
98 extern void cost_subplan(PlannerInfo *root, SubPlan *subplan, Plan *plan);
99 extern void cost_qual_eval(QualCost *cost, List *quals, PlannerInfo *root);
100 extern void cost_qual_eval_node(QualCost *cost, Node *qual, PlannerInfo *root);
101 extern void set_baserel_size_estimates(PlannerInfo *root, RelOptInfo *rel);
102 extern void set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
103 RelOptInfo *outer_rel,
104 RelOptInfo *inner_rel,
105 SpecialJoinInfo *sjinfo,
106 List *restrictlist);
107 extern void set_function_size_estimates(PlannerInfo *root, RelOptInfo *rel);
108 extern void set_values_size_estimates(PlannerInfo *root, RelOptInfo *rel);
109 extern void set_cte_size_estimates(PlannerInfo *root, RelOptInfo *rel,
110 Plan *cteplan);
113 * prototypes for clausesel.c
114 * routines to compute clause selectivities
116 extern Selectivity clauselist_selectivity(PlannerInfo *root,
117 List *clauses,
118 int varRelid,
119 JoinType jointype,
120 SpecialJoinInfo *sjinfo);
121 extern Selectivity clause_selectivity(PlannerInfo *root,
122 Node *clause,
123 int varRelid,
124 JoinType jointype,
125 SpecialJoinInfo *sjinfo);
127 #endif /* COST_H */