Fix xslt_process() to ensure that it inserts a NULL terminator after the
[PostgreSQL.git] / src / include / optimizer / cost.h
blob11be226fe4b7b5af93e1aff45c03e1ba1a84efce
1 /*-------------------------------------------------------------------------
3 * cost.h
4 * prototypes for costsize.c and clausesel.c.
7 * Portions Copyright (c) 1996-2009, 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 */
32 typedef enum
34 CONSTRAINT_EXCLUSION_OFF, /* do not use c_e */
35 CONSTRAINT_EXCLUSION_ON, /* apply c_e to all rels */
36 CONSTRAINT_EXCLUSION_PARTITION /* apply c_e to otherrels only */
37 } ConstraintExclusionType;
41 * prototypes for costsize.c
42 * routines to compute costs and sizes
45 /* parameter variables and flags */
46 extern PGDLLIMPORT double seq_page_cost;
47 extern PGDLLIMPORT double random_page_cost;
48 extern PGDLLIMPORT double cpu_tuple_cost;
49 extern PGDLLIMPORT double cpu_index_tuple_cost;
50 extern PGDLLIMPORT double cpu_operator_cost;
51 extern PGDLLIMPORT int effective_cache_size;
52 extern Cost disable_cost;
53 extern bool enable_seqscan;
54 extern bool enable_indexscan;
55 extern bool enable_bitmapscan;
56 extern bool enable_tidscan;
57 extern bool enable_sort;
58 extern bool enable_hashagg;
59 extern bool enable_nestloop;
60 extern bool enable_mergejoin;
61 extern bool enable_hashjoin;
62 extern int constraint_exclusion;
64 extern double clamp_row_est(double nrows);
65 extern double index_pages_fetched(double tuples_fetched, BlockNumber pages,
66 double index_pages, PlannerInfo *root);
67 extern void cost_seqscan(Path *path, PlannerInfo *root, RelOptInfo *baserel);
68 extern void cost_index(IndexPath *path, PlannerInfo *root, IndexOptInfo *index,
69 List *indexQuals, RelOptInfo *outer_rel);
70 extern void cost_bitmap_heap_scan(Path *path, PlannerInfo *root, RelOptInfo *baserel,
71 Path *bitmapqual, RelOptInfo *outer_rel);
72 extern void cost_bitmap_and_node(BitmapAndPath *path, PlannerInfo *root);
73 extern void cost_bitmap_or_node(BitmapOrPath *path, PlannerInfo *root);
74 extern void cost_bitmap_tree_node(Path *path, Cost *cost, Selectivity *selec);
75 extern void cost_tidscan(Path *path, PlannerInfo *root,
76 RelOptInfo *baserel, List *tidquals);
77 extern void cost_subqueryscan(Path *path, RelOptInfo *baserel);
78 extern void cost_functionscan(Path *path, PlannerInfo *root,
79 RelOptInfo *baserel);
80 extern void cost_valuesscan(Path *path, PlannerInfo *root,
81 RelOptInfo *baserel);
82 extern void cost_ctescan(Path *path, PlannerInfo *root, RelOptInfo *baserel);
83 extern void cost_recursive_union(Plan *runion, Plan *nrterm, Plan *rterm);
84 extern void cost_sort(Path *path, PlannerInfo *root,
85 List *pathkeys, Cost input_cost, double tuples, int width,
86 double limit_tuples);
87 extern bool sort_exceeds_work_mem(Sort *sort);
88 extern void cost_material(Path *path,
89 Cost input_cost, double tuples, int width);
90 extern void cost_agg(Path *path, PlannerInfo *root,
91 AggStrategy aggstrategy, int numAggs,
92 int numGroupCols, double numGroups,
93 Cost input_startup_cost, Cost input_total_cost,
94 double input_tuples);
95 extern void cost_windowagg(Path *path, PlannerInfo *root,
96 int numWindowFuncs, int numPartCols, int numOrderCols,
97 Cost input_startup_cost, Cost input_total_cost,
98 double input_tuples);
99 extern void cost_group(Path *path, PlannerInfo *root,
100 int numGroupCols, double numGroups,
101 Cost input_startup_cost, Cost input_total_cost,
102 double input_tuples);
103 extern void cost_nestloop(NestPath *path, PlannerInfo *root,
104 SpecialJoinInfo *sjinfo);
105 extern void cost_mergejoin(MergePath *path, PlannerInfo *root,
106 SpecialJoinInfo *sjinfo);
107 extern void cost_hashjoin(HashPath *path, PlannerInfo *root,
108 SpecialJoinInfo *sjinfo);
109 extern void cost_subplan(PlannerInfo *root, SubPlan *subplan, Plan *plan);
110 extern void cost_qual_eval(QualCost *cost, List *quals, PlannerInfo *root);
111 extern void cost_qual_eval_node(QualCost *cost, Node *qual, PlannerInfo *root);
112 extern void set_baserel_size_estimates(PlannerInfo *root, RelOptInfo *rel);
113 extern void set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
114 RelOptInfo *outer_rel,
115 RelOptInfo *inner_rel,
116 SpecialJoinInfo *sjinfo,
117 List *restrictlist);
118 extern void set_function_size_estimates(PlannerInfo *root, RelOptInfo *rel);
119 extern void set_values_size_estimates(PlannerInfo *root, RelOptInfo *rel);
120 extern void set_cte_size_estimates(PlannerInfo *root, RelOptInfo *rel,
121 Plan *cteplan);
124 * prototypes for clausesel.c
125 * routines to compute clause selectivities
127 extern Selectivity clauselist_selectivity(PlannerInfo *root,
128 List *clauses,
129 int varRelid,
130 JoinType jointype,
131 SpecialJoinInfo *sjinfo);
132 extern Selectivity clause_selectivity(PlannerInfo *root,
133 Node *clause,
134 int varRelid,
135 JoinType jointype,
136 SpecialJoinInfo *sjinfo);
138 #endif /* COST_H */