Re: Hash indexes

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Gregory Stark <gsstark(at)mit(dot)edu>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Hannu Krosing <hannu(at)skype(dot)net>, Luke Lonergan <LLonergan(at)greenplum(dot)com>, mark(at)mark(dot)mielke(dot)cc, Bruce Momjian <bruce(at)momjian(dot)us>, Jie Zhang <jzhang(at)greenplum(dot)com>, Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Hash indexes
Date: 2006-08-01 14:54:10
Message-ID: 44CF6B12.2070400@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Gregory Stark wrote:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
>
>
>> I think the problem may well be that we use hash buckets that are too
>> large (ie, whole pages). After we fetch the page, we have to grovel
>> through every tuple on it to find the one(s) that really match the
>> query, whereas btree has a much more intelligent strategy (viz binary
>> search) to do its intrapage searches. Smaller buckets would help make
>> up for this.
>>
>
> Hm, you would expect hash indexes to still be a win for very large indexes
> where you're worried more about i/o than cpu resources.
>
>
>> Another issue is that we don't store the raw hashcode in the index
>> tuples, so the only way to test a tuple is to actually invoke the
>> datatype equality function. If we stored the whole 32-bit hashcode
>> we could eliminate non-matching hashcodes cheaply. I'm not sure how
>> painful it'd be to do this though ... hash uses the same index tuple
>> layout as everybody else, and so there's no convenient place to put
>> the hashcode.
>>
>
> I looked a while back and was suspicious about the actual hash functions too.
> It seemed like a lot of them were vastly suboptimal. That would mean we're
> often dealing with mostly empty and mostly full buckets instead of well
> distributed hash tables.
>
>
>

This is now sounding like a lot of low hanging fruit ... highly
performant hash indexed tables could possibly be a very big win.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Luke Lonergan 2006-08-01 14:55:35 Re: Hash indexes (was: On-disk bitmap index patch)
Previous Message Martijn van Oosterhout 2006-08-01 14:51:56 Re: User-defined typle similar to char(length) varchar(length)