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