Re: Unexpected (wrong?) result querying boolean partitioned table with NULL partition

From: David Kimura <david(dot)g(dot)kimura(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unexpected (wrong?) result querying boolean partitioned table with NULL partition
Date: 2023-04-12 16:13:26
Message-ID: CAHnPFjRbzcEZ1OOXfbBcsKR3zjJ_73tRbnfiYhwqS8NMoKVzKQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Apr 12, 2023 at 4:13 AM David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> On Wed, 12 Apr 2023 at 22:13, David Kimura <david(dot)g(dot)kimura(at)gmail(dot)com> wrote:
> > Is it fair to assume that, given the same data, a partitioned table should
> > return the same results as a non-partitioned table?
>
> Yes, and also the same as when enable_partition_pruning is set to off.

Thanks for making me aware of that GUC.

> > One idea is to use the negation operator for IS_NOT_(true|false) (i.e.
> > BooleanNotEqualOperator instead of BooleanEqualOperator). But besides
> > presumably being a more expensive operation, not equal is not part of the btree
> > opfamily for bool_ops. So, seems like that won't really fit into the current
> > partition pruning framework.
>
> There's already code to effectively handle <> operators. Just the
> PartClauseInfo.op_is_ne needs to be set to true.
> get_matching_list_bounds() then handles that by taking the inverse of
> the partitions matching the equality operator.

Ah, I missed that when I first tried to implement that approach. Indeed, this
seems cleaner. Also, the domain space for boolean partitions is very small, so
any added cost for searching not equal seems negligible.

Thanks,
David

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Drouvot, Bertrand 2023-04-12 16:15:10 Add two missing tests in 035_standby_logical_decoding.pl
Previous Message Andrew Dunstan 2023-04-12 16:12:05 Re: Direct I/O