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.

Unless anyone seems a problem, please apply.

Cheers,

Neil

-- 
Neil Conway <neilconway@rogers.com>
PGP Key ID: DB3C29FC
04 Mar 2002 21:36:09 -0500
Neil Conway <nconway@klamath.dyndns.org>
new hash function

Your patch has been added to the PostgreSQL unapplied patches list at:

	http://candle.pha.pa.us/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------


Neil Conway wrote:
> 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.
> 
> Unless anyone seems a problem, please apply.
> 
> Cheers,
> 
> Neil
> 
> -- 
> Neil Conway <neilconway@rogers.com>
> PGP Key ID: DB3C29FC

[ Attachment, skipping... ]

> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Tue, 5 Mar 2002 01:35:50 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: new hash function
...
> 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.

That's great! Picking up 5% performance is not something we do every
day...

                   - Thomas

Tue, 05 Mar 2002 05:44:47 -0800
Thomas Lockhart <lockhart@fourpalms.org>
Re: [PATCHES] new hash function

Patch applied.  Thanks.

---------------------------------------------------------------------------


Neil Conway wrote:
> 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.
> 
> Unless anyone seems a problem, please apply.
> 
> Cheers,
> 
> Neil
> 
> -- 
> Neil Conway <neilconway@rogers.com>
> PGP Key ID: DB3C29FC

[ Attachment, skipping... ]

> 
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Wed, 6 Mar 2002 15:49:37 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: new hash function