diff options
author | Cédric Villemain | 2011-05-01 14:17:55 +0000 |
---|---|---|
committer | Cédric Villemain | 2011-05-01 14:17:55 +0000 |
commit | 06a8dfda3d2c5a20ac69a1ebcb1580b56bb43700 (patch) | |
tree | 957597369a2dd938a1d277888ac48f2e1064a278 | |
parent | 23621f75f0d5696a10996275ac986ecc4335dabb (diff) |
Add reloscache & relpgcache to (Index|Rel)OptInfo
So that costsize.c can use the values
-rw-r--r-- | src/backend/access/hash/hash.c | 4 | ||||
-rw-r--r-- | src/backend/optimizer/util/plancat.c | 19 | ||||
-rw-r--r-- | src/include/nodes/relation.h | 4 | ||||
-rw-r--r-- | src/include/optimizer/plancat.h | 3 |
4 files changed, 25 insertions, 5 deletions
diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c index 4cb29b2bb4..7f39a93a73 100644 --- a/src/backend/access/hash/hash.c +++ b/src/backend/access/hash/hash.c @@ -54,6 +54,8 @@ hashbuild(PG_FUNCTION_ARGS) IndexBuildResult *result; BlockNumber relpages; double reltuples; + float4 reloscache; + float4 relpgcache; uint32 num_buckets; HashBuildState buildstate; @@ -66,7 +68,7 @@ hashbuild(PG_FUNCTION_ARGS) RelationGetRelationName(index)); /* Estimate the number of rows currently present in the table */ - estimate_rel_size(heap, NULL, &relpages, &reltuples); + estimate_rel_size(heap, NULL, &relpages, &reltuples, &reloscache, &relpgcache); /* Initialize the hash index metadata page and initial buckets */ num_buckets = _hash_metapinit(index, reltuples, MAIN_FORKNUM); diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c index fd8ea45b4a..39f9eabacd 100644 --- a/src/backend/optimizer/util/plancat.c +++ b/src/backend/optimizer/util/plancat.c @@ -108,7 +108,8 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent, */ if (!inhparent) estimate_rel_size(relation, rel->attr_widths - rel->min_attr, - &rel->pages, &rel->tuples); + &rel->pages, &rel->tuples, + &rel->oscache, &rel->pgcache); /* * Make list of indexes. Ignore indexes on system catalogs if told to. @@ -323,11 +324,14 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent, { info->pages = RelationGetNumberOfBlocks(indexRelation); info->tuples = rel->tuples; + info->oscache = 0; + info->pgcache = 0; } else { estimate_rel_size(indexRelation, NULL, - &info->pages, &info->tuples); + &info->pages, &info->tuples, + &info->oscache, &info->pgcache); if (info->tuples > rel->tuples) info->tuples = rel->tuples; } @@ -362,7 +366,8 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent, */ void estimate_rel_size(Relation rel, int32 *attr_widths, - BlockNumber *pages, double *tuples) + BlockNumber *pages, double *tuples, + float4 *oscache, float4 *pgcache) { BlockNumber curpages; BlockNumber relpages; @@ -451,21 +456,29 @@ estimate_rel_size(Relation rel, int32 *attr_widths, density = (BLCKSZ - SizeOfPageHeaderData) / tuple_width; } *tuples = rint(density * (double) curpages); + *oscache = (float4) rel->rd_rel->reloscache; + *pgcache = (float4) rel->rd_rel->relpgcache; break; case RELKIND_SEQUENCE: /* Sequences always have a known size */ *pages = 1; *tuples = 1; + *oscache = 0; + *pgcache = 0; break; case RELKIND_FOREIGN_TABLE: /* Just use whatever's in pg_class */ *pages = rel->rd_rel->relpages; *tuples = rel->rd_rel->reltuples; + *oscache = 0; + *pgcache = 0; break; default: /* else it has no disk storage; probably shouldn't get here? */ *pages = 0; *tuples = 0; + *oscache = 0; + *pgcache = 0; break; } } diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index f6592697e4..3f08bb00e3 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -408,6 +408,8 @@ typedef struct RelOptInfo List *indexlist; /* list of IndexOptInfo */ BlockNumber pages; double tuples; + float4 oscache; + float4 pgcache; struct Plan *subplan; /* if subquery */ List *subrtable; /* if subquery */ List *subrowmark; /* if subquery */ @@ -466,6 +468,8 @@ typedef struct IndexOptInfo /* statistics from pg_class */ BlockNumber pages; /* number of disk pages in index */ double tuples; /* number of index tuples in index */ + float4 oscache; + float4 pgcache; /* index descriptor information */ int ncolumns; /* number of columns in index */ diff --git a/src/include/optimizer/plancat.h b/src/include/optimizer/plancat.h index c0b8eda813..1dc78d5bbb 100644 --- a/src/include/optimizer/plancat.h +++ b/src/include/optimizer/plancat.h @@ -29,7 +29,8 @@ extern void get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent, RelOptInfo *rel); extern void estimate_rel_size(Relation rel, int32 *attr_widths, - BlockNumber *pages, double *tuples); + BlockNumber *pages, double *tuples, + float4 *oscache, float4 *pgcache); extern int32 get_relation_data_width(Oid relid, int32 *attr_widths); |