Re: HASH partitioning not working properly

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Srinivasa T N <seenutn(at)gmail(dot)com>
Cc: PostgreSQL General <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: HASH partitioning not working properly
Date: 2020-06-19 06:14:07
Message-ID: CAApHDvra1kLN=GXc=fA0OHLz3ub2ThXwhe8P7a-Qo3-T73wV0w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 19 Jun 2020 at 17:42, Srinivasa T N <seenutn(at)gmail(dot)com> wrote:
> After seeing the below, I feel partitioning is not working properly or it maybe case that my understanding is wrong. Can somebody explain me what is happening?

> postgres=# select * from busbar_version6;
> objectid | ver_id
> ----------+--------
> (0 rows)
>
> postgres=# select * from busbar_version7;
> objectid | ver_id
> ----------+--------
> 6 | 6
> (1 row)
>
> Why second insert has gone to table busbar_version7 instead of busbar_version6?

It's your understanding that's not correct. The value of is passed
through a hash function and the partition is selected based partition
matching the remainder value after dividing the return value of the
hash function by the largest modulus of any partition.

That might surprise you, but how would you select which partition a
varchar value should go into if you didn't use a hash function.

David

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Srinivasa T N 2020-06-19 06:42:45 Re: HASH partitioning not working properly
Previous Message Kyotaro Horiguchi 2020-06-19 06:13:01 Re: Conflict with recovery on PG version 11.6