Re: PG11 - Multiple Key Range Partition

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Rares Salcudean <rares(dot)salcudean(at)takeofflabs(dot)com>
Cc: PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: PG11 - Multiple Key Range Partition
Date: 2019-07-10 08:37:28
Message-ID: CAKJS1f-QTS_uM9FwQT2-XVNjga=ueXifuYy-aTtb8OKWVKZOGQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, 10 Jul 2019 at 18:39, Rares Salcudean
<rares(dot)salcudean(at)takeofflabs(dot)com> wrote:
> I tested out your example and all works fine for me as well. But I live the main issue lies in the following example:
>
> create table rangep (a bool, b bool, c date) partition by range (a,b,c);
>
> create table rangep1_recent partition of rangep for values from (true,false, '1990-01-01') to (true,false,'2090-01-01');
> create table rangep1_deleted partition of rangep for values from (false,true, '1990-01-01') to (false,true,'2090-01-01');
> create table rangep1_2019 partition of rangep for values from (false,false, '2019-01-01') to (false,false,'2020-01-01');
> create table rangep1_2018 partition of rangep for values from (false,false, '2018-01-01') to (false,false,'2019-01-01');
> create table rangep1_2017 partition of rangep for values from (false,false, '2017-01-01') to (false,false,'2018-01-01');
>
> explain select * from rangep where not a and not b and c = '2019-07-10';

Thanks for making the test case. It is a bug. There's a problem in
match_clause_to_partition_key() where because
match_boolean_partition_clause() returns false for the "NOT b"
condition when comparing to the first partition key this causes the
function to return PARTCLAUSE_UNSUPPORTED which causes the calling
function to not bother trying to match that qual up to any other
partition key. Effectively, for pruning the WHERE clause is just WHERE
NOT a AND c = '2019-07-10', so only the rangep1_recent partition is
pruned.

I'll look into fixing it. Thanks for the report.

--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Amit Langote 2019-07-10 08:47:55 Re: FDW does not push down LIMIT & ORDER BY with sharding (partitions)
Previous Message Andres Freund 2019-07-10 07:55:01 Re: BUG #15888: Bogus "idle in transaction" state for logical decoding client after creating a slot