Re: HASH partitioning not working properly

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Srinivasa T N <seenutn(at)gmail(dot)com>
Cc: David Rowley <dgrowleyml(at)gmail(dot)com>, PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: HASH partitioning not working properly
Date: 2020-06-19 13:43:40
Message-ID: 219b96f22844aa5408285ef7d4a049af56fb7915.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Laurenz Albe 2020-06-19 13:44:44 Re: Conflict with recovery on PG version 11.6
Previous Message Adrian Klaver 2020-06-19 13:19:14 Re: create batch script to import into postgres tables