mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
I've attached a patch which implements Bob Jenkin's hash function for
PostgreSQL. This hash function replaces the one used by hash indexes and the catalog cache. Hash joins use a different, relatively poor-quality hash function, but I'll fix that later. As suggested by Tom Lane, this patch also changes the size of the fixed hash table used by the catalog cache to be a power-of-2 (instead of a prime: I chose 256 instead of 257). This allows the catcache to lookup hash buckets using a simple bitmask. This should improve the performance of the catalog cache slightly, since the previous method (modulo a prime) was slow. In my tests, this improves the performance of hash indexes by between 4% and 8%; the performance when using btree indexes or seqscans is basically unchanged. Neil Conway <neilconway@rogers.com>
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.23 2001/10/25 05:49:21 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.24 2002/03/06 20:49:40 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -49,7 +49,7 @@ _hash_doinsert(Relation rel, HashItem hitem)
|
||||
itup = &(hitem->hash_itup);
|
||||
if ((natts = rel->rd_rel->relnatts) != 1)
|
||||
elog(ERROR, "Hash indices valid for only one index key.");
|
||||
itup_scankey = _hash_mkscankey(rel, itup, metap);
|
||||
itup_scankey = _hash_mkscankey(rel, itup);
|
||||
|
||||
/*
|
||||
* find the first page in the bucket chain containing this key and
|
||||
@@ -232,7 +232,7 @@ _hash_pgaddtup(Relation rel,
|
||||
RelationGetRelationName(rel));
|
||||
|
||||
/* write the buffer, but hold our lock */
|
||||
_hash_wrtnorelbuf(rel, buf);
|
||||
_hash_wrtnorelbuf(buf);
|
||||
|
||||
return itup_off;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user