pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedPG10 declarative partitioning that allow null value
3+ messages / 2 participants
[nested] [flat]
* PG10 declarative partitioning that allow null value
@ 2019-04-16 02:37 Soni <diptatapa@gmail.com>
2019-04-16 03:06 ` Re: PG10 declarative partitioning that allow null value Soni <diptatapa@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Soni @ 2019-04-16 02:37 UTC (permalink / raw)
To: pgsql-general
Hello All,
currently we are planning to migrate inheritance partitioning to
declarative partitioning by range values of int on pg10. But the key
values can contain null. I know that range partitioning does not allow
null values.
We are looking for workaround for this, that is create a list
partitioning and then followed by range sub-partitioning. List
partitioning of number of digits of the int key column.
CREATE TABLE partitioned_table_name (like table_name) partition by list
(floor(log(int_key_column)+1));
create table partitions_1 partition of partitioned_table_name for values
in (null);
create table partitions_2 partition of partitioned_table_name for values
in (1);
.....
.....
create table partitions_2 partition of partitioned_table_name for values
in (9) partition by range(int_key_column);
Question is :
is this a good practice ? will performance dropped significantly due to
the process of counting the number of digits ?
or is there any better workaround for this ?
Thanks,
Soni.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: PG10 declarative partitioning that allow null value
2019-04-16 02:37 PG10 declarative partitioning that allow null value Soni <diptatapa@gmail.com>
@ 2019-04-16 03:06 ` Soni <diptatapa@gmail.com>
2019-04-16 03:10 ` Re: PG10 declarative partitioning that allow null value Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: Soni @ 2019-04-16 03:06 UTC (permalink / raw)
To: pgsql-general
I think it's better to had list partitioning of true/false based on
(int_key_column is null)
CREATE TABLE partitioned_table_name (like table_name) partition by list
((int_key_column is null));
On 16/04/2019 9:37, Soni wrote:
> Hello All,
> currently we are planning to migrate inheritance partitioning to
> declarative partitioning by range values of int on pg10. But the key
> values can contain null. I know that range partitioning does not allow
> null values.
> We are looking for workaround for this, that is create a list
> partitioning and then followed by range sub-partitioning. List
> partitioning of number of digits of the int key column.
>
>
> CREATE TABLE partitioned_table_name (like table_name) partition by
> list (floor(log(int_key_column)+1));
>
> create table partitions_1 partition of partitioned_table_name for
> values in (null);
> create table partitions_2 partition of partitioned_table_name for
> values in (1);
> .....
> .....
> create table partitions_2 partition of partitioned_table_name for
> values in (9) partition by range(int_key_column);
>
> Question is :
> is this a good practice ? will performance dropped significantly due
> to the process of counting the number of digits ?
> or is there any better workaround for this ?
>
> Thanks,
>
> Soni.
>
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: PG10 declarative partitioning that allow null value
2019-04-16 02:37 PG10 declarative partitioning that allow null value Soni <diptatapa@gmail.com>
2019-04-16 03:06 ` Re: PG10 declarative partitioning that allow null value Soni <diptatapa@gmail.com>
@ 2019-04-16 03:10 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 3+ messages in thread
From: Tom Lane @ 2019-04-16 03:10 UTC (permalink / raw)
To: Soni <diptatapa@gmail.com>; +Cc: pgsql-general
Soni <diptatapa@gmail.com> writes:
>> currently we are planning to migrate inheritance partitioning to
>> declarative partitioning by range values of int on pg10. But the key
>> values can contain null. I know that range partitioning does not allow
>> null values.
In v11 you could use a default partition ...
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2019-04-16 03:10 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-04-16 02:37 PG10 declarative partitioning that allow null value Soni <diptatapa@gmail.com>
2019-04-16 03:06 ` Soni <diptatapa@gmail.com>
2019-04-16 03:10 ` Tom Lane <tgl@sss.pgh.pa.us>
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