diff options
| author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-06-01 15:33:19 +0000 |
|---|---|---|
| committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-06-01 15:33:19 +0000 |
| commit | 1f559b7d3aa411e08d2ad46a4bd7d9213945b103 (patch) | |
| tree | df4325affc882914a2dd6c6e8a8160ffc223a057 /src/backend/utils/hash/hashfn.c | |
| parent | 397d00af8f0526c78eef5999e85ce6a3d5e9e36f (diff) | |
| download | postgresql-1f559b7d3aa411e08d2ad46a4bd7d9213945b103.tar.gz | |
Fix several hash functions that were taking chintzy shortcuts instead of
delivering a well-randomized hash value. I got religion on this after
observing that performance of multi-batch hash join degrades terribly if the
higher-order bits of hash values aren't random, as indeed was true for say
hashes of small integer values. It's now expected and documented that hash
functions should use hash_any or some comparable method to ensure that all
bits of their output are about equally random.
initdb forced because this change invalidates existing hash indexes. For the
same reason, this isn't back-patchable; the hash join performance problem
will get a band-aid fix in the back branches.
Diffstat (limited to 'src/backend/utils/hash/hashfn.c')
| -rw-r--r-- | src/backend/utils/hash/hashfn.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/backend/utils/hash/hashfn.c b/src/backend/utils/hash/hashfn.c index 6eeedc9383..e1e65c0350 100644 --- a/src/backend/utils/hash/hashfn.c +++ b/src/backend/utils/hash/hashfn.c @@ -9,7 +9,13 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/hash/hashfn.c,v 1.30 2007/01/05 22:19:43 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/hash/hashfn.c,v 1.31 2007/06/01 15:33:18 tgl Exp $ + * + * NOTES + * It is expected that every bit of a hash function's 32-bit result is + * as random as every other; failure to ensure this is likely to lead + * to poor performance of hash tables. In most cases a hash + * function should use hash_any() or its variant hash_uint32(). * *------------------------------------------------------------------------- */ @@ -58,8 +64,7 @@ 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); + return DatumGetUInt32(hash_uint32((uint32) *((const Oid *) key))); } /* |
