1 /*-------------------------------------------------------------------------
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
12 *-------------------------------------------------------------------------
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
,
73 extern void cost_valuesscan(Path
*path
, PlannerInfo
*root
,
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
,
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
,
88 extern void cost_group(Path
*path
, PlannerInfo
*root
,
89 int numGroupCols
, double numGroups
,
90 Cost input_startup_cost
, Cost input_total_cost
,
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
,
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
,
113 * prototypes for clausesel.c
114 * routines to compute clause selectivities
116 extern Selectivity
clauselist_selectivity(PlannerInfo
*root
,
120 SpecialJoinInfo
*sjinfo
);
121 extern Selectivity
clause_selectivity(PlannerInfo
*root
,
125 SpecialJoinInfo
*sjinfo
);