diff options
Diffstat (limited to 'src/backend/access/hash/hash.c')
| -rw-r--r-- | src/backend/access/hash/hash.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c index f6c4d5705d..b008c0aa4a 100644 --- a/src/backend/access/hash/hash.c +++ b/src/backend/access/hash/hash.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.98 2008/01/01 19:45:46 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hash.c,v 1.99 2008/03/15 20:46:31 tgl Exp $ * * NOTES * This file contains only the public interface routines. @@ -22,6 +22,7 @@ #include "access/hash.h" #include "catalog/index.h" #include "commands/vacuum.h" +#include "optimizer/plancat.h" /* Working state for hashbuild and its callback */ @@ -48,6 +49,7 @@ hashbuild(PG_FUNCTION_ARGS) Relation index = (Relation) PG_GETARG_POINTER(1); IndexInfo *indexInfo = (IndexInfo *) PG_GETARG_POINTER(2); IndexBuildResult *result; + BlockNumber relpages; double reltuples; HashBuildState buildstate; @@ -59,8 +61,11 @@ hashbuild(PG_FUNCTION_ARGS) elog(ERROR, "index \"%s\" already contains data", RelationGetRelationName(index)); - /* initialize the hash index metadata page */ - _hash_metapinit(index); + /* estimate the number of rows currently present in the table */ + estimate_rel_size(heap, NULL, &relpages, &reltuples); + + /* initialize the hash index metadata page and initial buckets */ + _hash_metapinit(index, reltuples); /* build the index */ buildstate.indtuples = 0; |
