diff options
Diffstat (limited to 'src/backend/access/hash')
-rw-r--r-- | src/backend/access/hash/hashpage.c | 14 | ||||
-rw-r--r-- | src/backend/access/hash/hashutil.c | 23 |
2 files changed, 20 insertions, 17 deletions
diff --git a/src/backend/access/hash/hashpage.c b/src/backend/access/hash/hashpage.c index bed0b5dbd72..f5a1fcfd814 100644 --- a/src/backend/access/hash/hashpage.c +++ b/src/backend/access/hash/hashpage.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.58 2006/07/02 02:23:18 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashpage.c,v 1.59 2006/07/03 22:45:36 tgl Exp $ * * NOTES * Postgres hash pages look like ordinary relation pages. The opaque @@ -30,7 +30,6 @@ #include "access/genam.h" #include "access/hash.h" -#include "catalog/index.h" #include "miscadmin.h" #include "storage/lmgr.h" #include "utils/lsyscache.h" @@ -223,16 +222,17 @@ _hash_metapinit(Relation rel) RelationGetRelationName(rel)); /* - * Determine the target fill factor (tuples per bucket) for this index. - * The idea is to make the fill factor correspond to pages about 3/4ths - * full. We can compute it exactly if the index datatype is fixed-width, - * but for var-width there's some guessing involved. + * Determine the target fill factor (in tuples per bucket) for this index. + * The idea is to make the fill factor correspond to pages about as full + * as the user-settable fillfactor parameter says. We can compute it + * exactly if the index datatype is fixed-width, but for var-width there's + * some guessing involved. */ data_width = get_typavgwidth(RelationGetDescr(rel)->attrs[0]->atttypid, RelationGetDescr(rel)->attrs[0]->atttypmod); item_width = MAXALIGN(sizeof(IndexTupleData)) + MAXALIGN(data_width) + sizeof(ItemIdData); /* include the line pointer */ - ffactor = BLCKSZ * IndexGetFillFactor(rel) / 100 / item_width; + ffactor = RelationGetTargetPageUsage(rel, HASH_DEFAULT_FILLFACTOR) / item_width; /* keep to a sane range */ if (ffactor < 10) ffactor = 10; diff --git a/src/backend/access/hash/hashutil.c b/src/backend/access/hash/hashutil.c index fbee1fdc2aa..a1a03ddcf36 100644 --- a/src/backend/access/hash/hashutil.c +++ b/src/backend/access/hash/hashutil.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/hash/hashutil.c,v 1.48 2006/07/02 02:23:18 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/access/hash/hashutil.c,v 1.49 2006/07/03 22:45:36 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -16,6 +16,7 @@ #include "access/genam.h" #include "access/hash.h" +#include "access/reloptions.h" #include "executor/execdebug.h" @@ -175,14 +176,16 @@ _hash_checkpage(Relation rel, Buffer buf, int flags) } Datum -hashoption(PG_FUNCTION_ARGS) +hashoptions(PG_FUNCTION_ARGS) { -#define HASH_MIN_FILLFACTOR 50 -#define HASH_DEFAULT_FILLFACTOR 75 - - ArrayType *options = (ArrayType *) PG_GETARG_POINTER(0); - - /* Use index common routine. */ - PG_RETURN_BYTEA_P(genam_option(options, - HASH_MIN_FILLFACTOR, HASH_DEFAULT_FILLFACTOR)); + Datum reloptions = PG_GETARG_DATUM(0); + bool validate = PG_GETARG_BOOL(1); + bytea *result; + + result = default_reloptions(reloptions, validate, + HASH_MIN_FILLFACTOR, + HASH_DEFAULT_FILLFACTOR); + if (result) + PG_RETURN_BYTEA_P(result); + PG_RETURN_NULL(); } |