mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Marginal hack to use a specialized hash function for dynahash hashtables
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.
This commit is contained in:
6
src/backend/utils/cache/relcache.c
vendored
6
src/backend/utils/cache/relcache.c
vendored
@@ -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);
|
||||
|
||||
|
||||
4
src/backend/utils/cache/typcache.c
vendored
4
src/backend/utils/cache/typcache.c
vendored
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user