pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Greg Stark <gsstark@mit.edu>
Cc: Dennis Bjorklund <db@zigo.dhs.org>
Cc: Bruno Wolff III <bruno@wolff.to>
Cc: Jim C. Nasby <jim@nasby.net>
Cc: pgsql-performance@postgresql.org
Subject: Re: Horribly slow hash join
Date: Mon, 19 Apr 2004 02:09:30 -0400
Message-ID: <16041.1082354970@sss.pgh.pa.us> (raw)
In-Reply-To: <874qrg7cy8.fsf@stark.xeocode.com>
References: <Pine.LNX.4.44.0404190640010.4551-100000@zigo.dhs.org>
	<874qrg7cy8.fsf@stark.xeocode.com>

Greg Stark <gsstark@mit.edu> writes:
> If the hash tables were made a power of two then it would be possible to mix
> the bits of the 32 bit value and just mask off the unneeded bits. I've found
> one page via google that mentions mixing bits in a hash function, but I would
> look for a more serious treatment somewhere.
>  http://burtleburtle.net/bob/hash/doobs.html
> Incidentally, this text claims mod is extremely slow compared to bit
> manipulations.

Modding by a *non* power of 2 (esp. a prime) mixes the bits quite well,
and is likely faster than any multiple-instruction way to do the same.

The quoted article seems to be by someone who has spent a lot of time
counting assembly cycles and none at all reading the last thirty years
worth of CS literature.  Knuth's treatment of hashing has some actual
math to it... 

			regards, tom lane



view thread (24+ messages)  latest in thread

Message-ID: <16041.1082354970@sss.pgh.pa.us>
Permalink:  ../16041.1082354970@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/16041.1082354970@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, gsstark@mit.edu, db@zigo.dhs.org, bruno@wolff.to, jim@nasby.net
  Subject: Re: Horribly slow hash join
  In-Reply-To: <16041.1082354970@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox