1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* cost.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* prototypes for costsize.c and clausesel.c.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*
|
2007-01-05 23:20:05 +01:00
|
|
|
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2007-09-22 23:36:40 +02:00
|
|
|
* $PostgreSQL: pgsql/src/include/optimizer/cost.h,v 1.89 2007/09/22 21:36:40 tgl Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef COST_H
|
|
|
|
#define COST_H
|
|
|
|
|
2002-11-21 01:42:20 +01:00
|
|
|
#include "nodes/plannodes.h"
|
1997-11-26 02:14:33 +01:00
|
|
|
#include "nodes/relation.h"
|
|
|
|
|
2002-11-21 01:42:20 +01:00
|
|
|
|
2000-01-23 03:07:00 +01:00
|
|
|
/* defaults for costsize.c's Cost parameters */
|
2000-02-15 21:49:31 +01:00
|
|
|
/* NB: cost-estimation code should use the variables, not these constants! */
|
2001-01-24 19:37:31 +01:00
|
|
|
/* If you change these, update backend/utils/misc/postgresql.sample.conf */
|
2006-06-05 04:49:58 +02:00
|
|
|
#define DEFAULT_SEQ_PAGE_COST 1.0
|
2000-02-15 21:49:31 +01:00
|
|
|
#define DEFAULT_RANDOM_PAGE_COST 4.0
|
2000-04-12 19:17:23 +02:00
|
|
|
#define DEFAULT_CPU_TUPLE_COST 0.01
|
2006-06-05 05:03:42 +02:00
|
|
|
#define DEFAULT_CPU_INDEX_TUPLE_COST 0.005
|
2000-02-15 21:49:31 +01:00
|
|
|
#define DEFAULT_CPU_OPERATOR_COST 0.0025
|
2000-01-23 03:07:00 +01:00
|
|
|
|
2006-10-04 02:30:14 +02:00
|
|
|
#define DEFAULT_EFFECTIVE_CACHE_SIZE 16384 /* measured in pages */
|
2006-06-05 04:49:58 +02:00
|
|
|
|
1999-07-15 17:21:54 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/*
|
1999-02-14 00:22:53 +01:00
|
|
|
* prototypes for costsize.c
|
1997-09-07 07:04:48 +02:00
|
|
|
* routines to compute costs and sizes
|
|
|
|
*/
|
2000-01-23 00:50:30 +01:00
|
|
|
|
2000-02-15 21:49:31 +01:00
|
|
|
/* parameter variables and flags */
|
2007-07-25 14:22:54 +02:00
|
|
|
extern PGDLLIMPORT double seq_page_cost;
|
|
|
|
extern PGDLLIMPORT double random_page_cost;
|
|
|
|
extern PGDLLIMPORT double cpu_tuple_cost;
|
|
|
|
extern PGDLLIMPORT double cpu_index_tuple_cost;
|
|
|
|
extern PGDLLIMPORT double cpu_operator_cost;
|
|
|
|
extern PGDLLIMPORT int effective_cache_size;
|
2000-01-23 00:50:30 +01:00
|
|
|
extern Cost disable_cost;
|
|
|
|
extern bool enable_seqscan;
|
|
|
|
extern bool enable_indexscan;
|
2005-04-21 21:18:13 +02:00
|
|
|
extern bool enable_bitmapscan;
|
2000-01-23 00:50:30 +01:00
|
|
|
extern bool enable_tidscan;
|
|
|
|
extern bool enable_sort;
|
2002-11-21 01:42:20 +01:00
|
|
|
extern bool enable_hashagg;
|
2000-01-23 00:50:30 +01:00
|
|
|
extern bool enable_nestloop;
|
|
|
|
extern bool enable_mergejoin;
|
|
|
|
extern bool enable_hashjoin;
|
2005-08-22 19:35:03 +02:00
|
|
|
extern bool constraint_exclusion;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2004-01-05 06:07:36 +01:00
|
|
|
extern double clamp_row_est(double nrows);
|
2006-06-06 19:59:58 +02:00
|
|
|
extern double index_pages_fetched(double tuples_fetched, BlockNumber pages,
|
2006-10-04 02:30:14 +02:00
|
|
|
double index_pages, PlannerInfo *root);
|
2005-06-06 00:32:58 +02:00
|
|
|
extern void cost_seqscan(Path *path, PlannerInfo *root, RelOptInfo *baserel);
|
|
|
|
extern void cost_index(IndexPath *path, PlannerInfo *root, IndexOptInfo *index,
|
2006-06-06 19:59:58 +02:00
|
|
|
List *indexQuals, RelOptInfo *outer_rel);
|
2005-06-06 00:32:58 +02:00
|
|
|
extern void cost_bitmap_heap_scan(Path *path, PlannerInfo *root, RelOptInfo *baserel,
|
2006-07-22 17:41:56 +02:00
|
|
|
Path *bitmapqual, RelOptInfo *outer_rel);
|
2005-06-06 00:32:58 +02:00
|
|
|
extern void cost_bitmap_and_node(BitmapAndPath *path, PlannerInfo *root);
|
|
|
|
extern void cost_bitmap_or_node(BitmapOrPath *path, PlannerInfo *root);
|
2005-04-22 23:58:32 +02:00
|
|
|
extern void cost_bitmap_tree_node(Path *path, Cost *cost, Selectivity *selec);
|
2005-06-06 00:32:58 +02:00
|
|
|
extern void cost_tidscan(Path *path, PlannerInfo *root,
|
2005-11-26 23:14:57 +01:00
|
|
|
RelOptInfo *baserel, List *tidquals);
|
2003-07-15 00:35:54 +02:00
|
|
|
extern void cost_subqueryscan(Path *path, RelOptInfo *baserel);
|
2005-06-06 00:32:58 +02:00
|
|
|
extern void cost_functionscan(Path *path, PlannerInfo *root,
|
2002-09-04 22:31:48 +02:00
|
|
|
RelOptInfo *baserel);
|
2006-08-02 03:59:48 +02:00
|
|
|
extern void cost_valuesscan(Path *path, PlannerInfo *root,
|
2006-10-04 02:30:14 +02:00
|
|
|
RelOptInfo *baserel);
|
2005-06-06 00:32:58 +02:00
|
|
|
extern void cost_sort(Path *path, PlannerInfo *root,
|
2007-05-04 03:13:45 +02:00
|
|
|
List *pathkeys, Cost input_cost, double tuples, int width,
|
|
|
|
double limit_tuples);
|
2007-05-21 19:57:35 +02:00
|
|
|
extern bool sort_exceeds_work_mem(Sort *sort);
|
2002-11-30 06:21:03 +01:00
|
|
|
extern void cost_material(Path *path,
|
2003-08-04 02:43:34 +02:00
|
|
|
Cost input_cost, double tuples, int width);
|
2005-06-06 00:32:58 +02:00
|
|
|
extern void cost_agg(Path *path, PlannerInfo *root,
|
2003-08-04 02:43:34 +02:00
|
|
|
AggStrategy aggstrategy, int numAggs,
|
|
|
|
int numGroupCols, double numGroups,
|
|
|
|
Cost input_startup_cost, Cost input_total_cost,
|
|
|
|
double input_tuples);
|
2005-06-06 00:32:58 +02:00
|
|
|
extern void cost_group(Path *path, PlannerInfo *root,
|
2003-08-04 02:43:34 +02:00
|
|
|
int numGroupCols, double numGroups,
|
|
|
|
Cost input_startup_cost, Cost input_total_cost,
|
|
|
|
double input_tuples);
|
2005-06-06 00:32:58 +02:00
|
|
|
extern void cost_nestloop(NestPath *path, PlannerInfo *root);
|
|
|
|
extern void cost_mergejoin(MergePath *path, PlannerInfo *root);
|
|
|
|
extern void cost_hashjoin(HashPath *path, PlannerInfo *root);
|
2007-02-22 23:00:26 +01:00
|
|
|
extern void cost_qual_eval(QualCost *cost, List *quals, PlannerInfo *root);
|
|
|
|
extern void cost_qual_eval_node(QualCost *cost, Node *qual, PlannerInfo *root);
|
2007-09-22 23:36:40 +02:00
|
|
|
extern Cost get_initplan_cost(PlannerInfo *root, SubPlan *subplan);
|
2005-06-06 00:32:58 +02:00
|
|
|
extern void set_baserel_size_estimates(PlannerInfo *root, RelOptInfo *rel);
|
|
|
|
extern void set_joinrel_size_estimates(PlannerInfo *root, RelOptInfo *rel,
|
2000-04-12 19:17:23 +02:00
|
|
|
RelOptInfo *outer_rel,
|
|
|
|
RelOptInfo *inner_rel,
|
2001-02-16 01:03:08 +01:00
|
|
|
JoinType jointype,
|
2000-04-12 19:17:23 +02:00
|
|
|
List *restrictlist);
|
2005-06-06 00:32:58 +02:00
|
|
|
extern void set_function_size_estimates(PlannerInfo *root, RelOptInfo *rel);
|
2006-08-02 03:59:48 +02:00
|
|
|
extern void set_values_size_estimates(PlannerInfo *root, RelOptInfo *rel);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
|
|
|
/*
|
2000-01-09 01:26:47 +01:00
|
|
|
* prototypes for clausesel.c
|
1997-09-07 07:04:48 +02:00
|
|
|
* routines to compute clause selectivities
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2005-06-06 00:32:58 +02:00
|
|
|
extern Selectivity clauselist_selectivity(PlannerInfo *root,
|
2003-08-04 02:43:34 +02:00
|
|
|
List *clauses,
|
|
|
|
int varRelid,
|
|
|
|
JoinType jointype);
|
2005-06-06 00:32:58 +02:00
|
|
|
extern Selectivity clause_selectivity(PlannerInfo *root,
|
2003-08-04 02:43:34 +02:00
|
|
|
Node *clause,
|
|
|
|
int varRelid,
|
|
|
|
JoinType jointype);
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* COST_H */
|