Re: constraint checking on partitions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Chris Spotts" <rfusca(at)gmail(dot)com>
Cc: "'postgres list'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: constraint checking on partitions
Date: 2009-07-09 19:09:04
Message-ID: 5053.1247166544@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Chris Spotts" <rfusca(at)gmail(dot)com> writes:
> I mistyped, that should be

> alter table D add constraint onlyjuly check (date1 >= '2009-07-01' and date1
> < '2009-08-01')
> Then this is also run
> alter table O add constraint notjuly check (NOT(date1 >= '2009-07-01' and
> date1 < '2009-08-01'))

> If I ran a select * from A where date1 >= '2009-07-02' and date1 <
> '2009-07-15' then I would think it wouldn't check O.

Works for me ...

regression=# create table a (date1 date);
CREATE TABLE
regression=# create table july() inherits(a);
CREATE TABLE
regression=# create table other() inherits(a);
CREATE TABLE
regression=# alter table other add constraint notjuly check (NOT(date1 >= '2009-07-01' and date1 < '2009-08-01'));
ALTER TABLE
regression=# explain select * from a where date1 >= '2009-07-02' and date1 < '2009-07-15';
QUERY PLAN
----------------------------------------------------------------------------------------
Result (cost=0.00..92.00 rows=24 width=4)
-> Append (cost=0.00..92.00 rows=24 width=4)
-> Seq Scan on a (cost=0.00..46.00 rows=12 width=4)
Filter: ((date1 >= '2009-07-02'::date) AND (date1 < '2009-07-15'::date))
-> Seq Scan on july a (cost=0.00..46.00 rows=12 width=4)
Filter: ((date1 >= '2009-07-02'::date) AND (date1 < '2009-07-15'::date))
(6 rows)

regression=#

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Spotts 2009-07-09 19:45:08 Re: constraint checking on partitions
Previous Message Chris Spotts 2009-07-09 18:59:30 Re: constraint checking on partitions