Re: Hash support for arrays

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Robert Haas" <robertmhaas(at)gmail(dot)com>
Cc: "marcin mank" <marcin(dot)mank(at)gmail(dot)com>, <pgsql-hackers(at)postgresql(dot)org>,"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Hash support for arrays
Date: 2010-11-02 20:25:16
Message-ID: 4CD02D5C02000025000371B6@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

>> There's no reason that the hash value of an integer of the same
>> size as the hash shouldn't be the integer itself, for example.
>> It's hard to get more predictable than that, yet it works well
>> for hash lookups.
>
> Well, no, not really. For example, it may be that you have a hash
> table with N buckets and values that of the form N+k, 2N+k, 3N+k,
> .... and everything will collide.

That hardly seems convincing if the integer is a sequentially
assigned number, as with many ID columns; but if you want an
algorithm which will work well with numbers which might be assigned
in a pattern with a high correlation with some unpredictable number
of buckets -- sure, it won't work well without some scrambling. For
sequentially assigned numbers, that scrambling would have a cost and
would be of no value. I guess it depend a bit on your use case and
goals.

-Kevin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-11-02 20:42:19 Re: Hash support for arrays
Previous Message Robert Haas 2010-11-02 20:07:47 Re: Hash support for arrays