Re: constraint checking on partitions - Mailing list pgsql-general

From Tom Lane
Subject Re: constraint checking on partitions
Date
Msg-id 5053.1247166544@sss.pgh.pa.us
Whole thread Raw
In response to Re: constraint checking on partitions  ("Chris Spotts" <rfusca@gmail.com>)
Responses Re: constraint checking on partitions
List pgsql-general
"Chris Spotts" <rfusca@gmail.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

pgsql-general by date:

Previous
From: "Chris Spotts"
Date:
Subject: Re: constraint checking on partitions
Next
From: "Chris Spotts"
Date:
Subject: Re: constraint checking on partitions