git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 162bd08)
Marginal hack to use a specialized hash function for dynahash hashtables
2005年4月14日 20:32:43 +0000 (20:32 +0000)
2005年4月14日 20:32:43 +0000 (20:32 +0000)
whose keys are OIDs. The only one that looks particularly performance
critical is the relcache hashtable, but as long as we've got the function
we may as well use it wherever it's applicable.


diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index ce4dc45f3d9cb5685edee078f924762b7d63e01a..e21adab7caa4be787f68dae75042d2d84cb115c2 100644 (file)
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -13,7 +13,7 @@
*
* Copyright (c) 2001-2005, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.91 2005年04月14日 20:03:25 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.92 2005年04月14日 20:32:42 tgl Exp $
* ----------
*/
#include "postgres.h"
@@ -2065,7 +2065,7 @@ pgstat_add_backend(PgStat_MsgHdr *msg)
memset(&hash_ctl, 0, sizeof(hash_ctl));
hash_ctl.keysize = sizeof(Oid);
hash_ctl.entrysize = sizeof(PgStat_StatTabEntry);
- hash_ctl.hash = tag_hash;
+ hash_ctl.hash = oid_hash;
dbentry->tables = hash_create("Per-database table",
PGSTAT_TAB_HASH_SIZE,
&hash_ctl,
@@ -2364,7 +2364,7 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb,
memset(&hash_ctl, 0, sizeof(hash_ctl));
hash_ctl.keysize = sizeof(Oid);
hash_ctl.entrysize = sizeof(PgStat_StatDBEntry);
- hash_ctl.hash = tag_hash;
+ hash_ctl.hash = oid_hash;
hash_ctl.hcxt = use_mcxt;
*dbhash = hash_create("Databases hash", PGSTAT_DB_HASH_SIZE, &hash_ctl,
HASH_ELEM | HASH_FUNCTION | mcxt_flags);
@@ -2453,7 +2453,7 @@ pgstat_read_statsfile(HTAB **dbhash, Oid onlydb,
memset(&hash_ctl, 0, sizeof(hash_ctl));
hash_ctl.keysize = sizeof(Oid);
hash_ctl.entrysize = sizeof(PgStat_StatTabEntry);
- hash_ctl.hash = tag_hash;
+ hash_ctl.hash = oid_hash;
hash_ctl.hcxt = use_mcxt;
dbentry->tables = hash_create("Per-database table",
PGSTAT_TAB_HASH_SIZE,
@@ -2888,7 +2888,7 @@ pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len)
memset(&hash_ctl, 0, sizeof(hash_ctl));
hash_ctl.keysize = sizeof(Oid);
hash_ctl.entrysize = sizeof(PgStat_StatTabEntry);
- hash_ctl.hash = tag_hash;
+ hash_ctl.hash = oid_hash;
dbentry->tables = hash_create("Per-database table",
PGSTAT_TAB_HASH_SIZE,
&hash_ctl,
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index ab773de9c80607f881b1cd165345ac38b581df8a..7c24e648af796a1138b021dbc80a04c80edfd6b9 100644 (file)
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.220 2005年04月14日 20:03:26 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.221 2005年04月14日 20:32:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1032,7 +1032,7 @@ LookupOpclassInfo(Oid operatorClassOid,
MemSet(&ctl, 0, sizeof(ctl));
ctl.keysize = sizeof(Oid);
ctl.entrysize = sizeof(OpClassCacheEnt);
- ctl.hash = tag_hash;
+ ctl.hash = oid_hash;
OpClassCache = hash_create("Operator class cache", 64,
&ctl, HASH_ELEM | HASH_FUNCTION);
}
@@ -2151,7 +2151,7 @@ RelationCacheInitialize(void)
MemSet(&ctl, 0, sizeof(ctl));
ctl.keysize = sizeof(Oid);
ctl.entrysize = sizeof(RelIdCacheEnt);
- ctl.hash = tag_hash;
+ ctl.hash = oid_hash;
RelationIdCache = hash_create("Relcache by OID", INITRELCACHESIZE,
&ctl, HASH_ELEM | HASH_FUNCTION);
diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c
index 01990db8ad9055e6c1025b6d4ffeae886dfdbc2f..a46267643b5e5bffb54c5c25d9dbd87f0cbf3d89 100644 (file)
--- a/src/backend/utils/cache/typcache.c
+++ b/src/backend/utils/cache/typcache.c
@@ -36,7 +36,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/cache/typcache.c,v 1.12 2005年04月14日 20:03:26 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/cache/typcache.c,v 1.13 2005年04月14日 20:32:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -123,7 +123,7 @@ lookup_type_cache(Oid type_id, int flags)
MemSet(&ctl, 0, sizeof(ctl));
ctl.keysize = sizeof(Oid);
ctl.entrysize = sizeof(TypeCacheEntry);
- ctl.hash = tag_hash;
+ ctl.hash = oid_hash;
TypeCacheHash = hash_create("Type information cache", 64,
&ctl, HASH_ELEM | HASH_FUNCTION);
}
diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c
index 0e9716de0135e06d6c93450bdb0871f70ff0442d..181da00fd7e916a5701776798a2e4735ffef08c5 100644 (file)
--- a/src/backend/utils/fmgr/fmgr.c
+++ b/src/backend/utils/fmgr/fmgr.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.93 2005年03月31日 22:46:16 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/fmgr/fmgr.c,v 1.94 2005年04月14日 20:32:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -509,7 +509,7 @@ record_C_func(HeapTuple procedureTuple,
MemSet(&hash_ctl, 0, sizeof(hash_ctl));
hash_ctl.keysize = sizeof(Oid);
hash_ctl.entrysize = sizeof(CFuncHashTabEntry);
- hash_ctl.hash = tag_hash;
+ hash_ctl.hash = oid_hash;
CFuncHash = hash_create("CFuncHash",
100,
&hash_ctl,
diff --git a/src/backend/utils/hash/hashfn.c b/src/backend/utils/hash/hashfn.c
index c27417d7d3be40ec8b617e2190782fab874ff724..24255f31e6e0ac19a5416461e31f1c7338539447 100644 (file)
--- a/src/backend/utils/hash/hashfn.c
+++ b/src/backend/utils/hash/hashfn.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/hash/hashfn.c,v 1.22 2004年12月31日 22:01:37 pgsql Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/hash/hashfn.c,v 1.23 2005年04月14日 20:32:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -40,3 +40,16 @@ tag_hash(const void *key, Size keysize)
return DatumGetUInt32(hash_any((const unsigned char *) key,
(int) keysize));
}
+
+/*
+ * oid_hash: hash function for keys that are OIDs
+ *
+ * (tag_hash works for this case too, but is slower)
+ */
+uint32
+oid_hash(const void *key, Size keysize)
+{
+ Assert(keysize == sizeof(Oid));
+ /* We don't actually bother to do anything to the OID value ... */
+ return (uint32) *((const Oid *) key);
+}
diff --git a/src/include/utils/hsearch.h b/src/include/utils/hsearch.h
index 9773dc733f3be4c4ed3a6ae621a35f09d25b7d3b..e6293bc000ccc5fb79985d5878e5a3f2fd6313ac 100644 (file)
--- a/src/include/utils/hsearch.h
+++ b/src/include/utils/hsearch.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/hsearch.h,v 1.34 2004年12月31日 22:03:46 pgsql Exp $
+ * $PostgreSQL: pgsql/src/include/utils/hsearch.h,v 1.35 2005年04月14日 20:32:43 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -184,5 +184,6 @@ extern long hash_select_dirsize(long num_entries);
*/
extern uint32 string_hash(const void *key, Size keysize);
extern uint32 tag_hash(const void *key, Size keysize);
+extern uint32 oid_hash(const void *key, Size keysize);
#endif /* HSEARCH_H */
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /