fix empty array expression in get_qual_for_list()

Started by Jeevan Ladhealmost 9 years ago4 messageshackers
Jump to latest
#1Jeevan Ladhe
jeevan.ladhe@enterprisedb.com

Hi,

In case of list partitioned table:
1. If there is a partition accepting only null values and nothing else, then
currently the partition constraints for such a partition are constructed as
"((a IS NULL) OR (a = ANY (ARRAY[]::integer[])))".
I think there it is better to avoid constructing an empty array to avoid
executing ANY expression.

2.Also, we are constructing an expression using index 0 of arrays in
PartitionKey since currently we have only one column for list partition in
key,
added an assert for this.

PFA.

Regards,
Jeevan Ladhe

Attachments:

fix_empty_arry_get_qual_for_list.patchapplication/octet-stream; name=fix_empty_arry_get_qual_for_list.patchDownload+32-18
#2Jeevan Ladhe
jeevan.ladhe@enterprisedb.com
In reply to: Jeevan Ladhe (#1)
Re: fix empty array expression in get_qual_for_list()

Here is an example:

create table t1 ( a int) partition by list (a);
create table t11 partition of t1 for values in (null);

*Current constraints:*
postgres=# \d+ t11;
Table "public.t11"
Column | Type | Collation | Nullable | Default | Storage | Stats target
| Description
--------+---------+-----------+----------+---------+---------+--------------+-------------
a | integer | | | | plain |
|
Partition of: t1 FOR VALUES IN (NULL)
Partition constraint: ((a IS NULL) OR (a = ANY (ARRAY[]::integer[])))

*Constraints after fix:*
postgres=# \d+ t11;
Table "public.t11"
Column | Type | Collation | Nullable | Default | Storage | Stats target
| Description
--------+---------+-----------+----------+---------+---------+--------------+-------------
a | integer | | | | plain |
|
Partition of: t1 FOR VALUES IN (NULL)
Partition constraint: (a IS NULL)

Regards,
Jeevan Ladhe

On Mon, Jun 26, 2017 at 4:53 PM, Jeevan Ladhe <jeevan.ladhe@enterprisedb.com

Show quoted text

wrote:

Hi,

In case of list partitioned table:
1. If there is a partition accepting only null values and nothing else,
then
currently the partition constraints for such a partition are constructed as
"((a IS NULL) OR (a = ANY (ARRAY[]::integer[])))".
I think there it is better to avoid constructing an empty array to avoid
executing ANY expression.

2.Also, we are constructing an expression using index 0 of arrays in
PartitionKey since currently we have only one column for list partition in
key,
added an assert for this.

PFA.

Regards,
Jeevan Ladhe

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jeevan Ladhe (#1)
Re: fix empty array expression in get_qual_for_list()

Jeevan Ladhe <jeevan.ladhe@enterprisedb.com> writes:

In case of list partitioned table:
1. If there is a partition accepting only null values and nothing else, then
currently the partition constraints for such a partition are constructed as
"((a IS NULL) OR (a = ANY (ARRAY[]::integer[])))".
I think there it is better to avoid constructing an empty array to avoid
executing ANY expression.

Looks like a good idea, pushed with trivial stylistic adjustments.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Jeevan Ladhe
jeevan.ladhe@enterprisedb.com
In reply to: Tom Lane (#3)
Re: fix empty array expression in get_qual_for_list()

On Mon, Jun 26, 2017 at 8:14 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Jeevan Ladhe <jeevan.ladhe@enterprisedb.com> writes:

In case of list partitioned table:
1. If there is a partition accepting only null values and nothing else,

then

currently the partition constraints for such a partition are constructed

as

"((a IS NULL) OR (a = ANY (ARRAY[]::integer[])))".
I think there it is better to avoid constructing an empty array to avoid
executing ANY expression.

Looks like a good idea, pushed with trivial stylistic adjustments.

Thanks Tom for taking care of this.

Regards,
Jeevan Ladhe