cost.h 2.8 KB
Newer Older
1 2
/*-------------------------------------------------------------------------
 *
3
 * cost.h
4
 *	  prototypes for costsize.c and clausesel.c.
5 6
 *
 *
B
Add:  
Bruce Momjian 已提交
7 8
 * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
 * Portions Copyright (c) 1994, Regents of the University of California
9
 *
10
 * $Id: cost.h,v 1.36 2001/01/24 18:37:31 momjian Exp $
11 12 13 14 15 16
 *
 *-------------------------------------------------------------------------
 */
#ifndef COST_H
#define COST_H

B
Bruce Momjian 已提交
17 18
#include "nodes/relation.h"

19
/* defaults for costsize.c's Cost parameters */
20
/* NB: cost-estimation code should use the variables, not these constants! */
21
/* If you change these, update backend/utils/misc/postgresql.sample.conf */
22 23
#define DEFAULT_EFFECTIVE_CACHE_SIZE  1000.0	/* measured in pages */
#define DEFAULT_RANDOM_PAGE_COST  4.0
24
#define DEFAULT_CPU_TUPLE_COST	0.01
25 26
#define DEFAULT_CPU_INDEX_TUPLE_COST 0.001
#define DEFAULT_CPU_OPERATOR_COST  0.0025
27

28 29 30 31 32
/* defaults for function attributes used for expensive function calculations */
#define BYTE_PCT 100
#define PERBYTE_CPU 0
#define PERCALL_CPU 0
#define OUTIN_RATIO 100
33

34

35
/*
36
 * prototypes for costsize.c
37 38
 *	  routines to compute costs and sizes
 */
39

40 41
/* parameter variables and flags */
extern double effective_cache_size;
42 43 44 45
extern double random_page_cost;
extern double cpu_tuple_cost;
extern double cpu_index_tuple_cost;
extern double cpu_operator_cost;
46 47 48 49 50 51 52 53
extern Cost disable_cost;
extern bool enable_seqscan;
extern bool enable_indexscan;
extern bool enable_tidscan;
extern bool enable_sort;
extern bool enable_nestloop;
extern bool enable_mergejoin;
extern bool enable_hashjoin;
54

55 56
extern void cost_seqscan(Path *path, RelOptInfo *baserel);
extern void cost_index(Path *path, Query *root,
57 58
		   RelOptInfo *baserel, IndexOptInfo *index,
		   List *indexQuals, bool is_injoin);
59 60 61
extern void cost_tidscan(Path *path, RelOptInfo *baserel, List *tideval);
extern void cost_sort(Path *path, List *pathkeys, double tuples, int width);
extern void cost_nestloop(Path *path, Path *outer_path, Path *inner_path,
62
			  List *restrictlist);
63
extern void cost_mergejoin(Path *path, Path *outer_path, Path *inner_path,
64 65
			   List *restrictlist,
			   List *outersortkeys, List *innersortkeys);
66
extern void cost_hashjoin(Path *path, Path *outer_path, Path *inner_path,
B
Bruce Momjian 已提交
67
			  List *restrictlist, Selectivity innerdispersion);
68
extern Cost cost_qual_eval(List *quals);
69 70
extern void set_baserel_size_estimates(Query *root, RelOptInfo *rel);
extern void set_joinrel_size_estimates(Query *root, RelOptInfo *rel,
71 72 73
						   RelOptInfo *outer_rel,
						   RelOptInfo *inner_rel,
						   List *restrictlist);
74 75

/*
76
 * prototypes for clausesel.c
77
 *	  routines to compute clause selectivities
78
 */
79
extern Selectivity restrictlist_selectivity(Query *root,
80 81
						 List *restrictinfo_list,
						 int varRelid);
82
extern Selectivity clauselist_selectivity(Query *root,
83 84
					   List *clauses,
					   int varRelid);
85

86
#endif	 /* COST_H */