0006-Add-cache_page_cost-GUC.patch
text/x-patch
Filename: 0006-Add-cache_page_cost-GUC.patch
Type: text/x-patch
Part: 5
From 4bea6a4d150b694f3d16546ec865e4be948745ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Villemain?= <cedric@2ndquadrant.fr>
Date: Thu, 2 Jun 2011 02:28:01 +0200
Subject: [PATCH 6/7] Add cache_page_cost GUC
this is used to improve cache estimate and impact in IO cost estimations
---
doc/src/sgml/config.sgml | 13 +++++++++++++
src/backend/optimizer/path/costsize.c | 1 +
src/backend/utils/misc/guc.c | 10 ++++++++++
src/backend/utils/misc/postgresql.conf.sample | 1 +
src/include/optimizer/cost.h | 2 ++
5 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
new file mode 100644
index e835e4b..8bc5560
*** a/doc/src/sgml/config.sgml
--- b/doc/src/sgml/config.sgml
*************** SET ENABLE_SEQSCAN TO OFF;
*** 2514,2519 ****
--- 2514,2532 ----
</listitem>
</varlistentry>
+ <varlistentry id="guc-cache-page-cost" xreflabel="cache_page_cost">
+ <term><varname>cache_page_cost</varname> (<type>floating point</type>)</term>
+ <indexterm>
+ <primary><varname>cache_page_cost</> configuration parameter</primary>
+ </indexterm>
+ <listitem>
+ <para>
+ Sets the planner's estimate of the cost of a
+ fetched page from cache. The default is 0.1.
+ </para>
+ </listitem>
+ </varlistentry>
+
<varlistentry id="guc-cpu-tuple-cost" xreflabel="cpu_tuple_cost">
<term><varname>cpu_tuple_cost</varname> (<type>floating point</type>)</term>
<indexterm>
diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c
new file mode 100644
index bb38768..a80dc0c
*** a/src/backend/optimizer/path/costsize.c
--- b/src/backend/optimizer/path/costsize.c
***************
*** 100,105 ****
--- 100,106 ----
double seq_page_cost = DEFAULT_SEQ_PAGE_COST;
double random_page_cost = DEFAULT_RANDOM_PAGE_COST;
+ double cache_page_cost = DEFAULT_CACHE_PAGE_COST;
double cpu_tuple_cost = DEFAULT_CPU_TUPLE_COST;
double cpu_index_tuple_cost = DEFAULT_CPU_INDEX_TUPLE_COST;
double cpu_operator_cost = DEFAULT_CPU_OPERATOR_COST;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
new file mode 100644
index 92391ed..7465c08
*** a/src/backend/utils/misc/guc.c
--- b/src/backend/utils/misc/guc.c
*************** static struct config_real ConfigureNames
*** 2392,2397 ****
--- 2392,2407 ----
NULL, NULL, NULL
},
{
+ {"cache_page_cost", PGC_USERSET, QUERY_TUNING_COST,
+ gettext_noop("Sets the planner's estimate of the cost of a "
+ "fetched page from cache."),
+ NULL
+ },
+ &cache_page_cost,
+ DEFAULT_CACHE_PAGE_COST, 0, DBL_MAX,
+ NULL, NULL, NULL
+ },
+ {
{"cpu_tuple_cost", PGC_USERSET, QUERY_TUNING_COST,
gettext_noop("Sets the planner's estimate of the cost of "
"processing each tuple (row)."),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
new file mode 100644
index 655dad4..82159e1
*** a/src/backend/utils/misc/postgresql.conf.sample
--- b/src/backend/utils/misc/postgresql.conf.sample
***************
*** 233,238 ****
--- 233,239 ----
#seq_page_cost = 1.0 # measured on an arbitrary scale
#random_page_cost = 4.0 # same scale as above
+ #cache_page_cost = 0.1 # same scale as above
#cpu_tuple_cost = 0.01 # same scale as above
#cpu_index_tuple_cost = 0.005 # same scale as above
#cpu_operator_cost = 0.0025 # same scale as above
diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h
new file mode 100644
index 2763863..f4babd0
*** a/src/include/optimizer/cost.h
--- b/src/include/optimizer/cost.h
***************
*** 23,28 ****
--- 23,29 ----
/* If you change these, update backend/utils/misc/postgresql.sample.conf */
#define DEFAULT_SEQ_PAGE_COST 1.0
#define DEFAULT_RANDOM_PAGE_COST 4.0
+ #define DEFAULT_CACHE_PAGE_COST 0.1
#define DEFAULT_CPU_TUPLE_COST 0.01
#define DEFAULT_CPU_INDEX_TUPLE_COST 0.005
#define DEFAULT_CPU_OPERATOR_COST 0.0025
*************** typedef enum
*** 45,50 ****
--- 46,52 ----
/* parameter variables and flags */
extern PGDLLIMPORT double seq_page_cost;
extern PGDLLIMPORT double random_page_cost;
+ extern PGDLLIMPORT double cache_page_cost;
extern PGDLLIMPORT double cpu_tuple_cost;
extern PGDLLIMPORT double cpu_index_tuple_cost;
extern PGDLLIMPORT double cpu_operator_cost;
--
1.7.5.3