Re: constraint exclusion with a tsrange type - Mailing list pgsql-general

From Tom Lane
Subject Re: constraint exclusion with a tsrange type
Date
Msg-id 32333.1536797387@sss.pgh.pa.us
Whole thread Raw
In response to constraint exclusion with a tsrange type  (Ben Chobot <bench@silentmedia.com>)
List pgsql-general
Ben Chobot <bench@silentmedia.com> writes:
> Hey everybody, I'm having trouble getting constraint exclusion to work on a table partitioned with a tsrange type.
I'vedistilled it down to this: 
> create table t (
>   id serial primary key,
>   observed_window tsrange not null
> );
> create index t_window on t(observed_window);

> create table p1 (like t including all);
> alter table p1 add check ( tsrange('2018-1-1','2019-2-1') @> observed_window);
> alter table p1 inherit t;
> create table p2 (like t including all);
> alter table p2 inherit t;
> alter table p2 add check ( tsrange('2018-2-1','2019-3-1') @> observed_window);

> # explain select * from t where tsrange('2018-1-5','2018-1-6') @> observed_window;

Nope, sorry, there's no logic in there about ranges.  You'd have to
break this down into something involving simple timestamp comparison
operators for constraint exclusion to be able to prove anything.

Might be a reasonable future extension, perhaps...

            regards, tom lane


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: PG9.1 migration to PG9.6, dump/restore issues
Next
From: Michael Paquier
Date:
Subject: Re: scram-sha-256 authentication broken in FIPS mode