Re: Hash function for numeric (WIP) - Mailing list pgsql-patches

From Tom Lane
Subject Re: Hash function for numeric (WIP)
Date
Msg-id 10004.1178251044@sss.pgh.pa.us
Whole thread Raw
In response to Re: Hash function for numeric (WIP)  (Neil Conway <neilc@samurai.com>)
Responses Re: Hash function for numeric (WIP)  (Neil Conway <neilc@samurai.com>)
List pgsql-patches
Neil Conway <neilc@samurai.com> writes:
> On Mon, 2007-30-04 at 00:04 -0400, Tom Lane wrote:
>> I'm still not very comfortable with that.  You're proposing to add a
>> pretty obvious failure mechanism --- any numeric-returning function
>> that failed to "normalize" its output would now create a subtle,
>> hard-to-find bug.

> What about teaching hash_numeric() to explicitly ignore leading and
> trailing zero digits?

Hm, but apply hash_any() to the remaining digits?  That might work, if
you are careful about how you factor the weight into it (or just not try
to use the weight in the hash).

>> Perhaps a suitable test would be to compare the number of
>> hash collisions in a large set of randomly-chosen-but-distinct
>> numeric values.

> Okay, I did a little testing.
> [ test that totally destroys my proposed hash function ]

OK, so *that* idea doesn't work.  How about yours above?

            regards, tom lane

pgsql-patches by date:

Previous
From: Neil Conway
Date:
Subject: Re: Hash function for numeric (WIP)
Next
From: Mark Kirkwood
Date:
Subject: Re: Updated bitmap index patch