Re: partitioning - Mailing list pgsql-general

From David Rowley
Subject Re: partitioning
Date
Msg-id CAApHDvoE2C=hUmAR_6a7kUE8hfvgxcK-b1ujZG+51YTAuyfZ6g@mail.gmail.com
Whole thread Raw
In response to partitioning  (Torsten Förtsch <tfoertsch123@gmail.com>)
List pgsql-general
On Tue, 24 Oct 2023 at 10:39, Torsten Förtsch <tfoertsch123@gmail.com> wrote:
> Then I added this constraint to the small table:
>
> ALTER TABLE original_small_table
> ADD CONSTRAINT partition_boundaries
> CHECK((false, '-infinity')<=(is_sold, purchase_time)
>   AND (is_sold, purchase_time)<(false, 'infinity'))
>   NOT VALID;
>
> And validated it.
>
> When this is being attached as a partition, I still can see the process is reading the entire table.

I'm not seeing any handling of RowCompareExpr in predtest.c, so it
appears your row comparisons can't be used to prove that the CHECK
constraint implies the partition constraint.

> What am I missing? What should the check constraint look like in my case to match the partition constraint?

The following should work:

ALTER TABLE original_small_table ADD CONSTRAINT partition_boundaries
CHECK(not is_sold and purchase_time >= '-infinity' and purchase_time <
'infinity');

David



pgsql-general by date:

Previous
From: Ron
Date:
Subject: Re: setting up streaming replication
Next
From: Merlin Moncure
Date:
Subject: Re: psql _ and \e -- what does clearing the query buffer actually do?