Re: constraint exclusion with a tsrange type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ben Chobot <bench(at)silentmedia(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: constraint exclusion with a tsrange type
Date: 2018-09-13 00:09:47
Message-ID: 32333.1536797387@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ben Chobot <bench(at)silentmedia(dot)com> writes:
> Hey everybody, I'm having trouble getting constraint exclusion to work on a table partitioned with a tsrange type. I've distilled 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Paquier 2018-09-13 03:11:14 Re: scram-sha-256 authentication broken in FIPS mode
Previous Message Adrian Klaver 2018-09-12 23:53:01 Re: PG9.1 migration to PG9.6, dump/restore issues