pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedPG11 Hash partitioning and null values in the partition key
3+ messages / 2 participants
[nested] [flat]
* PG11 Hash partitioning and null values in the partition key
@ 2018-07-13 14:05 Daniel Westermann <daniel.westermann@dbi-services.com>
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Westermann @ 2018-07-13 14:05 UTC (permalink / raw)
To: pgsql-general
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?
Thanks in advance
Daniel
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: PG11 Hash partitioning and null values in the partition key
@ 2018-07-13 14:56 amul sul <sulamul@gmail.com>
parent: Daniel Westermann <daniel.westermann@dbi-services.com>
0 siblings, 1 reply; 3+ messages in thread
From: amul sul @ 2018-07-13 14:56 UTC (permalink / raw)
To: daniel.westermann@dbi-services.com; +Cc: pgsql-general
On Fri, Jul 13, 2018, 7:35 PM Daniel Westermann <
daniel.westermann@dbi-services.com> wrote:
> 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.
​Regards,
Amul​
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: PG11 Hash partitioning and null values in the partition key
@ 2018-07-14 04:22 Daniel Westermann <daniel.westermann@dbi-services.com>
parent: amul sul <sulamul@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Westermann @ 2018-07-14 04:22 UTC (permalink / raw)
To: amul sul <sulamul@gmail.com>; +Cc: pgsql-general
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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2018-07-14 04:22 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-07-13 14:05 PG11 Hash partitioning and null values in the partition key Daniel Westermann <daniel.westermann@dbi-services.com>
2018-07-13 14:56 ` amul sul <sulamul@gmail.com>
2018-07-14 04:22 ` Daniel Westermann <daniel.westermann@dbi-services.com>
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