Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1feC4b-0001qm-CQ for pgsql-general@arkaria.postgresql.org; Sat, 14 Jul 2018 04:22:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1feC4X-0001KQ-0t for pgsql-general@arkaria.postgresql.org; Sat, 14 Jul 2018 04:22:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1feC4W-0001KI-PU for pgsql-general@lists.postgresql.org; Sat, 14 Jul 2018 04:22:16 +0000 Received: from mail.dbi-services.com ([195.70.1.167] helo=33229-ml-01.dfinet.ch) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1feC4P-0002Do-G0 for pgsql-general@postgresql.org; Sat, 14 Jul 2018 04:22:16 +0000 Received: from 33229-ml-01.dfinet.ch (localhost [127.0.0.1]) by 33229-ml-01.dfinet.ch (Postfix) with ESMTPS id 3F1D4C09D9FB; Sat, 14 Jul 2018 06:22:06 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by 33229-ml-01.dfinet.ch (Postfix) with ESMTP id 2FD9DC09E353; Sat, 14 Jul 2018 06:22:06 +0200 (CEST) X-Virus-Scanned: amavisd-new at 33229-ml-01.dfinet.ch Received: from 33229-ml-01.dfinet.ch ([127.0.0.1]) by localhost (33229-ml-01.dfinet.ch [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id JOmH0x-wIoXt; Sat, 14 Jul 2018 06:22:06 +0200 (CEST) Received: from 33229-ml-01.dfinet.ch (33229-ml-01.dfinet.ch [10.128.30.2]) by 33229-ml-01.dfinet.ch (Postfix) with ESMTP id 19DA8C09D9FB; Sat, 14 Jul 2018 06:22:06 +0200 (CEST) Date: Sat, 14 Jul 2018 06:22:04 +0200 (CEST) From: Daniel Westermann To: amul sul Cc: pgsql-general Message-ID: <1150806919.726.1531542123999.JavaMail.zimbra@dbi-services.com> In-Reply-To: References: <1001533186.34186.1531490726446.JavaMail.zimbra@dbi-services.com> Subject: Re: PG11 Hash partitioning and null values in the partition key MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="=_278916f8-1914-4d93-bf07-4c4cb5998558" X-Originating-IP: [37.201.6.36] X-Mailer: Zimbra 8.8.7_GA_1964 (ZimbraWebClient - FF61 (Linux)/8.8.7_GA_1964) Thread-Topic: PG11 Hash partitioning and null values in the partition key Thread-Index: 1DIy1sNzTtzloHT2OajXC4MG2+y5Bw== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --=_278916f8-1914-4d93-bf07-4c4cb5998558 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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 --=_278916f8-1914-4d93-bf07-4c4cb5998558 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hi,

given this setup:

create table part2 ( a int= , list varchar(10) ) partition by hash (a);
create table part= 2_1 partition of part2 FOR VALUES WITH (MODULUS 3, REMAINDER 0);
<= div>create table part2_2 partition of part2 FOR VALUES WITH (MODULUS 3, REM= AINDER 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 t= hat?

>> The calculated hash valu= e for the null value will be zero, therefore, it will fall to the partition= having remainder zero.


Thank you, Amul

--=_278916f8-1914-4d93-bf07-4c4cb5998558--