pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Srinivasa T N <seenutn@gmail.com>
Cc: David Rowley <dgrowleyml@gmail.com>
Cc: PostgreSQL General <pgsql-general@lists.postgresql.org>
Subject: Re: HASH partitioning not working properly
Date: Fri, 19 Jun 2020 15:43:40 +0200
Message-ID: <219b96f22844aa5408285ef7d4a049af56fb7915.camel@cybertec.at> (raw)
In-Reply-To: <CAFruNdcAJGHM4gnh3kEzBS-dJT1PEzQoSYep7wMwMQc97KxPkA@mail.gmail.com>
References: <CAFruNddApLqb36oUVyHr1BhnN1he1yWUpzqgrT0gPYL_mufB4A@mail.gmail.com>
	<CAApHDvra1kLN=GXc=fA0OHLz3ub2ThXwhe8P7a-Qo3-T73wV0w@mail.gmail.com>
	<CAFruNdeXzVG25yvvpZxBY6_LRgi2azPvAR9qLdnrxNhtVmD+Pg@mail.gmail.com>
	<c8f81436ebf46f083b56af189093872f869f8cf1.camel@cybertec.at>
	<CAFruNdcAJGHM4gnh3kEzBS-dJT1PEzQoSYep7wMwMQc97KxPkA@mail.gmail.com>

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






view thread (10+ messages)

Message-ID: <219b96f22844aa5408285ef7d4a049af56fb7915.camel@cybertec.at>
Permalink:  ../219b96f22844aa5408285ef7d4a049af56fb7915.camel@cybertec.at/
Also on:    postgresql.org/message-id/219b96f22844aa5408285ef7d4a049af56fb7915.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: laurenz.albe@cybertec.at, seenutn@gmail.com, dgrowleyml@gmail.com
  Subject: Re: HASH partitioning not working properly
  In-Reply-To: <219b96f22844aa5408285ef7d4a049af56fb7915.camel@cybertec.at>
  References: <CAFruNddApLqb36oUVyHr1BhnN1he1yWUpzqgrT0gPYL_mufB4A@mail.gmail.com> <CAApHDvra1kLN=GXc=fA0OHLz3ub2ThXwhe8P7a-Qo3-T73wV0w@mail.gmail.com> <CAFruNdeXzVG25yvvpZxBY6_LRgi2azPvAR9qLdnrxNhtVmD+Pg@mail.gmail.com> <c8f81436ebf46f083b56af189093872f869f8cf1.camel@cybertec.at> <CAFruNdcAJGHM4gnh3kEzBS-dJT1PEzQoSYep7wMwMQc97KxPkA@mail.gmail.com> <219b96f22844aa5408285ef7d4a049af56fb7915.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox