From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ben Chobot <bench@silentmedia.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: constraint exclusion with a tsrange type
Date: Wed, 12 Sep 2018 20:09:47 -0400
Message-ID: <32333.1536797387@sss.pgh.pa.us> (raw)
In-Reply-To: <EC8A473F-BA09-4AE7-9D61-5A1027FF0852@silentmedia.com>
References: <EC8A473F-BA09-4AE7-9D61-5A1027FF0852@silentmedia.com>
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'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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, bench@silentmedia.com
Subject: Re: constraint exclusion with a tsrange type
In-Reply-To: <32333.1536797387@sss.pgh.pa.us>
References: <EC8A473F-BA09-4AE7-9D61-5A1027FF0852@silentmedia.com> <32333.1536797387@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox