0005-Add-reloscache-to-Index-Rel-OptInfo.patch
text/x-patch
Filename: 0005-Add-reloscache-to-Index-Rel-OptInfo.patch
Type: text/x-patch
Part: 4
From d742c0f1c16672c1632cea9936cc846c8b039187 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Villemain?= <cedric@2ndquadrant.fr>
Date: Thu, 2 Jun 2011 02:27:35 +0200
Subject: [PATCH 5/7] Add reloscache to (Index|Rel)OptInfo
So that costsize.c can use the values
---
src/backend/optimizer/util/plancat.c | 7 +++++++
src/include/nodes/relation.h | 2 ++
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
new file mode 100644
index b286816..a9aa4b1
*** a/src/backend/optimizer/util/plancat.c
--- b/src/backend/optimizer/util/plancat.c
*************** static List *get_relation_constraints(Pl
*** 64,69 ****
--- 64,70 ----
* indexlist list of IndexOptInfos for relation's indexes
* pages number of pages
* tuples number of tuples
+ * oscache density of page in cache
*
* Also, initialize the attr_needed[] and attr_widths[] arrays. In most
* cases these are left as zeroes, but sometimes we need to compute attr
*************** get_relation_info(PlannerInfo *root, Oid
*** 111,120 ****
--- 112,125 ----
* case the size will be computed later in set_append_rel_pathlist, and we
* must leave it zero for now to avoid bollixing the total_table_pages
* calculation.
+ * XXX: we need to handle oscache for inherited tables....check that
*/
if (!inhparent)
+ {
+ rel->oscache = (float4) relation->rd_rel->reloscache;
estimate_rel_size(relation, rel->attr_widths - rel->min_attr,
&rel->pages, &rel->tuples);
+ }
/*
* Make list of indexes. Ignore indexes on system catalogs if told to.
*************** get_relation_info(PlannerInfo *root, Oid
*** 327,337 ****
--- 332,344 ----
*/
if (info->indpred == NIL)
{
+ info->oscache = (float4) indexRelation->rd_rel->reloscache;
info->pages = RelationGetNumberOfBlocks(indexRelation);
info->tuples = rel->tuples;
}
else
{
+ info->oscache = (float4) indexRelation->rd_rel->reloscache;
estimate_rel_size(indexRelation, NULL,
&info->pages, &info->tuples);
if (info->tuples > rel->tuples)
diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h
new file mode 100644
index f659269..e94b48b
*** a/src/include/nodes/relation.h
--- b/src/include/nodes/relation.h
*************** typedef struct RelOptInfo
*** 408,413 ****
--- 408,414 ----
List *indexlist; /* list of IndexOptInfo */
BlockNumber pages;
double tuples;
+ float4 oscache; /* density of the relation in cache */
struct Plan *subplan; /* if subquery */
List *subrtable; /* if subquery */
List *subrowmark; /* if subquery */
*************** typedef struct IndexOptInfo
*** 466,471 ****
--- 467,473 ----
/* statistics from pg_class */
BlockNumber pages; /* number of disk pages in index */
double tuples; /* number of index tuples in index */
+ float4 oscache; /* density of the relation in cache */
/* index descriptor information */
int ncolumns; /* number of columns in index */
--
1.7.5.3