Re: HASH partitioning not working properly - Mailing list pgsql-general

From Laurenz Albe
Subject Re: HASH partitioning not working properly
Date
Msg-id 219b96f22844aa5408285ef7d4a049af56fb7915.camel@cybertec.at
Whole thread Raw
In response to Re: HASH partitioning not working properly  (Srinivasa T N <seenutn@gmail.com>)
List pgsql-general
On Fri, 2020-06-19 at 13:27 +0530, Srinivasa T N wrote:
> > > How can I see the output of hash function that is used internally?
> > 
> > In the case of "integer", the hash function is "pg_catalog"."hashint4".
>
> I guess output formatting is wrong, any help?
>
>  postgres=# select pg_catalog.hashint4(7);
>   hashint4  
> ------------
>  -978793473
> (1 row)

No, that is fine.
Just take the result mod 10 if that is how hash partitioning was defined:

select pg_catalog.hashint4(7) - floor(pg_catalog.hashint4(7) / 10.0) * 10;
 ?column? 
----------
        7
(1 row)

So that should end up in the eighth partition.

You have no choice which hash function to use for partitioning.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com




pgsql-general by date:

Previous
From: Srinivasa T N
Date:
Subject: Re: HASH partitioning not working properly
Next
From: Laurenz Albe
Date:
Subject: Re: Conflict with recovery on PG version 11.6