Re: store narrow values in hash indexes? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: store narrow values in hash indexes?
Date
Msg-id 26868.1474661784@sss.pgh.pa.us
Whole thread Raw
In response to store narrow values in hash indexes?  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> Another thought is that hash codes are 32 bits, but a Datum is 64 bits
> wide on most current platforms.  So we're wasting 4 bytes per index
> tuple storing nothing.

Datum is not a concept that exists on-disk.  What's stored is the 32-bit
hash value.  You're right that we waste space if the platform's MAXALIGN
is 8, but that's the fault of the alignment requirement not the index
definition.

> If we generated 64-bit hash codes we could
> store as many bits of it as a Datum will hold and reduce hash
> collisions.

I think there is considerable merit in trying to move to 64-bit hash
codes (at least for data types that are more than 4 bytes to begin with),
but that's largely in the hope of reducing hash collisions in very large
indexes, not because we'd avoid wasting alignment pad space.  If we do
support that, I think we would do it regardless of the platform MAXALIGN.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: 9.6 TAP tests and extensions
Next
From: Andres Freund
Date:
Subject: Re: Hash Indexes