From: Daniel Westermann <daniel.westermann@dbi-services.com>
To: amul sul <sulamul@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: PG11 Hash partitioning and null values in the partition key
Date: Sat, 14 Jul 2018 06:22:04 +0200 (CEST)
Message-ID: <1150806919.726.1531542123999.JavaMail.zimbra@dbi-services.com> (raw)
In-Reply-To: <CAAJ_b94Y+ajsqGs0tFw9hnX8h-u2mfZdZy5LcbG05_2DCJOXig@mail.gmail.com>
References: <1001533186.34186.1531490726446.JavaMail.zimbra@dbi-services.com>
<CAAJ_b94Y+ajsqGs0tFw9hnX8h-u2mfZdZy5LcbG05_2DCJOXig@mail.gmail.com>
Hi,
given this setup:
create table part2 ( a int, list varchar(10) ) partition by hash (a);
create table part2_1 partition of part2 FOR VALUES WITH (MODULUS 3, REMAINDER 0);
create table part2_2 partition of part2 FOR VALUES WITH (MODULUS 3, REMAINDER 1);
create table part2_3 partition of part2 FOR VALUES WITH (MODULUS 3, REMAINDER 2);
insert into part2 (a,list) values (1,'aaa');
insert into part2 (a,list) values (2,'bbb');
insert into part2 (a,list) values (3,'ccc');
... it is possible to insert rows like this which will always go to the first partition:
insert into part2 (a,list) values (null,'ddd');
insert into part2 (a,list) values (null,'eee');
select * from part2_1;
a | list
---+------
2 | bbb
| ddd
| eee
(3 rows)
I suppose this is intended but I could not find anything in the documentation about that. Can someone please clarify the logic behind that?
>> The calculated hash value for the null value will be zero, therefore, it will fall to the partition having remainder zero.
Thank you, Amul
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: daniel.westermann@dbi-services.com, sulamul@gmail.com
Subject: Re: PG11 Hash partitioning and null values in the partition key
In-Reply-To: <1150806919.726.1531542123999.JavaMail.zimbra@dbi-services.com>
References: <1001533186.34186.1531490726446.JavaMail.zimbra@dbi-services.com> <CAAJ_b94Y+ajsqGs0tFw9hnX8h-u2mfZdZy5LcbG05_2DCJOXig@mail.gmail.com> <1150806919.726.1531542123999.JavaMail.zimbra@dbi-services.com>
* 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