Re: Postgres 11, partitioning with a custom hash function - Mailing list pgsql-general

From David Rowley
Subject Re: Postgres 11, partitioning with a custom hash function
Date
Msg-id CAKJS1f-aTO=ipnVFuM3N6sf2+Cub+vasxtw4ZN0ei2TTfJ+m4g@mail.gmail.com
Whole thread Raw
In response to Re: Postgres 11, partitioning with a custom hash function  (Harry B <harrysungod@gmail.com>)
Responses Re: Postgres 11, partitioning with a custom hash function
List pgsql-general
On 5 October 2018 at 06:18, Harry B <harrysungod@gmail.com> wrote:
>
> Thank you David! These helped me create an operator class.
> However, there still seems to be a 'off-by-a-fixed-N' difference between the
> hash value returned and how PG selects the partition.

hmm, actually, this is probably due to the hash_combine64() call in
compute_partition_hash_value(). This seems to combine the hash value
with 0 regardless of if there's another partition key column to hash.
If you could somehow do the reverse of what hash_combine64() will do
to you hash before returning it to the function then you might get
somewhere, but that does not look possible since it appears to be
throwing away some bits.

It may not have been a great choice to decide to have
compute_partition_hash_value() do this unnecessary combine, but it's
likely a few months too late to change that now.

-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


pgsql-general by date:

Previous
From: Harry B
Date:
Subject: Re: Postgres 11, partitioning with a custom hash function
Next
From: Harry B
Date:
Subject: Re: Postgres 11, partitioning with a custom hash function