HASH partitioning not working properly

From: Srinivasa T N <seenutn(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: HASH partitioning not working properly
Date: 2020-06-19 05:42:25
Message-ID: CAFruNddApLqb36oUVyHr1BhnN1he1yWUpzqgrT0gPYL_mufB4A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
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=# create table busbar_version (objectid int, ver_id int) partition
by hash(ver_id);
CREATE TABLE
postgres=# CREATE TABLE busbar_version0 PARTITION OF busbar_version FOR
VALUES WITH (MODULUS 10, REMAINDER 0);
CREATE TABLE
postgres=# CREATE TABLE busbar_version5 PARTITION OF busbar_version FOR
VALUES WITH (MODULUS 10, REMAINDER 5);
CREATE TABLE
postgres=# CREATE TABLE busbar_version6 PARTITION OF busbar_version FOR
VALUES WITH (MODULUS 10, REMAINDER 6);
CREATE TABLE
postgres=# CREATE TABLE busbar_version7 PARTITION OF busbar_version FOR
VALUES WITH (MODULUS 10, REMAINDER 7);
CREATE TABLE

I did insert using following:

postgres=# insert into busbar_version(objectid,ver_id) values (5,5);
INSERT 0 1
postgres=# insert into busbar_version(objectid,ver_id) values (6,6);
INSERT 0 1

I was of the opinion that the above rows were inserted into busbar_version5
and busbar_version6, but I'm wrong.

postgres=# select * from busbar_version;
objectid | ver_id
----------+--------
5 | 5
6 | 6
(2 rows)

postgres=# select * from busbar_version5;
objectid | ver_id
----------+--------
5 | 5
(1 row)

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?

If it helps, I am trying on the "psql (12.3 (Debian 12.3-1.pgdg100+1))"
container.

Regards,
Seenu.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kyotaro Horiguchi 2020-06-19 06:13:01 Re: Conflict with recovery on PG version 11.6
Previous Message Paul Förster 2020-06-19 05:35:47 Re: Netapp SnapCenter